97c97ec75185fe26587177f23d269d214d896293
[ldk-java] / src / main / jni / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include <jni.h>
4 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
5 #define int64_t jlong
6 #include "org_ldk_impl_bindings.h"
7 #include <lightning.h>
8 #include <string.h>
9 #include <stdatomic.h>
10 #include <stdlib.h>
11
12 #define LIKELY(v) __builtin_expect(!!(v), 1)
13 #define UNLIKELY(v) __builtin_expect(!!(v), 0)
14
15 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
16 #define MALLOC(a, _) malloc(a)
17 #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
18 #define CHECK_ACCESS(p)
19 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
20 #define DO_ASSERT(a) (void)(a)
21 #define CHECK(a)
22
23 static jmethodID ordinal_meth = NULL;
24 static jmethodID slicedef_meth = NULL;
25 static jclass slicedef_cls = NULL;
26 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
27         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
28         CHECK(ordinal_meth != NULL);
29         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
30         CHECK(slicedef_meth != NULL);
31         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
32         CHECK(slicedef_cls != NULL);
33 }
34
35 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
36         return *((bool*)ptr);
37 }
38 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
39         return *((long*)ptr);
40 }
41 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
42         FREE((void*)ptr);
43 }
44 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
45         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
46         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
47         return ret_arr;
48 }
49 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
50         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
51         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
52         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
53         return ret_arr;
54 }
55 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
56         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
57         vec->datalen = (*env)->GetArrayLength(env, bytes);
58         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
59         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
60         return (uint64_t)vec;
61 }
62 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
63         LDKTransaction *txdata = (LDKTransaction*)ptr;
64         LDKu8slice slice;
65         slice.data = txdata->data;
66         slice.datalen = txdata->datalen;
67         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
68 }
69 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
70         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
71         txdata->datalen = (*env)->GetArrayLength(env, bytes);
72         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
73         txdata->data_is_owned = false;
74         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
75         return (uint64_t)txdata;
76 }
77 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
78         LDKTransaction *tx = (LDKTransaction*)ptr;
79         tx->data_is_owned = true;
80         Transaction_free(*tx);
81         FREE((void*)ptr);
82 }
83 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
84         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
85         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
86         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
87         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
88         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
89         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
90         return (uint64_t)vec->datalen;
91 }
92 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
93         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
94         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
95         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
96         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
97         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
98         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
99         vec->data = NULL;
100         vec->datalen = 0;
101         return (uint64_t)vec;
102 }
103
104 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
105 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
106 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
107 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
108
109 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
110 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
111 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
112
113 typedef jlongArray int64_tArray;
114 typedef jbyteArray int8_tArray;
115
116 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
117         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
118         char* conv_buf = MALLOC(len + 1, "str conv buf");
119         memcpy(conv_buf, chars, len);
120         conv_buf[len] = 0;
121         jstring ret = (*env)->NewStringUTF(env, conv_buf);
122         FREE(conv_buf);
123         return ret;
124 }
125 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
126         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
127         char* newchars = MALLOC(str_len + 1, "String chars");
128         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
129         memcpy(newchars, jchars, str_len);
130         newchars[str_len] = 0;
131         (*env)->ReleaseStringUTFChars(env, str, jchars);
132         LDKStr res = {
133                 .chars = newchars,
134                 .len = str_len,
135                 .chars_is_owned = true
136         };
137         return res;
138 }
139
140 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
141         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
142 }
143 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
144         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
145 }
146 #include "version.c"
147 static jclass arr_of_B_clz = NULL;
148 static jclass arr_of_J_clz = NULL;
149 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
150         arr_of_B_clz = (*env)->FindClass(env, "[B");
151         CHECK(arr_of_B_clz != NULL);
152         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
153         arr_of_J_clz = (*env)->FindClass(env, "[J");
154         CHECK(arr_of_J_clz != NULL);
155         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
156 }
157 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
158 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
159         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
160         if (UNLIKELY((*env)->ExceptionCheck(env))) {
161                 (*env)->ExceptionDescribe(env);
162                 (*env)->FatalError(env, "A call to AccessError.ordinal() from rust threw an exception.");
163         }
164         switch (ord) {
165                 case 0: return LDKAccessError_UnknownChain;
166                 case 1: return LDKAccessError_UnknownTx;
167         }
168         (*env)->FatalError(env, "A call to AccessError.ordinal() from rust returned an invalid value.");
169         abort(); // Unreachable, but will let the compiler know we don't return here
170 }
171 static jclass AccessError_class = NULL;
172 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
173 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
174 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
175         AccessError_class = (*env)->NewGlobalRef(env, clz);
176         CHECK(AccessError_class != NULL);
177         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
178         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
179         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
180         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
181 }
182 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
183         switch (val) {
184                 case LDKAccessError_UnknownChain:
185                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
186                 case LDKAccessError_UnknownTx:
187                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
188                 default: abort();
189         }
190 }
191
192 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_java(JNIEnv *env, jclass clz) {
193         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
194         if (UNLIKELY((*env)->ExceptionCheck(env))) {
195                 (*env)->ExceptionDescribe(env);
196                 (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust threw an exception.");
197         }
198         switch (ord) {
199                 case 0: return LDKCOption_NoneZ_Some;
200                 case 1: return LDKCOption_NoneZ_None;
201         }
202         (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust returned an invalid value.");
203         abort(); // Unreachable, but will let the compiler know we don't return here
204 }
205 static jclass COption_NoneZ_class = NULL;
206 static jfieldID COption_NoneZ_LDKCOption_NoneZ_Some = NULL;
207 static jfieldID COption_NoneZ_LDKCOption_NoneZ_None = NULL;
208 JNIEXPORT void JNICALL Java_org_ldk_enums_COption_1NoneZ_init (JNIEnv *env, jclass clz) {
209         COption_NoneZ_class = (*env)->NewGlobalRef(env, clz);
210         CHECK(COption_NoneZ_class != NULL);
211         COption_NoneZ_LDKCOption_NoneZ_Some = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_Some", "Lorg/ldk/enums/COption_NoneZ;");
212         CHECK(COption_NoneZ_LDKCOption_NoneZ_Some != NULL);
213         COption_NoneZ_LDKCOption_NoneZ_None = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_None", "Lorg/ldk/enums/COption_NoneZ;");
214         CHECK(COption_NoneZ_LDKCOption_NoneZ_None != NULL);
215 }
216 static inline jclass LDKCOption_NoneZ_to_java(JNIEnv *env, LDKCOption_NoneZ val) {
217         switch (val) {
218                 case LDKCOption_NoneZ_Some:
219                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_Some);
220                 case LDKCOption_NoneZ_None:
221                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_None);
222                 default: abort();
223         }
224 }
225
226 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
227         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
228         if (UNLIKELY((*env)->ExceptionCheck(env))) {
229                 (*env)->ExceptionDescribe(env);
230                 (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust threw an exception.");
231         }
232         switch (ord) {
233                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
234                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
235         }
236         (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust returned an invalid value.");
237         abort(); // Unreachable, but will let the compiler know we don't return here
238 }
239 static jclass ChannelMonitorUpdateErr_class = NULL;
240 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
241 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
242 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
243         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
244         CHECK(ChannelMonitorUpdateErr_class != NULL);
245         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
246         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
247         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
248         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
249 }
250 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
251         switch (val) {
252                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
253                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
254                 case LDKChannelMonitorUpdateErr_PermanentFailure:
255                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
256                 default: abort();
257         }
258 }
259
260 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
261         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
262         if (UNLIKELY((*env)->ExceptionCheck(env))) {
263                 (*env)->ExceptionDescribe(env);
264                 (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust threw an exception.");
265         }
266         switch (ord) {
267                 case 0: return LDKConfirmationTarget_Background;
268                 case 1: return LDKConfirmationTarget_Normal;
269                 case 2: return LDKConfirmationTarget_HighPriority;
270         }
271         (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust returned an invalid value.");
272         abort(); // Unreachable, but will let the compiler know we don't return here
273 }
274 static jclass ConfirmationTarget_class = NULL;
275 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
276 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
277 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
278 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
279         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
280         CHECK(ConfirmationTarget_class != NULL);
281         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
282         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
283         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
284         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
285         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
286         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
287 }
288 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
289         switch (val) {
290                 case LDKConfirmationTarget_Background:
291                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
292                 case LDKConfirmationTarget_Normal:
293                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
294                 case LDKConfirmationTarget_HighPriority:
295                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
296                 default: abort();
297         }
298 }
299
300 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
301         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
302         if (UNLIKELY((*env)->ExceptionCheck(env))) {
303                 (*env)->ExceptionDescribe(env);
304                 (*env)->FatalError(env, "A call to CreationError.ordinal() from rust threw an exception.");
305         }
306         switch (ord) {
307                 case 0: return LDKCreationError_DescriptionTooLong;
308                 case 1: return LDKCreationError_RouteTooLong;
309                 case 2: return LDKCreationError_TimestampOutOfBounds;
310                 case 3: return LDKCreationError_InvalidAmount;
311                 case 4: return LDKCreationError_MissingRouteHints;
312         }
313         (*env)->FatalError(env, "A call to CreationError.ordinal() from rust returned an invalid value.");
314         abort(); // Unreachable, but will let the compiler know we don't return here
315 }
316 static jclass CreationError_class = NULL;
317 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
318 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
319 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
320 static jfieldID CreationError_LDKCreationError_InvalidAmount = NULL;
321 static jfieldID CreationError_LDKCreationError_MissingRouteHints = NULL;
322 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
323         CreationError_class = (*env)->NewGlobalRef(env, clz);
324         CHECK(CreationError_class != NULL);
325         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
326         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
327         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
328         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
329         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
330         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
331         CreationError_LDKCreationError_InvalidAmount = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_InvalidAmount", "Lorg/ldk/enums/CreationError;");
332         CHECK(CreationError_LDKCreationError_InvalidAmount != NULL);
333         CreationError_LDKCreationError_MissingRouteHints = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_MissingRouteHints", "Lorg/ldk/enums/CreationError;");
334         CHECK(CreationError_LDKCreationError_MissingRouteHints != NULL);
335 }
336 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
337         switch (val) {
338                 case LDKCreationError_DescriptionTooLong:
339                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
340                 case LDKCreationError_RouteTooLong:
341                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
342                 case LDKCreationError_TimestampOutOfBounds:
343                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
344                 case LDKCreationError_InvalidAmount:
345                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_InvalidAmount);
346                 case LDKCreationError_MissingRouteHints:
347                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_MissingRouteHints);
348                 default: abort();
349         }
350 }
351
352 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
353         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
354         if (UNLIKELY((*env)->ExceptionCheck(env))) {
355                 (*env)->ExceptionDescribe(env);
356                 (*env)->FatalError(env, "A call to Currency.ordinal() from rust threw an exception.");
357         }
358         switch (ord) {
359                 case 0: return LDKCurrency_Bitcoin;
360                 case 1: return LDKCurrency_BitcoinTestnet;
361                 case 2: return LDKCurrency_Regtest;
362                 case 3: return LDKCurrency_Simnet;
363                 case 4: return LDKCurrency_Signet;
364         }
365         (*env)->FatalError(env, "A call to Currency.ordinal() from rust returned an invalid value.");
366         abort(); // Unreachable, but will let the compiler know we don't return here
367 }
368 static jclass Currency_class = NULL;
369 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
370 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
371 static jfieldID Currency_LDKCurrency_Regtest = NULL;
372 static jfieldID Currency_LDKCurrency_Simnet = NULL;
373 static jfieldID Currency_LDKCurrency_Signet = NULL;
374 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
375         Currency_class = (*env)->NewGlobalRef(env, clz);
376         CHECK(Currency_class != NULL);
377         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
378         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
379         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
380         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
381         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
382         CHECK(Currency_LDKCurrency_Regtest != NULL);
383         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
384         CHECK(Currency_LDKCurrency_Simnet != NULL);
385         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
386         CHECK(Currency_LDKCurrency_Signet != NULL);
387 }
388 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
389         switch (val) {
390                 case LDKCurrency_Bitcoin:
391                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
392                 case LDKCurrency_BitcoinTestnet:
393                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
394                 case LDKCurrency_Regtest:
395                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
396                 case LDKCurrency_Simnet:
397                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
398                 case LDKCurrency_Signet:
399                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
400                 default: abort();
401         }
402 }
403
404 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
405         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
406         if (UNLIKELY((*env)->ExceptionCheck(env))) {
407                 (*env)->ExceptionDescribe(env);
408                 (*env)->FatalError(env, "A call to IOError.ordinal() from rust threw an exception.");
409         }
410         switch (ord) {
411                 case 0: return LDKIOError_NotFound;
412                 case 1: return LDKIOError_PermissionDenied;
413                 case 2: return LDKIOError_ConnectionRefused;
414                 case 3: return LDKIOError_ConnectionReset;
415                 case 4: return LDKIOError_ConnectionAborted;
416                 case 5: return LDKIOError_NotConnected;
417                 case 6: return LDKIOError_AddrInUse;
418                 case 7: return LDKIOError_AddrNotAvailable;
419                 case 8: return LDKIOError_BrokenPipe;
420                 case 9: return LDKIOError_AlreadyExists;
421                 case 10: return LDKIOError_WouldBlock;
422                 case 11: return LDKIOError_InvalidInput;
423                 case 12: return LDKIOError_InvalidData;
424                 case 13: return LDKIOError_TimedOut;
425                 case 14: return LDKIOError_WriteZero;
426                 case 15: return LDKIOError_Interrupted;
427                 case 16: return LDKIOError_Other;
428                 case 17: return LDKIOError_UnexpectedEof;
429         }
430         (*env)->FatalError(env, "A call to IOError.ordinal() from rust returned an invalid value.");
431         abort(); // Unreachable, but will let the compiler know we don't return here
432 }
433 static jclass IOError_class = NULL;
434 static jfieldID IOError_LDKIOError_NotFound = NULL;
435 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
436 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
437 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
438 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
439 static jfieldID IOError_LDKIOError_NotConnected = NULL;
440 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
441 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
442 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
443 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
444 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
445 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
446 static jfieldID IOError_LDKIOError_InvalidData = NULL;
447 static jfieldID IOError_LDKIOError_TimedOut = NULL;
448 static jfieldID IOError_LDKIOError_WriteZero = NULL;
449 static jfieldID IOError_LDKIOError_Interrupted = NULL;
450 static jfieldID IOError_LDKIOError_Other = NULL;
451 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
452 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
453         IOError_class = (*env)->NewGlobalRef(env, clz);
454         CHECK(IOError_class != NULL);
455         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
456         CHECK(IOError_LDKIOError_NotFound != NULL);
457         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
458         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
459         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
460         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
461         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
462         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
463         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
464         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
465         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
466         CHECK(IOError_LDKIOError_NotConnected != NULL);
467         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
468         CHECK(IOError_LDKIOError_AddrInUse != NULL);
469         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
470         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
471         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
472         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
473         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
474         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
475         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
476         CHECK(IOError_LDKIOError_WouldBlock != NULL);
477         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
478         CHECK(IOError_LDKIOError_InvalidInput != NULL);
479         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
480         CHECK(IOError_LDKIOError_InvalidData != NULL);
481         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
482         CHECK(IOError_LDKIOError_TimedOut != NULL);
483         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
484         CHECK(IOError_LDKIOError_WriteZero != NULL);
485         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
486         CHECK(IOError_LDKIOError_Interrupted != NULL);
487         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
488         CHECK(IOError_LDKIOError_Other != NULL);
489         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
490         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
491 }
492 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
493         switch (val) {
494                 case LDKIOError_NotFound:
495                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
496                 case LDKIOError_PermissionDenied:
497                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
498                 case LDKIOError_ConnectionRefused:
499                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
500                 case LDKIOError_ConnectionReset:
501                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
502                 case LDKIOError_ConnectionAborted:
503                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
504                 case LDKIOError_NotConnected:
505                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
506                 case LDKIOError_AddrInUse:
507                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
508                 case LDKIOError_AddrNotAvailable:
509                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
510                 case LDKIOError_BrokenPipe:
511                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
512                 case LDKIOError_AlreadyExists:
513                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
514                 case LDKIOError_WouldBlock:
515                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
516                 case LDKIOError_InvalidInput:
517                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
518                 case LDKIOError_InvalidData:
519                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
520                 case LDKIOError_TimedOut:
521                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
522                 case LDKIOError_WriteZero:
523                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
524                 case LDKIOError_Interrupted:
525                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
526                 case LDKIOError_Other:
527                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
528                 case LDKIOError_UnexpectedEof:
529                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
530                 default: abort();
531         }
532 }
533
534 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
535         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
536         if (UNLIKELY((*env)->ExceptionCheck(env))) {
537                 (*env)->ExceptionDescribe(env);
538                 (*env)->FatalError(env, "A call to Level.ordinal() from rust threw an exception.");
539         }
540         switch (ord) {
541                 case 0: return LDKLevel_Gossip;
542                 case 1: return LDKLevel_Trace;
543                 case 2: return LDKLevel_Debug;
544                 case 3: return LDKLevel_Info;
545                 case 4: return LDKLevel_Warn;
546                 case 5: return LDKLevel_Error;
547         }
548         (*env)->FatalError(env, "A call to Level.ordinal() from rust returned an invalid value.");
549         abort(); // Unreachable, but will let the compiler know we don't return here
550 }
551 static jclass Level_class = NULL;
552 static jfieldID Level_LDKLevel_Gossip = NULL;
553 static jfieldID Level_LDKLevel_Trace = NULL;
554 static jfieldID Level_LDKLevel_Debug = NULL;
555 static jfieldID Level_LDKLevel_Info = NULL;
556 static jfieldID Level_LDKLevel_Warn = NULL;
557 static jfieldID Level_LDKLevel_Error = NULL;
558 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
559         Level_class = (*env)->NewGlobalRef(env, clz);
560         CHECK(Level_class != NULL);
561         Level_LDKLevel_Gossip = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Gossip", "Lorg/ldk/enums/Level;");
562         CHECK(Level_LDKLevel_Gossip != NULL);
563         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
564         CHECK(Level_LDKLevel_Trace != NULL);
565         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
566         CHECK(Level_LDKLevel_Debug != NULL);
567         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
568         CHECK(Level_LDKLevel_Info != NULL);
569         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
570         CHECK(Level_LDKLevel_Warn != NULL);
571         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
572         CHECK(Level_LDKLevel_Error != NULL);
573 }
574 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
575         switch (val) {
576                 case LDKLevel_Gossip:
577                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Gossip);
578                 case LDKLevel_Trace:
579                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
580                 case LDKLevel_Debug:
581                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
582                 case LDKLevel_Info:
583                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
584                 case LDKLevel_Warn:
585                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
586                 case LDKLevel_Error:
587                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
588                 default: abort();
589         }
590 }
591
592 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
593         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
594         if (UNLIKELY((*env)->ExceptionCheck(env))) {
595                 (*env)->ExceptionDescribe(env);
596                 (*env)->FatalError(env, "A call to Network.ordinal() from rust threw an exception.");
597         }
598         switch (ord) {
599                 case 0: return LDKNetwork_Bitcoin;
600                 case 1: return LDKNetwork_Testnet;
601                 case 2: return LDKNetwork_Regtest;
602                 case 3: return LDKNetwork_Signet;
603         }
604         (*env)->FatalError(env, "A call to Network.ordinal() from rust returned an invalid value.");
605         abort(); // Unreachable, but will let the compiler know we don't return here
606 }
607 static jclass Network_class = NULL;
608 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
609 static jfieldID Network_LDKNetwork_Testnet = NULL;
610 static jfieldID Network_LDKNetwork_Regtest = NULL;
611 static jfieldID Network_LDKNetwork_Signet = NULL;
612 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
613         Network_class = (*env)->NewGlobalRef(env, clz);
614         CHECK(Network_class != NULL);
615         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
616         CHECK(Network_LDKNetwork_Bitcoin != NULL);
617         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
618         CHECK(Network_LDKNetwork_Testnet != NULL);
619         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
620         CHECK(Network_LDKNetwork_Regtest != NULL);
621         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
622         CHECK(Network_LDKNetwork_Signet != NULL);
623 }
624 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
625         switch (val) {
626                 case LDKNetwork_Bitcoin:
627                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
628                 case LDKNetwork_Testnet:
629                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
630                 case LDKNetwork_Regtest:
631                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
632                 case LDKNetwork_Signet:
633                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
634                 default: abort();
635         }
636 }
637
638 static inline LDKRecipient LDKRecipient_from_java(JNIEnv *env, jclass clz) {
639         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
640         if (UNLIKELY((*env)->ExceptionCheck(env))) {
641                 (*env)->ExceptionDescribe(env);
642                 (*env)->FatalError(env, "A call to Recipient.ordinal() from rust threw an exception.");
643         }
644         switch (ord) {
645                 case 0: return LDKRecipient_Node;
646                 case 1: return LDKRecipient_PhantomNode;
647         }
648         (*env)->FatalError(env, "A call to Recipient.ordinal() from rust returned an invalid value.");
649         abort(); // Unreachable, but will let the compiler know we don't return here
650 }
651 static jclass Recipient_class = NULL;
652 static jfieldID Recipient_LDKRecipient_Node = NULL;
653 static jfieldID Recipient_LDKRecipient_PhantomNode = NULL;
654 JNIEXPORT void JNICALL Java_org_ldk_enums_Recipient_init (JNIEnv *env, jclass clz) {
655         Recipient_class = (*env)->NewGlobalRef(env, clz);
656         CHECK(Recipient_class != NULL);
657         Recipient_LDKRecipient_Node = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_Node", "Lorg/ldk/enums/Recipient;");
658         CHECK(Recipient_LDKRecipient_Node != NULL);
659         Recipient_LDKRecipient_PhantomNode = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_PhantomNode", "Lorg/ldk/enums/Recipient;");
660         CHECK(Recipient_LDKRecipient_PhantomNode != NULL);
661 }
662 static inline jclass LDKRecipient_to_java(JNIEnv *env, LDKRecipient val) {
663         switch (val) {
664                 case LDKRecipient_Node:
665                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_Node);
666                 case LDKRecipient_PhantomNode:
667                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_PhantomNode);
668                 default: abort();
669         }
670 }
671
672 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
673         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
674         if (UNLIKELY((*env)->ExceptionCheck(env))) {
675                 (*env)->ExceptionDescribe(env);
676                 (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust threw an exception.");
677         }
678         switch (ord) {
679                 case 0: return LDKSecp256k1Error_IncorrectSignature;
680                 case 1: return LDKSecp256k1Error_InvalidMessage;
681                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
682                 case 3: return LDKSecp256k1Error_InvalidSignature;
683                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
684                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
685                 case 6: return LDKSecp256k1Error_InvalidTweak;
686                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
687                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
688         }
689         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
690         abort(); // Unreachable, but will let the compiler know we don't return here
691 }
692 static jclass Secp256k1Error_class = NULL;
693 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
694 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
695 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
696 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
697 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
698 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
699 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
700 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
701 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
702 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
703         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
704         CHECK(Secp256k1Error_class != NULL);
705         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
706         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
707         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
708         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
709         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
710         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
711         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
712         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
713         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
714         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
715         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
716         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
717         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
718         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
719         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
720         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
721         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
722         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
723 }
724 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
725         switch (val) {
726                 case LDKSecp256k1Error_IncorrectSignature:
727                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
728                 case LDKSecp256k1Error_InvalidMessage:
729                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
730                 case LDKSecp256k1Error_InvalidPublicKey:
731                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
732                 case LDKSecp256k1Error_InvalidSignature:
733                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
734                 case LDKSecp256k1Error_InvalidSecretKey:
735                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
736                 case LDKSecp256k1Error_InvalidRecoveryId:
737                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
738                 case LDKSecp256k1Error_InvalidTweak:
739                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
740                 case LDKSecp256k1Error_TweakCheckFailed:
741                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
742                 case LDKSecp256k1Error_NotEnoughMemory:
743                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
744                 default: abort();
745         }
746 }
747
748 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
749         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
750         if (UNLIKELY((*env)->ExceptionCheck(env))) {
751                 (*env)->ExceptionDescribe(env);
752                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
753         }
754         switch (ord) {
755                 case 0: return LDKSemanticError_NoPaymentHash;
756                 case 1: return LDKSemanticError_MultiplePaymentHashes;
757                 case 2: return LDKSemanticError_NoDescription;
758                 case 3: return LDKSemanticError_MultipleDescriptions;
759                 case 4: return LDKSemanticError_NoPaymentSecret;
760                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
761                 case 6: return LDKSemanticError_InvalidFeatures;
762                 case 7: return LDKSemanticError_InvalidRecoveryId;
763                 case 8: return LDKSemanticError_InvalidSignature;
764                 case 9: return LDKSemanticError_ImpreciseAmount;
765         }
766         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
767         abort(); // Unreachable, but will let the compiler know we don't return here
768 }
769 static jclass SemanticError_class = NULL;
770 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
771 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
772 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
773 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
774 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
775 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
776 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
777 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
778 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
779 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
780 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
781         SemanticError_class = (*env)->NewGlobalRef(env, clz);
782         CHECK(SemanticError_class != NULL);
783         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
784         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
785         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
786         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
787         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
788         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
789         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
790         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
791         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
792         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
793         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
794         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
795         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
796         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
797         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
798         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
799         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
800         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
801         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
802         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
803 }
804 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
805         switch (val) {
806                 case LDKSemanticError_NoPaymentHash:
807                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
808                 case LDKSemanticError_MultiplePaymentHashes:
809                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
810                 case LDKSemanticError_NoDescription:
811                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
812                 case LDKSemanticError_MultipleDescriptions:
813                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
814                 case LDKSemanticError_NoPaymentSecret:
815                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
816                 case LDKSemanticError_MultiplePaymentSecrets:
817                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
818                 case LDKSemanticError_InvalidFeatures:
819                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
820                 case LDKSemanticError_InvalidRecoveryId:
821                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
822                 case LDKSemanticError_InvalidSignature:
823                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
824                 case LDKSemanticError_ImpreciseAmount:
825                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
826                 default: abort();
827         }
828 }
829
830 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
831         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
832         if (UNLIKELY((*env)->ExceptionCheck(env))) {
833                 (*env)->ExceptionDescribe(env);
834                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
835         }
836         switch (ord) {
837                 case 0: return LDKSiPrefix_Milli;
838                 case 1: return LDKSiPrefix_Micro;
839                 case 2: return LDKSiPrefix_Nano;
840                 case 3: return LDKSiPrefix_Pico;
841         }
842         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
843         abort(); // Unreachable, but will let the compiler know we don't return here
844 }
845 static jclass SiPrefix_class = NULL;
846 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
847 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
848 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
849 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
850 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
851         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
852         CHECK(SiPrefix_class != NULL);
853         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
854         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
855         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
856         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
857         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
858         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
859         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
860         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
861 }
862 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
863         switch (val) {
864                 case LDKSiPrefix_Milli:
865                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
866                 case LDKSiPrefix_Micro:
867                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
868                 case LDKSiPrefix_Nano:
869                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
870                 case LDKSiPrefix_Pico:
871                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
872                 default: abort();
873         }
874 }
875
876 static jclass LDKBech32Error_MissingSeparator_class = NULL;
877 static jmethodID LDKBech32Error_MissingSeparator_meth = NULL;
878 static jclass LDKBech32Error_InvalidChecksum_class = NULL;
879 static jmethodID LDKBech32Error_InvalidChecksum_meth = NULL;
880 static jclass LDKBech32Error_InvalidLength_class = NULL;
881 static jmethodID LDKBech32Error_InvalidLength_meth = NULL;
882 static jclass LDKBech32Error_InvalidChar_class = NULL;
883 static jmethodID LDKBech32Error_InvalidChar_meth = NULL;
884 static jclass LDKBech32Error_InvalidData_class = NULL;
885 static jmethodID LDKBech32Error_InvalidData_meth = NULL;
886 static jclass LDKBech32Error_InvalidPadding_class = NULL;
887 static jmethodID LDKBech32Error_InvalidPadding_meth = NULL;
888 static jclass LDKBech32Error_MixedCase_class = NULL;
889 static jmethodID LDKBech32Error_MixedCase_meth = NULL;
890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBech32Error_init (JNIEnv *env, jclass clz) {
891         LDKBech32Error_MissingSeparator_class =
892                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MissingSeparator"));
893         CHECK(LDKBech32Error_MissingSeparator_class != NULL);
894         LDKBech32Error_MissingSeparator_meth = (*env)->GetMethodID(env, LDKBech32Error_MissingSeparator_class, "<init>", "()V");
895         CHECK(LDKBech32Error_MissingSeparator_meth != NULL);
896         LDKBech32Error_InvalidChecksum_class =
897                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChecksum"));
898         CHECK(LDKBech32Error_InvalidChecksum_class != NULL);
899         LDKBech32Error_InvalidChecksum_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChecksum_class, "<init>", "()V");
900         CHECK(LDKBech32Error_InvalidChecksum_meth != NULL);
901         LDKBech32Error_InvalidLength_class =
902                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidLength"));
903         CHECK(LDKBech32Error_InvalidLength_class != NULL);
904         LDKBech32Error_InvalidLength_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidLength_class, "<init>", "()V");
905         CHECK(LDKBech32Error_InvalidLength_meth != NULL);
906         LDKBech32Error_InvalidChar_class =
907                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChar"));
908         CHECK(LDKBech32Error_InvalidChar_class != NULL);
909         LDKBech32Error_InvalidChar_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChar_class, "<init>", "(I)V");
910         CHECK(LDKBech32Error_InvalidChar_meth != NULL);
911         LDKBech32Error_InvalidData_class =
912                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidData"));
913         CHECK(LDKBech32Error_InvalidData_class != NULL);
914         LDKBech32Error_InvalidData_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidData_class, "<init>", "(B)V");
915         CHECK(LDKBech32Error_InvalidData_meth != NULL);
916         LDKBech32Error_InvalidPadding_class =
917                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidPadding"));
918         CHECK(LDKBech32Error_InvalidPadding_class != NULL);
919         LDKBech32Error_InvalidPadding_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidPadding_class, "<init>", "()V");
920         CHECK(LDKBech32Error_InvalidPadding_meth != NULL);
921         LDKBech32Error_MixedCase_class =
922                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MixedCase"));
923         CHECK(LDKBech32Error_MixedCase_class != NULL);
924         LDKBech32Error_MixedCase_meth = (*env)->GetMethodID(env, LDKBech32Error_MixedCase_class, "<init>", "()V");
925         CHECK(LDKBech32Error_MixedCase_meth != NULL);
926 }
927 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBech32Error_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
928         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
929         switch(obj->tag) {
930                 case LDKBech32Error_MissingSeparator: {
931                         return (*env)->NewObject(env, LDKBech32Error_MissingSeparator_class, LDKBech32Error_MissingSeparator_meth);
932                 }
933                 case LDKBech32Error_InvalidChecksum: {
934                         return (*env)->NewObject(env, LDKBech32Error_InvalidChecksum_class, LDKBech32Error_InvalidChecksum_meth);
935                 }
936                 case LDKBech32Error_InvalidLength: {
937                         return (*env)->NewObject(env, LDKBech32Error_InvalidLength_class, LDKBech32Error_InvalidLength_meth);
938                 }
939                 case LDKBech32Error_InvalidChar: {
940                         return (*env)->NewObject(env, LDKBech32Error_InvalidChar_class, LDKBech32Error_InvalidChar_meth, obj->invalid_char);
941                 }
942                 case LDKBech32Error_InvalidData: {
943                         return (*env)->NewObject(env, LDKBech32Error_InvalidData_class, LDKBech32Error_InvalidData_meth, obj->invalid_data);
944                 }
945                 case LDKBech32Error_InvalidPadding: {
946                         return (*env)->NewObject(env, LDKBech32Error_InvalidPadding_class, LDKBech32Error_InvalidPadding_meth);
947                 }
948                 case LDKBech32Error_MixedCase: {
949                         return (*env)->NewObject(env, LDKBech32Error_MixedCase_class, LDKBech32Error_MixedCase_meth);
950                 }
951                 default: abort();
952         }
953 }
954 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
955         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
956         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
957         return ret;
958 }
959 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) {
960         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
961         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
962         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
963         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
964         CVec_u8Z_free(ret_var);
965         return ret_arr;
966 }
967
968 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) {
969         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
970         int64_t ret_val = TxOut_get_value(thing_conv);
971         return ret_val;
972 }
973
974 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
975 CHECK(owner->result_ok);
976         return *owner->contents.result;
977 }
978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
979         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
980         CResult_NoneNoneZ_get_ok(owner_conv);
981 }
982
983 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
984 CHECK(!owner->result_ok);
985         return *owner->contents.err;
986 }
987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
988         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
989         CResult_NoneNoneZ_get_err(owner_conv);
990 }
991
992 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
993 CHECK(owner->result_ok);
994         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
995 }
996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
997         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
998         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
999         int64_t ret_ref = 0;
1000         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1001         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1003         ret_ref = (uintptr_t)ret_var.inner;
1004         if (ret_var.is_owned) {
1005                 ret_ref |= 1;
1006         }
1007         return ret_ref;
1008 }
1009
1010 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1011 CHECK(!owner->result_ok);
1012         return DecodeError_clone(&*owner->contents.err);
1013 }
1014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1015         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
1016         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
1017         int64_t ret_ref = 0;
1018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1021         ret_ref = (uintptr_t)ret_var.inner;
1022         if (ret_var.is_owned) {
1023                 ret_ref |= 1;
1024         }
1025         return ret_ref;
1026 }
1027
1028 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1029 CHECK(owner->result_ok);
1030         return *owner->contents.result;
1031 }
1032 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1033         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
1034         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1035         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes);
1036         return ret_arr;
1037 }
1038
1039 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1040 CHECK(!owner->result_ok);
1041         return *owner->contents.err;
1042 }
1043 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1044         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
1045         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_SecretKeyErrorZ_get_err(owner_conv));
1046         return ret_conv;
1047 }
1048
1049 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1050 CHECK(owner->result_ok);
1051         return *owner->contents.result;
1052 }
1053 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1054         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
1055         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
1056         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
1057         return ret_arr;
1058 }
1059
1060 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1061 CHECK(!owner->result_ok);
1062         return *owner->contents.err;
1063 }
1064 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1065         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
1066         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
1067         return ret_conv;
1068 }
1069
1070 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1071 CHECK(owner->result_ok);
1072         return TxCreationKeys_clone(&*owner->contents.result);
1073 }
1074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1075         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1076         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
1077         int64_t ret_ref = 0;
1078         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1079         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1081         ret_ref = (uintptr_t)ret_var.inner;
1082         if (ret_var.is_owned) {
1083                 ret_ref |= 1;
1084         }
1085         return ret_ref;
1086 }
1087
1088 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1089 CHECK(!owner->result_ok);
1090         return DecodeError_clone(&*owner->contents.err);
1091 }
1092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1093         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1094         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1095         int64_t ret_ref = 0;
1096         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1097         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1099         ret_ref = (uintptr_t)ret_var.inner;
1100         if (ret_var.is_owned) {
1101                 ret_ref |= 1;
1102         }
1103         return ret_ref;
1104 }
1105
1106 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1107 CHECK(owner->result_ok);
1108         return ChannelPublicKeys_clone(&*owner->contents.result);
1109 }
1110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1111         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1112         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1113         int64_t ret_ref = 0;
1114         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1115         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1117         ret_ref = (uintptr_t)ret_var.inner;
1118         if (ret_var.is_owned) {
1119                 ret_ref |= 1;
1120         }
1121         return ret_ref;
1122 }
1123
1124 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1125 CHECK(!owner->result_ok);
1126         return DecodeError_clone(&*owner->contents.err);
1127 }
1128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1129         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1130         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1131         int64_t ret_ref = 0;
1132         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1133         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1135         ret_ref = (uintptr_t)ret_var.inner;
1136         if (ret_var.is_owned) {
1137                 ret_ref |= 1;
1138         }
1139         return ret_ref;
1140 }
1141
1142 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1143 CHECK(owner->result_ok);
1144         return TxCreationKeys_clone(&*owner->contents.result);
1145 }
1146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1147         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1148         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
1149         int64_t ret_ref = 0;
1150         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1151         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1153         ret_ref = (uintptr_t)ret_var.inner;
1154         if (ret_var.is_owned) {
1155                 ret_ref |= 1;
1156         }
1157         return ret_ref;
1158 }
1159
1160 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1161 CHECK(!owner->result_ok);
1162         return *owner->contents.err;
1163 }
1164 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1165         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1166         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_TxCreationKeysErrorZ_get_err(owner_conv));
1167         return ret_conv;
1168 }
1169
1170 static jclass LDKCOption_u32Z_Some_class = NULL;
1171 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1172 static jclass LDKCOption_u32Z_None_class = NULL;
1173 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1175         LDKCOption_u32Z_Some_class =
1176                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1177         CHECK(LDKCOption_u32Z_Some_class != NULL);
1178         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1179         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1180         LDKCOption_u32Z_None_class =
1181                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1182         CHECK(LDKCOption_u32Z_None_class != NULL);
1183         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1184         CHECK(LDKCOption_u32Z_None_meth != NULL);
1185 }
1186 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1187         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
1188         switch(obj->tag) {
1189                 case LDKCOption_u32Z_Some: {
1190                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
1191                 }
1192                 case LDKCOption_u32Z_None: {
1193                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1194                 }
1195                 default: abort();
1196         }
1197 }
1198 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1199 CHECK(owner->result_ok);
1200         return HTLCOutputInCommitment_clone(&*owner->contents.result);
1201 }
1202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1203         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1204         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1205         int64_t ret_ref = 0;
1206         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1207         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1209         ret_ref = (uintptr_t)ret_var.inner;
1210         if (ret_var.is_owned) {
1211                 ret_ref |= 1;
1212         }
1213         return ret_ref;
1214 }
1215
1216 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1217 CHECK(!owner->result_ok);
1218         return DecodeError_clone(&*owner->contents.err);
1219 }
1220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1221         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1222         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1223         int64_t ret_ref = 0;
1224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1227         ret_ref = (uintptr_t)ret_var.inner;
1228         if (ret_var.is_owned) {
1229                 ret_ref |= 1;
1230         }
1231         return ret_ref;
1232 }
1233
1234 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1235 CHECK(owner->result_ok);
1236         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
1237 }
1238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1239         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1240         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1241         int64_t ret_ref = 0;
1242         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1243         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1245         ret_ref = (uintptr_t)ret_var.inner;
1246         if (ret_var.is_owned) {
1247                 ret_ref |= 1;
1248         }
1249         return ret_ref;
1250 }
1251
1252 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1253 CHECK(!owner->result_ok);
1254         return DecodeError_clone(&*owner->contents.err);
1255 }
1256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1257         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1258         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1259         int64_t ret_ref = 0;
1260         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1261         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1263         ret_ref = (uintptr_t)ret_var.inner;
1264         if (ret_var.is_owned) {
1265                 ret_ref |= 1;
1266         }
1267         return ret_ref;
1268 }
1269
1270 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1271 CHECK(owner->result_ok);
1272         return ChannelTransactionParameters_clone(&*owner->contents.result);
1273 }
1274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1275         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1276         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1277         int64_t ret_ref = 0;
1278         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1279         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1281         ret_ref = (uintptr_t)ret_var.inner;
1282         if (ret_var.is_owned) {
1283                 ret_ref |= 1;
1284         }
1285         return ret_ref;
1286 }
1287
1288 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1289 CHECK(!owner->result_ok);
1290         return DecodeError_clone(&*owner->contents.err);
1291 }
1292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1293         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1294         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1295         int64_t ret_ref = 0;
1296         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1297         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1299         ret_ref = (uintptr_t)ret_var.inner;
1300         if (ret_var.is_owned) {
1301                 ret_ref |= 1;
1302         }
1303         return ret_ref;
1304 }
1305
1306 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1307 CHECK(owner->result_ok);
1308         return HolderCommitmentTransaction_clone(&*owner->contents.result);
1309 }
1310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1311         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1312         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1313         int64_t ret_ref = 0;
1314         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1315         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1317         ret_ref = (uintptr_t)ret_var.inner;
1318         if (ret_var.is_owned) {
1319                 ret_ref |= 1;
1320         }
1321         return ret_ref;
1322 }
1323
1324 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1325 CHECK(!owner->result_ok);
1326         return DecodeError_clone(&*owner->contents.err);
1327 }
1328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1329         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1330         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1331         int64_t ret_ref = 0;
1332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1335         ret_ref = (uintptr_t)ret_var.inner;
1336         if (ret_var.is_owned) {
1337                 ret_ref |= 1;
1338         }
1339         return ret_ref;
1340 }
1341
1342 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1343 CHECK(owner->result_ok);
1344         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
1345 }
1346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1347         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1348         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1349         int64_t ret_ref = 0;
1350         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1351         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1353         ret_ref = (uintptr_t)ret_var.inner;
1354         if (ret_var.is_owned) {
1355                 ret_ref |= 1;
1356         }
1357         return ret_ref;
1358 }
1359
1360 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1361 CHECK(!owner->result_ok);
1362         return DecodeError_clone(&*owner->contents.err);
1363 }
1364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1365         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1366         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1367         int64_t ret_ref = 0;
1368         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1369         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1371         ret_ref = (uintptr_t)ret_var.inner;
1372         if (ret_var.is_owned) {
1373                 ret_ref |= 1;
1374         }
1375         return ret_ref;
1376 }
1377
1378 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1379 CHECK(owner->result_ok);
1380         return &*owner->contents.result;
1381 }
1382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1383         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1384         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1385         int64_t ret_ref = 0;
1386         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1387         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1389         ret_ref = (uintptr_t)ret_var.inner & ~1;
1390         return ret_ref;
1391 }
1392
1393 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1394 CHECK(!owner->result_ok);
1395         return *owner->contents.err;
1396 }
1397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1398         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1399         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1400 }
1401
1402 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1403 CHECK(owner->result_ok);
1404         return CommitmentTransaction_clone(&*owner->contents.result);
1405 }
1406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1407         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1408         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1409         int64_t ret_ref = 0;
1410         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1411         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1413         ret_ref = (uintptr_t)ret_var.inner;
1414         if (ret_var.is_owned) {
1415                 ret_ref |= 1;
1416         }
1417         return ret_ref;
1418 }
1419
1420 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1421 CHECK(!owner->result_ok);
1422         return DecodeError_clone(&*owner->contents.err);
1423 }
1424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1425         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1426         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1427         int64_t ret_ref = 0;
1428         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1429         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1431         ret_ref = (uintptr_t)ret_var.inner;
1432         if (ret_var.is_owned) {
1433                 ret_ref |= 1;
1434         }
1435         return ret_ref;
1436 }
1437
1438 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1439 CHECK(owner->result_ok);
1440         return &*owner->contents.result;
1441 }
1442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1443         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1444         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1445         int64_t ret_ref = 0;
1446         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1447         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1449         ret_ref = (uintptr_t)ret_var.inner & ~1;
1450         return ret_ref;
1451 }
1452
1453 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1454 CHECK(!owner->result_ok);
1455         return *owner->contents.err;
1456 }
1457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1458         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1459         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1460 }
1461
1462 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1463 CHECK(owner->result_ok);
1464         return *owner->contents.result;
1465 }
1466 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1467         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1468         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1469         jobjectArray ret_arr = NULL;
1470         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1471         ;
1472         for (size_t i = 0; i < ret_var.datalen; i++) {
1473                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1474                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1475                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1476         }
1477         
1478         return ret_arr;
1479 }
1480
1481 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1482 CHECK(!owner->result_ok);
1483         return *owner->contents.err;
1484 }
1485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1486         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1487         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1488 }
1489
1490 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1491 CHECK(owner->result_ok);
1492         return ShutdownScript_clone(&*owner->contents.result);
1493 }
1494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1495         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1496         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1497         int64_t ret_ref = 0;
1498         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1499         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1501         ret_ref = (uintptr_t)ret_var.inner;
1502         if (ret_var.is_owned) {
1503                 ret_ref |= 1;
1504         }
1505         return ret_ref;
1506 }
1507
1508 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1509 CHECK(!owner->result_ok);
1510         return DecodeError_clone(&*owner->contents.err);
1511 }
1512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1513         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1514         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1515         int64_t ret_ref = 0;
1516         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1517         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1519         ret_ref = (uintptr_t)ret_var.inner;
1520         if (ret_var.is_owned) {
1521                 ret_ref |= 1;
1522         }
1523         return ret_ref;
1524 }
1525
1526 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1527 CHECK(owner->result_ok);
1528         return ShutdownScript_clone(&*owner->contents.result);
1529 }
1530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1531         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1532         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1533         int64_t ret_ref = 0;
1534         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1535         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1537         ret_ref = (uintptr_t)ret_var.inner;
1538         if (ret_var.is_owned) {
1539                 ret_ref |= 1;
1540         }
1541         return ret_ref;
1542 }
1543
1544 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1545 CHECK(!owner->result_ok);
1546         return InvalidShutdownScript_clone(&*owner->contents.err);
1547 }
1548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1549         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1550         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1551         int64_t ret_ref = 0;
1552         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1553         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1555         ret_ref = (uintptr_t)ret_var.inner;
1556         if (ret_var.is_owned) {
1557                 ret_ref |= 1;
1558         }
1559         return ret_ref;
1560 }
1561
1562 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1563 CHECK(owner->result_ok);
1564         return *owner->contents.result;
1565 }
1566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1567         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1568         CResult_NoneErrorZ_get_ok(owner_conv);
1569 }
1570
1571 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1572 CHECK(!owner->result_ok);
1573         return *owner->contents.err;
1574 }
1575 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1576         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1577         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
1578         return ret_conv;
1579 }
1580
1581 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1582 CHECK(owner->result_ok);
1583         return RouteHop_clone(&*owner->contents.result);
1584 }
1585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1586         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1587         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
1588         int64_t ret_ref = 0;
1589         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1590         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1592         ret_ref = (uintptr_t)ret_var.inner;
1593         if (ret_var.is_owned) {
1594                 ret_ref |= 1;
1595         }
1596         return ret_ref;
1597 }
1598
1599 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1600 CHECK(!owner->result_ok);
1601         return DecodeError_clone(&*owner->contents.err);
1602 }
1603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1604         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1605         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1606         int64_t ret_ref = 0;
1607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1610         ret_ref = (uintptr_t)ret_var.inner;
1611         if (ret_var.is_owned) {
1612                 ret_ref |= 1;
1613         }
1614         return ret_ref;
1615 }
1616
1617 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1618         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1619         for (size_t i = 0; i < ret.datalen; i++) {
1620                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1621         }
1622         return ret;
1623 }
1624 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1625         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1626         for (size_t i = 0; i < ret.datalen; i++) {
1627                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1628         }
1629         return ret;
1630 }
1631 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1632 CHECK(owner->result_ok);
1633         return Route_clone(&*owner->contents.result);
1634 }
1635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1636         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1637         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1638         int64_t ret_ref = 0;
1639         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1640         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1642         ret_ref = (uintptr_t)ret_var.inner;
1643         if (ret_var.is_owned) {
1644                 ret_ref |= 1;
1645         }
1646         return ret_ref;
1647 }
1648
1649 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1650 CHECK(!owner->result_ok);
1651         return DecodeError_clone(&*owner->contents.err);
1652 }
1653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1654         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1655         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1656         int64_t ret_ref = 0;
1657         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1658         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1660         ret_ref = (uintptr_t)ret_var.inner;
1661         if (ret_var.is_owned) {
1662                 ret_ref |= 1;
1663         }
1664         return ret_ref;
1665 }
1666
1667 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1668 CHECK(owner->result_ok);
1669         return RouteParameters_clone(&*owner->contents.result);
1670 }
1671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1672         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1673         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1674         int64_t ret_ref = 0;
1675         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1676         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1678         ret_ref = (uintptr_t)ret_var.inner;
1679         if (ret_var.is_owned) {
1680                 ret_ref |= 1;
1681         }
1682         return ret_ref;
1683 }
1684
1685 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1686 CHECK(!owner->result_ok);
1687         return DecodeError_clone(&*owner->contents.err);
1688 }
1689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1690         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1691         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1692         int64_t ret_ref = 0;
1693         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1694         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1696         ret_ref = (uintptr_t)ret_var.inner;
1697         if (ret_var.is_owned) {
1698                 ret_ref |= 1;
1699         }
1700         return ret_ref;
1701 }
1702
1703 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1704         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1705         for (size_t i = 0; i < ret.datalen; i++) {
1706                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1707         }
1708         return ret;
1709 }
1710 static jclass LDKCOption_u64Z_Some_class = NULL;
1711 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1712 static jclass LDKCOption_u64Z_None_class = NULL;
1713 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1715         LDKCOption_u64Z_Some_class =
1716                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
1717         CHECK(LDKCOption_u64Z_Some_class != NULL);
1718         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1719         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1720         LDKCOption_u64Z_None_class =
1721                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
1722         CHECK(LDKCOption_u64Z_None_class != NULL);
1723         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1724         CHECK(LDKCOption_u64Z_None_meth != NULL);
1725 }
1726 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1727         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1728         switch(obj->tag) {
1729                 case LDKCOption_u64Z_Some: {
1730                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1731                 }
1732                 case LDKCOption_u64Z_None: {
1733                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1734                 }
1735                 default: abort();
1736         }
1737 }
1738 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1739 CHECK(owner->result_ok);
1740         return PaymentParameters_clone(&*owner->contents.result);
1741 }
1742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1743         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1744         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1745         int64_t ret_ref = 0;
1746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1749         ret_ref = (uintptr_t)ret_var.inner;
1750         if (ret_var.is_owned) {
1751                 ret_ref |= 1;
1752         }
1753         return ret_ref;
1754 }
1755
1756 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1757 CHECK(!owner->result_ok);
1758         return DecodeError_clone(&*owner->contents.err);
1759 }
1760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1761         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1762         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1763         int64_t ret_ref = 0;
1764         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1765         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1767         ret_ref = (uintptr_t)ret_var.inner;
1768         if (ret_var.is_owned) {
1769                 ret_ref |= 1;
1770         }
1771         return ret_ref;
1772 }
1773
1774 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1775         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1776         for (size_t i = 0; i < ret.datalen; i++) {
1777                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1778         }
1779         return ret;
1780 }
1781 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1782 CHECK(owner->result_ok);
1783         return RouteHint_clone(&*owner->contents.result);
1784 }
1785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1786         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1787         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1788         int64_t ret_ref = 0;
1789         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1790         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1792         ret_ref = (uintptr_t)ret_var.inner;
1793         if (ret_var.is_owned) {
1794                 ret_ref |= 1;
1795         }
1796         return ret_ref;
1797 }
1798
1799 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1800 CHECK(!owner->result_ok);
1801         return DecodeError_clone(&*owner->contents.err);
1802 }
1803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1804         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1805         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1806         int64_t ret_ref = 0;
1807         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1808         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1810         ret_ref = (uintptr_t)ret_var.inner;
1811         if (ret_var.is_owned) {
1812                 ret_ref |= 1;
1813         }
1814         return ret_ref;
1815 }
1816
1817 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1818 CHECK(owner->result_ok);
1819         return RouteHintHop_clone(&*owner->contents.result);
1820 }
1821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1822         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1823         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1824         int64_t ret_ref = 0;
1825         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1826         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1827         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1828         ret_ref = (uintptr_t)ret_var.inner;
1829         if (ret_var.is_owned) {
1830                 ret_ref |= 1;
1831         }
1832         return ret_ref;
1833 }
1834
1835 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1836 CHECK(!owner->result_ok);
1837         return DecodeError_clone(&*owner->contents.err);
1838 }
1839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1840         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1841         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1842         int64_t ret_ref = 0;
1843         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1844         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1846         ret_ref = (uintptr_t)ret_var.inner;
1847         if (ret_var.is_owned) {
1848                 ret_ref |= 1;
1849         }
1850         return ret_ref;
1851 }
1852
1853 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1854         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1855         for (size_t i = 0; i < ret.datalen; i++) {
1856                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1857         }
1858         return ret;
1859 }
1860 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1861 CHECK(owner->result_ok);
1862         return Route_clone(&*owner->contents.result);
1863 }
1864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1865         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1866         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1867         int64_t ret_ref = 0;
1868         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1869         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1871         ret_ref = (uintptr_t)ret_var.inner;
1872         if (ret_var.is_owned) {
1873                 ret_ref |= 1;
1874         }
1875         return ret_ref;
1876 }
1877
1878 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1879 CHECK(!owner->result_ok);
1880         return LightningError_clone(&*owner->contents.err);
1881 }
1882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1883         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1884         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1885         int64_t ret_ref = 0;
1886         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1887         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1889         ret_ref = (uintptr_t)ret_var.inner;
1890         if (ret_var.is_owned) {
1891                 ret_ref |= 1;
1892         }
1893         return ret_ref;
1894 }
1895
1896 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1897 CHECK(owner->result_ok);
1898         return TxOut_clone(&*owner->contents.result);
1899 }
1900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1901         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1902         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
1903         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
1904         return (int64_t)ret_ref;
1905 }
1906
1907 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1908 CHECK(!owner->result_ok);
1909         return AccessError_clone(&*owner->contents.err);
1910 }
1911 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1912         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1913         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
1914         return ret_conv;
1915 }
1916
1917 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1918         return owner->a;
1919 }
1920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
1921         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1922         int64_t ret_val = C2Tuple_usizeTransactionZ_get_a(owner_conv);
1923         return ret_val;
1924 }
1925
1926 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1927         return owner->b;
1928 }
1929 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
1930         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1931         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
1932         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1933         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1934         return ret_arr;
1935 }
1936
1937 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1938         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1939         for (size_t i = 0; i < ret.datalen; i++) {
1940                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1941         }
1942         return ret;
1943 }
1944 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
1945         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1946         for (size_t i = 0; i < ret.datalen; i++) {
1947                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1948         }
1949         return ret;
1950 }
1951 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1952 CHECK(owner->result_ok);
1953         return *owner->contents.result;
1954 }
1955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1956         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1957         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
1958 }
1959
1960 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1961 CHECK(!owner->result_ok);
1962         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
1963 }
1964 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1965         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1966         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
1967         return ret_conv;
1968 }
1969
1970 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1971 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1972 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
1973 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
1974 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
1975 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
1976 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
1977 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
1978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1979         LDKMonitorEvent_HTLCEvent_class =
1980                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
1981         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1982         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1983         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1984         LDKMonitorEvent_CommitmentTxConfirmed_class =
1985                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
1986         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
1987         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
1988         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
1989         LDKMonitorEvent_UpdateCompleted_class =
1990                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted"));
1991         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
1992         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
1993         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
1994         LDKMonitorEvent_UpdateFailed_class =
1995                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
1996         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
1997         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
1998         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
1999 }
2000 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2001         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2002         switch(obj->tag) {
2003                 case LDKMonitorEvent_HTLCEvent: {
2004                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
2005                         int64_t htlc_event_ref = 0;
2006                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2007                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2008                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
2009                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
2010                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
2011                 }
2012                 case LDKMonitorEvent_CommitmentTxConfirmed: {
2013                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
2014                         int64_t commitment_tx_confirmed_ref = 0;
2015                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2016                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2017                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
2018                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
2019                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
2020                 }
2021                 case LDKMonitorEvent_UpdateCompleted: {
2022                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
2023                         int64_t funding_txo_ref = 0;
2024                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2025                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2026                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
2027                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
2028                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, obj->update_completed.monitor_update_id);
2029                 }
2030                 case LDKMonitorEvent_UpdateFailed: {
2031                         LDKOutPoint update_failed_var = obj->update_failed;
2032                         int64_t update_failed_ref = 0;
2033                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2034                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2035                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
2036                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
2037                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
2038                 }
2039                 default: abort();
2040         }
2041 }
2042 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
2043         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
2044         for (size_t i = 0; i < ret.datalen; i++) {
2045                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
2046         }
2047         return ret;
2048 }
2049 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
2050 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
2051 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
2052 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
2053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
2054         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
2055                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some"));
2056         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
2057         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
2058         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
2059         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
2060                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None"));
2061         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
2062         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
2063         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
2064 }
2065 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2066         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2067         switch(obj->tag) {
2068                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
2069                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
2070                         *some_conv = obj->some;
2071                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
2072                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((int64_t)some_conv));
2073                 }
2074                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
2075                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
2076                 }
2077                 default: abort();
2078         }
2079 }
2080 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
2081 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
2082 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
2083 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
2084 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
2085 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
2086 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
2087 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
2088 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
2089 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
2090 static jclass LDKClosureReason_ProcessingError_class = NULL;
2091 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
2092 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
2093 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
2094 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
2095 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
2096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
2097         LDKClosureReason_CounterpartyForceClosed_class =
2098                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
2099         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
2100         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
2101         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
2102         LDKClosureReason_HolderForceClosed_class =
2103                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
2104         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
2105         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
2106         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
2107         LDKClosureReason_CooperativeClosure_class =
2108                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
2109         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
2110         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
2111         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
2112         LDKClosureReason_CommitmentTxConfirmed_class =
2113                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
2114         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
2115         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
2116         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
2117         LDKClosureReason_FundingTimedOut_class =
2118                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
2119         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
2120         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
2121         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
2122         LDKClosureReason_ProcessingError_class =
2123                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
2124         CHECK(LDKClosureReason_ProcessingError_class != NULL);
2125         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
2126         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
2127         LDKClosureReason_DisconnectedPeer_class =
2128                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
2129         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
2130         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
2131         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
2132         LDKClosureReason_OutdatedChannelManager_class =
2133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
2134         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
2135         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
2136         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
2137 }
2138 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2139         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
2140         switch(obj->tag) {
2141                 case LDKClosureReason_CounterpartyForceClosed: {
2142                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
2143                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
2144                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
2145                 }
2146                 case LDKClosureReason_HolderForceClosed: {
2147                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
2148                 }
2149                 case LDKClosureReason_CooperativeClosure: {
2150                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
2151                 }
2152                 case LDKClosureReason_CommitmentTxConfirmed: {
2153                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
2154                 }
2155                 case LDKClosureReason_FundingTimedOut: {
2156                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
2157                 }
2158                 case LDKClosureReason_ProcessingError: {
2159                         LDKStr err_str = obj->processing_error.err;
2160                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2161                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
2162                 }
2163                 case LDKClosureReason_DisconnectedPeer: {
2164                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
2165                 }
2166                 case LDKClosureReason_OutdatedChannelManager: {
2167                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
2168                 }
2169                 default: abort();
2170         }
2171 }
2172 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
2173 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
2174 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
2175 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
2176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
2177         LDKCOption_ClosureReasonZ_Some_class =
2178                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
2179         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
2180         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
2181         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
2182         LDKCOption_ClosureReasonZ_None_class =
2183                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
2184         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
2185         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
2186         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
2187 }
2188 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2189         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
2190         switch(obj->tag) {
2191                 case LDKCOption_ClosureReasonZ_Some: {
2192                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2193                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
2194                 }
2195                 case LDKCOption_ClosureReasonZ_None: {
2196                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
2197                 }
2198                 default: abort();
2199         }
2200 }
2201 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2202 CHECK(owner->result_ok);
2203         return COption_ClosureReasonZ_clone(&*owner->contents.result);
2204 }
2205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2206         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2207         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
2208         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
2209         int64_t ret_ref = (uintptr_t)ret_copy;
2210         return ret_ref;
2211 }
2212
2213 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2214 CHECK(!owner->result_ok);
2215         return DecodeError_clone(&*owner->contents.err);
2216 }
2217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2218         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2219         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
2220         int64_t ret_ref = 0;
2221         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2222         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2224         ret_ref = (uintptr_t)ret_var.inner;
2225         if (ret_var.is_owned) {
2226                 ret_ref |= 1;
2227         }
2228         return ret_ref;
2229 }
2230
2231 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2232 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2233 static jclass LDKNetworkUpdate_ChannelClosed_class = NULL;
2234 static jmethodID LDKNetworkUpdate_ChannelClosed_meth = NULL;
2235 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2236 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2238         LDKNetworkUpdate_ChannelUpdateMessage_class =
2239                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2240         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2241         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2242         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2243         LDKNetworkUpdate_ChannelClosed_class =
2244                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelClosed"));
2245         CHECK(LDKNetworkUpdate_ChannelClosed_class != NULL);
2246         LDKNetworkUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelClosed_class, "<init>", "(JZ)V");
2247         CHECK(LDKNetworkUpdate_ChannelClosed_meth != NULL);
2248         LDKNetworkUpdate_NodeFailure_class =
2249                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2250         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2251         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2252         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2253 }
2254 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2255         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
2256         switch(obj->tag) {
2257                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2258                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2259                         int64_t msg_ref = 0;
2260                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2261                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2262                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2263                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2264                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2265                 }
2266                 case LDKNetworkUpdate_ChannelClosed: {
2267                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelClosed_class, LDKNetworkUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
2268                 }
2269                 case LDKNetworkUpdate_NodeFailure: {
2270                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2271                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2272                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
2273                 }
2274                 default: abort();
2275         }
2276 }
2277 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2278 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2279 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2280 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2282         LDKCOption_NetworkUpdateZ_Some_class =
2283                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2284         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2285         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2286         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2287         LDKCOption_NetworkUpdateZ_None_class =
2288                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2289         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2290         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2291         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2292 }
2293 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2294         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
2295         switch(obj->tag) {
2296                 case LDKCOption_NetworkUpdateZ_Some: {
2297                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2298                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2299                 }
2300                 case LDKCOption_NetworkUpdateZ_None: {
2301                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2302                 }
2303                 default: abort();
2304         }
2305 }
2306 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2307 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2308 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2309 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2310 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2311 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2313         LDKSpendableOutputDescriptor_StaticOutput_class =
2314                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2315         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2316         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2317         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2318         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2319                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2320         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2321         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2322         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2323         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2324                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2325         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2326         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2327         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2328 }
2329 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2330         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
2331         switch(obj->tag) {
2332                 case LDKSpendableOutputDescriptor_StaticOutput: {
2333                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2334                         int64_t outpoint_ref = 0;
2335                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2336                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2337                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2338                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
2339                         int64_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
2340                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (int64_t)output_ref);
2341                 }
2342                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
2343                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
2344                         int64_t delayed_payment_output_ref = 0;
2345                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2346                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2347                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
2348                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
2349                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
2350                 }
2351                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
2352                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
2353                         int64_t static_payment_output_ref = 0;
2354                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2355                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2356                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
2357                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
2358                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
2359                 }
2360                 default: abort();
2361         }
2362 }
2363 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
2364         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
2365         for (size_t i = 0; i < ret.datalen; i++) {
2366                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
2367         }
2368         return ret;
2369 }
2370 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
2371 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
2372 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
2373 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
2374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
2375         LDKPaymentPurpose_InvoicePayment_class =
2376                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
2377         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
2378         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
2379         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
2380         LDKPaymentPurpose_SpontaneousPayment_class =
2381                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
2382         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
2383         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
2384         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
2385 }
2386 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2387         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
2388         switch(obj->tag) {
2389                 case LDKPaymentPurpose_InvoicePayment: {
2390                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2391                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
2392                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
2393                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
2394                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
2395                 }
2396                 case LDKPaymentPurpose_SpontaneousPayment: {
2397                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
2398                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
2399                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
2400                 }
2401                 default: abort();
2402         }
2403 }
2404 static jclass LDKEvent_FundingGenerationReady_class = NULL;
2405 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
2406 static jclass LDKEvent_PaymentReceived_class = NULL;
2407 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
2408 static jclass LDKEvent_PaymentSent_class = NULL;
2409 static jmethodID LDKEvent_PaymentSent_meth = NULL;
2410 static jclass LDKEvent_PaymentPathFailed_class = NULL;
2411 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
2412 static jclass LDKEvent_PaymentFailed_class = NULL;
2413 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
2414 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
2415 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
2416 static jclass LDKEvent_SpendableOutputs_class = NULL;
2417 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
2418 static jclass LDKEvent_PaymentForwarded_class = NULL;
2419 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
2420 static jclass LDKEvent_ChannelClosed_class = NULL;
2421 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
2422 static jclass LDKEvent_DiscardFunding_class = NULL;
2423 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
2424 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
2425 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
2426 static jclass LDKEvent_OpenChannelRequest_class = NULL;
2427 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
2428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
2429         LDKEvent_FundingGenerationReady_class =
2430                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
2431         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
2432         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
2433         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
2434         LDKEvent_PaymentReceived_class =
2435                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentReceived"));
2436         CHECK(LDKEvent_PaymentReceived_class != NULL);
2437         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
2438         CHECK(LDKEvent_PaymentReceived_meth != NULL);
2439         LDKEvent_PaymentSent_class =
2440                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
2441         CHECK(LDKEvent_PaymentSent_class != NULL);
2442         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
2443         CHECK(LDKEvent_PaymentSent_meth != NULL);
2444         LDKEvent_PaymentPathFailed_class =
2445                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
2446         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
2447         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
2448         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
2449         LDKEvent_PaymentFailed_class =
2450                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
2451         CHECK(LDKEvent_PaymentFailed_class != NULL);
2452         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
2453         CHECK(LDKEvent_PaymentFailed_meth != NULL);
2454         LDKEvent_PendingHTLCsForwardable_class =
2455                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
2456         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
2457         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
2458         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
2459         LDKEvent_SpendableOutputs_class =
2460                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
2461         CHECK(LDKEvent_SpendableOutputs_class != NULL);
2462         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
2463         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
2464         LDKEvent_PaymentForwarded_class =
2465                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
2466         CHECK(LDKEvent_PaymentForwarded_class != NULL);
2467         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "(JZ)V");
2468         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
2469         LDKEvent_ChannelClosed_class =
2470                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
2471         CHECK(LDKEvent_ChannelClosed_class != NULL);
2472         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
2473         CHECK(LDKEvent_ChannelClosed_meth != NULL);
2474         LDKEvent_DiscardFunding_class =
2475                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
2476         CHECK(LDKEvent_DiscardFunding_class != NULL);
2477         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
2478         CHECK(LDKEvent_DiscardFunding_meth != NULL);
2479         LDKEvent_PaymentPathSuccessful_class =
2480                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
2481         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
2482         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
2483         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
2484         LDKEvent_OpenChannelRequest_class =
2485                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
2486         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
2487         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
2488         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
2489 }
2490 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2491         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2492         switch(obj->tag) {
2493                 case LDKEvent_FundingGenerationReady: {
2494                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2495                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
2496                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
2497                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
2498                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
2499                         return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, obj->funding_generation_ready.channel_value_satoshis, output_script_arr, obj->funding_generation_ready.user_channel_id);
2500                 }
2501                 case LDKEvent_PaymentReceived: {
2502                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2503                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
2504                         int64_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
2505                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
2506                 }
2507                 case LDKEvent_PaymentSent: {
2508                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2509                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
2510                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2511                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
2512                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2513                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
2514                         int64_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
2515                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
2516                 }
2517                 case LDKEvent_PaymentPathFailed: {
2518                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2519                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
2520                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2521                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
2522                         int64_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
2523                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
2524                         int64_tArray path_arr = NULL;
2525                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2526                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2527                         for (size_t k = 0; k < path_var.datalen; k++) {
2528                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2529                                 int64_t path_conv_10_ref = 0;
2530                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2531                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2532                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2533                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2534                                 path_arr_ptr[k] = path_conv_10_ref;
2535                         }
2536                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2537                         int64_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
2538                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
2539                         int64_t retry_ref = 0;
2540                         if ((uintptr_t)retry_var.inner > 4096) {
2541                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2542                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2543                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
2544                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
2545                         }
2546                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, obj->payment_path_failed.rejected_by_dest, network_update_ref, obj->payment_path_failed.all_paths_failed, path_arr, short_channel_id_ref, retry_ref);
2547                 }
2548                 case LDKEvent_PaymentFailed: {
2549                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2550                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
2551                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2552                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
2553                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
2554                 }
2555                 case LDKEvent_PendingHTLCsForwardable: {
2556                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
2557                 }
2558                 case LDKEvent_SpendableOutputs: {
2559                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
2560                         int64_tArray outputs_arr = NULL;
2561                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
2562                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
2563                         for (size_t b = 0; b < outputs_var.datalen; b++) {
2564                                 int64_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
2565                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
2566                         }
2567                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
2568                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
2569                 }
2570                 case LDKEvent_PaymentForwarded: {
2571                         int64_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
2572                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, obj->payment_forwarded.claim_from_onchain_tx);
2573                 }
2574                 case LDKEvent_ChannelClosed: {
2575                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2576                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
2577                         int64_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
2578                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, obj->channel_closed.user_channel_id, reason_ref);
2579                 }
2580                 case LDKEvent_DiscardFunding: {
2581                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2582                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
2583                         LDKTransaction transaction_var = obj->discard_funding.transaction;
2584                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
2585                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
2586                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
2587                 }
2588                 case LDKEvent_PaymentPathSuccessful: {
2589                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2590                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
2591                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2592                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
2593                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
2594                         int64_tArray path_arr = NULL;
2595                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2596                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2597                         for (size_t k = 0; k < path_var.datalen; k++) {
2598                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2599                                 int64_t path_conv_10_ref = 0;
2600                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2601                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2602                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2603                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2604                                 path_arr_ptr[k] = path_conv_10_ref;
2605                         }
2606                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2607                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2608                 }
2609                 case LDKEvent_OpenChannelRequest: {
2610                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2611                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
2612                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2613                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
2614                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
2615                         int64_t channel_type_ref = 0;
2616                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2617                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2618                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
2619                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
2620                         return (*env)->NewObject(env, LDKEvent_OpenChannelRequest_class, LDKEvent_OpenChannelRequest_meth, temporary_channel_id_arr, counterparty_node_id_arr, obj->open_channel_request.funding_satoshis, obj->open_channel_request.push_msat, channel_type_ref);
2621                 }
2622                 default: abort();
2623         }
2624 }
2625 static jclass LDKCOption_EventZ_Some_class = NULL;
2626 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
2627 static jclass LDKCOption_EventZ_None_class = NULL;
2628 static jmethodID LDKCOption_EventZ_None_meth = NULL;
2629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
2630         LDKCOption_EventZ_Some_class =
2631                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
2632         CHECK(LDKCOption_EventZ_Some_class != NULL);
2633         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
2634         CHECK(LDKCOption_EventZ_Some_meth != NULL);
2635         LDKCOption_EventZ_None_class =
2636                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
2637         CHECK(LDKCOption_EventZ_None_class != NULL);
2638         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
2639         CHECK(LDKCOption_EventZ_None_meth != NULL);
2640 }
2641 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2642         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2643         switch(obj->tag) {
2644                 case LDKCOption_EventZ_Some: {
2645                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2646                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
2647                 }
2648                 case LDKCOption_EventZ_None: {
2649                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
2650                 }
2651                 default: abort();
2652         }
2653 }
2654 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2655 CHECK(owner->result_ok);
2656         return COption_EventZ_clone(&*owner->contents.result);
2657 }
2658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2659         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2660         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
2661         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
2662         int64_t ret_ref = (uintptr_t)ret_copy;
2663         return ret_ref;
2664 }
2665
2666 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2667 CHECK(!owner->result_ok);
2668         return DecodeError_clone(&*owner->contents.err);
2669 }
2670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2671         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2672         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
2673         int64_t ret_ref = 0;
2674         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2675         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2677         ret_ref = (uintptr_t)ret_var.inner;
2678         if (ret_var.is_owned) {
2679                 ret_ref |= 1;
2680         }
2681         return ret_ref;
2682 }
2683
2684 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
2685 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
2686 static jclass LDKErrorAction_IgnoreError_class = NULL;
2687 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
2688 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
2689 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
2690 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
2691 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
2692 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
2693 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
2694 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
2695 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
2696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
2697         LDKErrorAction_DisconnectPeer_class =
2698                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
2699         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2700         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2701         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2702         LDKErrorAction_IgnoreError_class =
2703                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
2704         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2705         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2706         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2707         LDKErrorAction_IgnoreAndLog_class =
2708                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
2709         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
2710         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
2711         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
2712         LDKErrorAction_IgnoreDuplicateGossip_class =
2713                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
2714         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
2715         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
2716         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
2717         LDKErrorAction_SendErrorMessage_class =
2718                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
2719         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2720         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2721         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2722         LDKErrorAction_SendWarningMessage_class =
2723                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
2724         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
2725         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
2726         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
2727 }
2728 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2729         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2730         switch(obj->tag) {
2731                 case LDKErrorAction_DisconnectPeer: {
2732                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2733                         int64_t msg_ref = 0;
2734                         if ((uintptr_t)msg_var.inner > 4096) {
2735                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2736                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2737                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2738                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
2739                         }
2740                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2741                 }
2742                 case LDKErrorAction_IgnoreError: {
2743                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2744                 }
2745                 case LDKErrorAction_IgnoreAndLog: {
2746                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
2747                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
2748                 }
2749                 case LDKErrorAction_IgnoreDuplicateGossip: {
2750                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
2751                 }
2752                 case LDKErrorAction_SendErrorMessage: {
2753                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2754                         int64_t msg_ref = 0;
2755                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2756                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2757                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2758                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2759                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2760                 }
2761                 case LDKErrorAction_SendWarningMessage: {
2762                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2763                         int64_t msg_ref = 0;
2764                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2765                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2766                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2767                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2768                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
2769                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
2770                 }
2771                 default: abort();
2772         }
2773 }
2774 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2775 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2776 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2777 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2778 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2779 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2780 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2781 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2782 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
2783 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
2784 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2785 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2786 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2787 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2788 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2789 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2790 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2791 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2792 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2793 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2794 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2795 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2796 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2797 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2798 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2799 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2800 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2801 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2802 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
2803 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
2804 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2805 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2806 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2807 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2808 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2809 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2810 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2811 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2812 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
2813 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
2814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2815         LDKMessageSendEvent_SendAcceptChannel_class =
2816                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
2817         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2818         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2819         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2820         LDKMessageSendEvent_SendOpenChannel_class =
2821                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
2822         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2823         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2824         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2825         LDKMessageSendEvent_SendFundingCreated_class =
2826                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
2827         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2828         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2829         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2830         LDKMessageSendEvent_SendFundingSigned_class =
2831                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
2832         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2833         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2834         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2835         LDKMessageSendEvent_SendFundingLocked_class =
2836                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked"));
2837         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
2838         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
2839         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
2840         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2841                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
2842         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2843         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2844         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2845         LDKMessageSendEvent_UpdateHTLCs_class =
2846                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
2847         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2848         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2849         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2850         LDKMessageSendEvent_SendRevokeAndACK_class =
2851                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
2852         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2853         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2854         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2855         LDKMessageSendEvent_SendClosingSigned_class =
2856                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
2857         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2858         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2859         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2860         LDKMessageSendEvent_SendShutdown_class =
2861                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
2862         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2863         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2864         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2865         LDKMessageSendEvent_SendChannelReestablish_class =
2866                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
2867         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2868         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2869         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2870         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2871                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
2872         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2873         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2874         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2875         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2876                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
2877         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2878         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2879         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2880         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2881                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
2882         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2883         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2884         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2885         LDKMessageSendEvent_SendChannelUpdate_class =
2886                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
2887         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
2888         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
2889         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
2890         LDKMessageSendEvent_HandleError_class =
2891                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
2892         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2893         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2894         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2895         LDKMessageSendEvent_SendChannelRangeQuery_class =
2896                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
2897         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2898         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2899         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2900         LDKMessageSendEvent_SendShortIdsQuery_class =
2901                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
2902         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2903         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2904         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2905         LDKMessageSendEvent_SendReplyChannelRange_class =
2906                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
2907         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2908         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2909         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2910         LDKMessageSendEvent_SendGossipTimestampFilter_class =
2911                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
2912         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
2913         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
2914         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
2915 }
2916 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2917         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2918         switch(obj->tag) {
2919                 case LDKMessageSendEvent_SendAcceptChannel: {
2920                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2921                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2922                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2923                         int64_t msg_ref = 0;
2924                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2925                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2926                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2927                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2928                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
2929                 }
2930                 case LDKMessageSendEvent_SendOpenChannel: {
2931                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2932                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
2933                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2934                         int64_t msg_ref = 0;
2935                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2936                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2937                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2938                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2939                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
2940                 }
2941                 case LDKMessageSendEvent_SendFundingCreated: {
2942                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2943                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
2944                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2945                         int64_t msg_ref = 0;
2946                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2947                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2948                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2949                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2950                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
2951                 }
2952                 case LDKMessageSendEvent_SendFundingSigned: {
2953                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2954                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
2955                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2956                         int64_t msg_ref = 0;
2957                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2958                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2959                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2960                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2961                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
2962                 }
2963                 case LDKMessageSendEvent_SendFundingLocked: {
2964                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2965                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
2966                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2967                         int64_t msg_ref = 0;
2968                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2969                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2970                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2971                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2972                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
2973                 }
2974                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
2975                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2976                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
2977                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2978                         int64_t msg_ref = 0;
2979                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2980                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2981                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2982                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2983                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
2984                 }
2985                 case LDKMessageSendEvent_UpdateHTLCs: {
2986                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2987                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
2988                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2989                         int64_t updates_ref = 0;
2990                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2991                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2992                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2993                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2994                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
2995                 }
2996                 case LDKMessageSendEvent_SendRevokeAndACK: {
2997                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2998                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
2999                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.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_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
3006                 }
3007                 case LDKMessageSendEvent_SendClosingSigned: {
3008                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3009                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
3010                         LDKClosingSigned msg_var = obj->send_closing_signed.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_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
3017                 }
3018                 case LDKMessageSendEvent_SendShutdown: {
3019                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3020                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
3021                         LDKShutdown msg_var = obj->send_shutdown.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_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
3028                 }
3029                 case LDKMessageSendEvent_SendChannelReestablish: {
3030                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3031                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
3032                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
3033                         int64_t msg_ref = 0;
3034                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3035                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3036                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3037                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3038                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
3039                 }
3040                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
3041                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
3042                         int64_t msg_ref = 0;
3043                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3044                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3045                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3046                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3047                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
3048                         int64_t update_msg_ref = 0;
3049                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3050                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3051                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3052                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
3053                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
3054                 }
3055                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
3056                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
3057                         int64_t msg_ref = 0;
3058                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3059                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3060                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3061                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3062                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
3063                 }
3064                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
3065                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
3066                         int64_t msg_ref = 0;
3067                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3068                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3069                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3070                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3071                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
3072                 }
3073                 case LDKMessageSendEvent_SendChannelUpdate: {
3074                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3075                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
3076                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
3077                         int64_t msg_ref = 0;
3078                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3079                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3080                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3081                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3082                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
3083                 }
3084                 case LDKMessageSendEvent_HandleError: {
3085                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3086                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
3087                         int64_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
3088                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
3089                 }
3090                 case LDKMessageSendEvent_SendChannelRangeQuery: {
3091                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3092                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
3093                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
3094                         int64_t msg_ref = 0;
3095                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3096                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3097                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3098                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3099                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
3100                 }
3101                 case LDKMessageSendEvent_SendShortIdsQuery: {
3102                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3103                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
3104                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
3105                         int64_t msg_ref = 0;
3106                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3107                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3108                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3109                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3110                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
3111                 }
3112                 case LDKMessageSendEvent_SendReplyChannelRange: {
3113                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3114                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
3115                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3116                         int64_t msg_ref = 0;
3117                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3118                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3119                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3120                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3121                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
3122                 }
3123                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
3124                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3125                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
3126                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
3127                         int64_t msg_ref = 0;
3128                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3129                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3130                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3131                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3132                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
3133                 }
3134                 default: abort();
3135         }
3136 }
3137 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3138         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3139         for (size_t i = 0; i < ret.datalen; i++) {
3140                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3141         }
3142         return ret;
3143 }
3144 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3145 CHECK(owner->result_ok);
3146         return FixedPenaltyScorer_clone(&*owner->contents.result);
3147 }
3148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3149         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3150         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3151         int64_t ret_ref = 0;
3152         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3153         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3155         ret_ref = (uintptr_t)ret_var.inner;
3156         if (ret_var.is_owned) {
3157                 ret_ref |= 1;
3158         }
3159         return ret_ref;
3160 }
3161
3162 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3163 CHECK(!owner->result_ok);
3164         return DecodeError_clone(&*owner->contents.err);
3165 }
3166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3167         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3168         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3169         int64_t ret_ref = 0;
3170         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3171         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3173         ret_ref = (uintptr_t)ret_var.inner;
3174         if (ret_var.is_owned) {
3175                 ret_ref |= 1;
3176         }
3177         return ret_ref;
3178 }
3179
3180 static inline struct LDKScoringParameters CResult_ScoringParametersDecodeErrorZ_get_ok(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
3181 CHECK(owner->result_ok);
3182         return ScoringParameters_clone(&*owner->contents.result);
3183 }
3184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3185         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
3186         LDKScoringParameters ret_var = CResult_ScoringParametersDecodeErrorZ_get_ok(owner_conv);
3187         int64_t ret_ref = 0;
3188         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3189         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3191         ret_ref = (uintptr_t)ret_var.inner;
3192         if (ret_var.is_owned) {
3193                 ret_ref |= 1;
3194         }
3195         return ret_ref;
3196 }
3197
3198 static inline struct LDKDecodeError CResult_ScoringParametersDecodeErrorZ_get_err(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
3199 CHECK(!owner->result_ok);
3200         return DecodeError_clone(&*owner->contents.err);
3201 }
3202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3203         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
3204         LDKDecodeError ret_var = CResult_ScoringParametersDecodeErrorZ_get_err(owner_conv);
3205         int64_t ret_ref = 0;
3206         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3207         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3209         ret_ref = (uintptr_t)ret_var.inner;
3210         if (ret_var.is_owned) {
3211                 ret_ref |= 1;
3212         }
3213         return ret_ref;
3214 }
3215
3216 static inline struct LDKScorer *CResult_ScorerDecodeErrorZ_get_ok(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
3217 CHECK(owner->result_ok);
3218         return &*owner->contents.result;
3219 }
3220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3221         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
3222         LDKScorer ret_var = *CResult_ScorerDecodeErrorZ_get_ok(owner_conv);
3223         int64_t ret_ref = 0;
3224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3227         ret_ref = (uintptr_t)ret_var.inner & ~1;
3228         return ret_ref;
3229 }
3230
3231 static inline struct LDKDecodeError CResult_ScorerDecodeErrorZ_get_err(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
3232 CHECK(!owner->result_ok);
3233         return DecodeError_clone(&*owner->contents.err);
3234 }
3235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3236         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
3237         LDKDecodeError ret_var = CResult_ScorerDecodeErrorZ_get_err(owner_conv);
3238         int64_t ret_ref = 0;
3239         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3240         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3242         ret_ref = (uintptr_t)ret_var.inner;
3243         if (ret_var.is_owned) {
3244                 ret_ref |= 1;
3245         }
3246         return ret_ref;
3247 }
3248
3249 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3250 CHECK(owner->result_ok);
3251         return &*owner->contents.result;
3252 }
3253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3254         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3255         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
3256         int64_t ret_ref = 0;
3257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3260         ret_ref = (uintptr_t)ret_var.inner & ~1;
3261         return ret_ref;
3262 }
3263
3264 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3265 CHECK(!owner->result_ok);
3266         return DecodeError_clone(&*owner->contents.err);
3267 }
3268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3269         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3270         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
3271         int64_t ret_ref = 0;
3272         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3273         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3275         ret_ref = (uintptr_t)ret_var.inner;
3276         if (ret_var.is_owned) {
3277                 ret_ref |= 1;
3278         }
3279         return ret_ref;
3280 }
3281
3282 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3283 CHECK(owner->result_ok);
3284         return InitFeatures_clone(&*owner->contents.result);
3285 }
3286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3287         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3288         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
3289         int64_t ret_ref = 0;
3290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3293         ret_ref = (uintptr_t)ret_var.inner;
3294         if (ret_var.is_owned) {
3295                 ret_ref |= 1;
3296         }
3297         return ret_ref;
3298 }
3299
3300 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3301 CHECK(!owner->result_ok);
3302         return DecodeError_clone(&*owner->contents.err);
3303 }
3304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3305         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3306         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
3307         int64_t ret_ref = 0;
3308         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3309         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3311         ret_ref = (uintptr_t)ret_var.inner;
3312         if (ret_var.is_owned) {
3313                 ret_ref |= 1;
3314         }
3315         return ret_ref;
3316 }
3317
3318 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3319 CHECK(owner->result_ok);
3320         return ChannelFeatures_clone(&*owner->contents.result);
3321 }
3322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3323         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3324         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
3325         int64_t ret_ref = 0;
3326         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3327         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3329         ret_ref = (uintptr_t)ret_var.inner;
3330         if (ret_var.is_owned) {
3331                 ret_ref |= 1;
3332         }
3333         return ret_ref;
3334 }
3335
3336 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3337 CHECK(!owner->result_ok);
3338         return DecodeError_clone(&*owner->contents.err);
3339 }
3340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3341         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3342         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
3343         int64_t ret_ref = 0;
3344         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3345         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3347         ret_ref = (uintptr_t)ret_var.inner;
3348         if (ret_var.is_owned) {
3349                 ret_ref |= 1;
3350         }
3351         return ret_ref;
3352 }
3353
3354 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3355 CHECK(owner->result_ok);
3356         return NodeFeatures_clone(&*owner->contents.result);
3357 }
3358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3359         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3360         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
3361         int64_t ret_ref = 0;
3362         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3363         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3365         ret_ref = (uintptr_t)ret_var.inner;
3366         if (ret_var.is_owned) {
3367                 ret_ref |= 1;
3368         }
3369         return ret_ref;
3370 }
3371
3372 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3373 CHECK(!owner->result_ok);
3374         return DecodeError_clone(&*owner->contents.err);
3375 }
3376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3377         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3378         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3379         int64_t ret_ref = 0;
3380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3383         ret_ref = (uintptr_t)ret_var.inner;
3384         if (ret_var.is_owned) {
3385                 ret_ref |= 1;
3386         }
3387         return ret_ref;
3388 }
3389
3390 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3391 CHECK(owner->result_ok);
3392         return InvoiceFeatures_clone(&*owner->contents.result);
3393 }
3394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3395         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3396         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3397         int64_t ret_ref = 0;
3398         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3399         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3401         ret_ref = (uintptr_t)ret_var.inner;
3402         if (ret_var.is_owned) {
3403                 ret_ref |= 1;
3404         }
3405         return ret_ref;
3406 }
3407
3408 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3409 CHECK(!owner->result_ok);
3410         return DecodeError_clone(&*owner->contents.err);
3411 }
3412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3413         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3414         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3415         int64_t ret_ref = 0;
3416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3419         ret_ref = (uintptr_t)ret_var.inner;
3420         if (ret_var.is_owned) {
3421                 ret_ref |= 1;
3422         }
3423         return ret_ref;
3424 }
3425
3426 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3427 CHECK(owner->result_ok);
3428         return ChannelTypeFeatures_clone(&*owner->contents.result);
3429 }
3430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3431         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3432         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3433         int64_t ret_ref = 0;
3434         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3435         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3437         ret_ref = (uintptr_t)ret_var.inner;
3438         if (ret_var.is_owned) {
3439                 ret_ref |= 1;
3440         }
3441         return ret_ref;
3442 }
3443
3444 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3445 CHECK(!owner->result_ok);
3446         return DecodeError_clone(&*owner->contents.err);
3447 }
3448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3449         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3450         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3451         int64_t ret_ref = 0;
3452         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3453         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3455         ret_ref = (uintptr_t)ret_var.inner;
3456         if (ret_var.is_owned) {
3457                 ret_ref |= 1;
3458         }
3459         return ret_ref;
3460 }
3461
3462 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3463 CHECK(owner->result_ok);
3464         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
3465 }
3466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3467         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3468         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3469         int64_t ret_ref = 0;
3470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3473         ret_ref = (uintptr_t)ret_var.inner;
3474         if (ret_var.is_owned) {
3475                 ret_ref |= 1;
3476         }
3477         return ret_ref;
3478 }
3479
3480 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3481 CHECK(!owner->result_ok);
3482         return DecodeError_clone(&*owner->contents.err);
3483 }
3484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3485         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3486         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3487         int64_t ret_ref = 0;
3488         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3489         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3491         ret_ref = (uintptr_t)ret_var.inner;
3492         if (ret_var.is_owned) {
3493                 ret_ref |= 1;
3494         }
3495         return ret_ref;
3496 }
3497
3498 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3499 CHECK(owner->result_ok);
3500         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
3501 }
3502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3503         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3504         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3505         int64_t ret_ref = 0;
3506         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3507         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3509         ret_ref = (uintptr_t)ret_var.inner;
3510         if (ret_var.is_owned) {
3511                 ret_ref |= 1;
3512         }
3513         return ret_ref;
3514 }
3515
3516 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3517 CHECK(!owner->result_ok);
3518         return DecodeError_clone(&*owner->contents.err);
3519 }
3520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3521         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3522         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3523         int64_t ret_ref = 0;
3524         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3525         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3527         ret_ref = (uintptr_t)ret_var.inner;
3528         if (ret_var.is_owned) {
3529                 ret_ref |= 1;
3530         }
3531         return ret_ref;
3532 }
3533
3534 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3535 CHECK(owner->result_ok);
3536         return SpendableOutputDescriptor_clone(&*owner->contents.result);
3537 }
3538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3539         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3540         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
3541         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3542         int64_t ret_ref = (uintptr_t)ret_copy;
3543         return ret_ref;
3544 }
3545
3546 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3547 CHECK(!owner->result_ok);
3548         return DecodeError_clone(&*owner->contents.err);
3549 }
3550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3551         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3552         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3553         int64_t ret_ref = 0;
3554         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3555         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3557         ret_ref = (uintptr_t)ret_var.inner;
3558         if (ret_var.is_owned) {
3559                 ret_ref |= 1;
3560         }
3561         return ret_ref;
3562 }
3563
3564 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
3565         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
3566         for (size_t i = 0; i < ret.datalen; i++) {
3567                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3568         }
3569         return ret;
3570 }
3571 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3572         return owner->a;
3573 }
3574 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3575         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3576         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3577         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
3578         return ret_arr;
3579 }
3580
3581 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3582         return owner->b;
3583 }
3584 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3585         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3586         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
3587         jobjectArray ret_arr = NULL;
3588         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
3589         ;
3590         for (size_t i = 0; i < ret_var.datalen; i++) {
3591                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
3592                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
3593                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
3594         }
3595         
3596         return ret_arr;
3597 }
3598
3599 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3600 CHECK(owner->result_ok);
3601         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
3602 }
3603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3604         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3605         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
3606         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
3607         return ((int64_t)ret_conv);
3608 }
3609
3610 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3611 CHECK(!owner->result_ok);
3612         return *owner->contents.err;
3613 }
3614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3615         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3616         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
3617 }
3618
3619 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3620 CHECK(owner->result_ok);
3621         return *owner->contents.result;
3622 }
3623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3624         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3625         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3626         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
3627         return ret_arr;
3628 }
3629
3630 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3631 CHECK(!owner->result_ok);
3632         return *owner->contents.err;
3633 }
3634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3635         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3636         CResult_SignatureNoneZ_get_err(owner_conv);
3637 }
3638
3639 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3640         return owner->a;
3641 }
3642 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3643         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3644         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3645         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
3646         return ret_arr;
3647 }
3648
3649 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3650         return owner->b;
3651 }
3652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3653         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3654         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3655         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
3656         return ret_arr;
3657 }
3658
3659 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3660 CHECK(owner->result_ok);
3661         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
3662 }
3663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3664         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3665         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
3666         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
3667         return ((int64_t)ret_conv);
3668 }
3669
3670 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3671 CHECK(!owner->result_ok);
3672         return *owner->contents.err;
3673 }
3674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3675         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3676         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
3677 }
3678
3679 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3680 CHECK(owner->result_ok);
3681         return *owner->contents.result;
3682 }
3683 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3684         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3685         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3686         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
3687         return ret_arr;
3688 }
3689
3690 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3691 CHECK(!owner->result_ok);
3692         return *owner->contents.err;
3693 }
3694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3695         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3696         CResult_SecretKeyNoneZ_get_err(owner_conv);
3697 }
3698
3699 typedef struct LDKBaseSign_JCalls {
3700         atomic_size_t refcnt;
3701         JavaVM *vm;
3702         jweak o;
3703         jmethodID get_per_commitment_point_meth;
3704         jmethodID release_commitment_secret_meth;
3705         jmethodID validate_holder_commitment_meth;
3706         jmethodID channel_keys_id_meth;
3707         jmethodID sign_counterparty_commitment_meth;
3708         jmethodID validate_counterparty_revocation_meth;
3709         jmethodID sign_holder_commitment_and_htlcs_meth;
3710         jmethodID sign_justice_revoked_output_meth;
3711         jmethodID sign_justice_revoked_htlc_meth;
3712         jmethodID sign_counterparty_htlc_transaction_meth;
3713         jmethodID sign_closing_transaction_meth;
3714         jmethodID sign_channel_announcement_meth;
3715         jmethodID ready_channel_meth;
3716 } LDKBaseSign_JCalls;
3717 static void LDKBaseSign_JCalls_free(void* this_arg) {
3718         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3719         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3720                 JNIEnv *env;
3721                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3722                 if (get_jenv_res == JNI_EDETACHED) {
3723                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3724                 } else {
3725                         DO_ASSERT(get_jenv_res == JNI_OK);
3726                 }
3727                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3728                 if (get_jenv_res == JNI_EDETACHED) {
3729                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3730                 }
3731                 FREE(j_calls);
3732         }
3733 }
3734 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3735         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3736         JNIEnv *env;
3737         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3738         if (get_jenv_res == JNI_EDETACHED) {
3739                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3740         } else {
3741                 DO_ASSERT(get_jenv_res == JNI_OK);
3742         }
3743         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3744         CHECK(obj != NULL);
3745         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
3746         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3747                 (*env)->ExceptionDescribe(env);
3748                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
3749         }
3750         LDKPublicKey ret_ref;
3751         CHECK((*env)->GetArrayLength(env, ret) == 33);
3752         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3753         if (get_jenv_res == JNI_EDETACHED) {
3754                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3755         }
3756         return ret_ref;
3757 }
3758 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3759         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3760         JNIEnv *env;
3761         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3762         if (get_jenv_res == JNI_EDETACHED) {
3763                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3764         } else {
3765                 DO_ASSERT(get_jenv_res == JNI_OK);
3766         }
3767         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3768         CHECK(obj != NULL);
3769         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
3770         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3771                 (*env)->ExceptionDescribe(env);
3772                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
3773         }
3774         LDKThirtyTwoBytes ret_ref;
3775         CHECK((*env)->GetArrayLength(env, ret) == 32);
3776         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3777         if (get_jenv_res == JNI_EDETACHED) {
3778                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3779         }
3780         return ret_ref;
3781 }
3782 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
3783         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3784         JNIEnv *env;
3785         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3786         if (get_jenv_res == JNI_EDETACHED) {
3787                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3788         } else {
3789                 DO_ASSERT(get_jenv_res == JNI_OK);
3790         }
3791         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
3792         int64_t holder_tx_ref = 0;
3793         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
3794         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3795         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3796         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
3797         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
3798         if (holder_tx_var.is_owned) {
3799                 holder_tx_ref |= 1;
3800         }
3801         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3802         jobjectArray preimages_arr = NULL;
3803         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
3804         ;
3805         for (size_t i = 0; i < preimages_var.datalen; i++) {
3806                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
3807                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
3808                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
3809         }
3810         
3811         FREE(preimages_var.data);
3812         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3813         CHECK(obj != NULL);
3814         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
3815         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3816                 (*env)->ExceptionDescribe(env);
3817                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
3818         }
3819         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3820         CHECK_ACCESS(ret_ptr);
3821         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3822         FREE((void*)ret);
3823         if (get_jenv_res == JNI_EDETACHED) {
3824                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3825         }
3826         return ret_conv;
3827 }
3828 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
3829         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3830         JNIEnv *env;
3831         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3832         if (get_jenv_res == JNI_EDETACHED) {
3833                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3834         } else {
3835                 DO_ASSERT(get_jenv_res == JNI_OK);
3836         }
3837         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3838         CHECK(obj != NULL);
3839         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
3840         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3841                 (*env)->ExceptionDescribe(env);
3842                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
3843         }
3844         LDKThirtyTwoBytes ret_ref;
3845         CHECK((*env)->GetArrayLength(env, ret) == 32);
3846         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3847         if (get_jenv_res == JNI_EDETACHED) {
3848                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3849         }
3850         return ret_ref;
3851 }
3852 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
3853         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3854         JNIEnv *env;
3855         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3856         if (get_jenv_res == JNI_EDETACHED) {
3857                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3858         } else {
3859                 DO_ASSERT(get_jenv_res == JNI_OK);
3860         }
3861         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
3862         int64_t commitment_tx_ref = 0;
3863         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
3864         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3865         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3866         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3867         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3868         if (commitment_tx_var.is_owned) {
3869                 commitment_tx_ref |= 1;
3870         }
3871         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3872         jobjectArray preimages_arr = NULL;
3873         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
3874         ;
3875         for (size_t i = 0; i < preimages_var.datalen; i++) {
3876                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
3877                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
3878                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
3879         }
3880         
3881         FREE(preimages_var.data);
3882         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3883         CHECK(obj != NULL);
3884         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
3885         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3886                 (*env)->ExceptionDescribe(env);
3887                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
3888         }
3889         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3890         CHECK_ACCESS(ret_ptr);
3891         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3892         FREE((void*)ret);
3893         if (get_jenv_res == JNI_EDETACHED) {
3894                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3895         }
3896         return ret_conv;
3897 }
3898 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
3899         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3900         JNIEnv *env;
3901         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3902         if (get_jenv_res == JNI_EDETACHED) {
3903                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3904         } else {
3905                 DO_ASSERT(get_jenv_res == JNI_OK);
3906         }
3907         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
3908         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
3909         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3910         CHECK(obj != NULL);
3911         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx, secret_arr);
3912         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3913                 (*env)->ExceptionDescribe(env);
3914                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
3915         }
3916         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3917         CHECK_ACCESS(ret_ptr);
3918         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3919         FREE((void*)ret);
3920         if (get_jenv_res == JNI_EDETACHED) {
3921                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3922         }
3923         return ret_conv;
3924 }
3925 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3926         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3927         JNIEnv *env;
3928         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3929         if (get_jenv_res == JNI_EDETACHED) {
3930                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3931         } else {
3932                 DO_ASSERT(get_jenv_res == JNI_OK);
3933         }
3934         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3935         int64_t commitment_tx_ref = 0;
3936         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
3937         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3938         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3939         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3940         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3941         if (commitment_tx_var.is_owned) {
3942                 commitment_tx_ref |= 1;
3943         }
3944         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3945         CHECK(obj != NULL);
3946         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
3947         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3948                 (*env)->ExceptionDescribe(env);
3949                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
3950         }
3951         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3952         CHECK_ACCESS(ret_ptr);
3953         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3954         FREE((void*)ret);
3955         if (get_jenv_res == JNI_EDETACHED) {
3956                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3957         }
3958         return ret_conv;
3959 }
3960 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]) {
3961         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3962         JNIEnv *env;
3963         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3964         if (get_jenv_res == JNI_EDETACHED) {
3965                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3966         } else {
3967                 DO_ASSERT(get_jenv_res == JNI_OK);
3968         }
3969         LDKTransaction justice_tx_var = justice_tx;
3970         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
3971         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
3972         Transaction_free(justice_tx_var);
3973         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
3974         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
3975         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3976         CHECK(obj != NULL);
3977         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
3978         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3979                 (*env)->ExceptionDescribe(env);
3980                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
3981         }
3982         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3983         CHECK_ACCESS(ret_ptr);
3984         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3985         FREE((void*)ret);
3986         if (get_jenv_res == JNI_EDETACHED) {
3987                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3988         }
3989         return ret_conv;
3990 }
3991 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) {
3992         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3993         JNIEnv *env;
3994         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3995         if (get_jenv_res == JNI_EDETACHED) {
3996                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3997         } else {
3998                 DO_ASSERT(get_jenv_res == JNI_OK);
3999         }
4000         LDKTransaction justice_tx_var = justice_tx;
4001         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
4002         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
4003         Transaction_free(justice_tx_var);
4004         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
4005         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
4006         LDKHTLCOutputInCommitment htlc_var = *htlc;
4007         int64_t htlc_ref = 0;
4008         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4009         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4010         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4011         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4012         htlc_ref = (uintptr_t)htlc_var.inner;
4013         if (htlc_var.is_owned) {
4014                 htlc_ref |= 1;
4015         }
4016         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4017         CHECK(obj != NULL);
4018         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
4019         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4020                 (*env)->ExceptionDescribe(env);
4021                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
4022         }
4023         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4024         CHECK_ACCESS(ret_ptr);
4025         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4026         FREE((void*)ret);
4027         if (get_jenv_res == JNI_EDETACHED) {
4028                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4029         }
4030         return ret_conv;
4031 }
4032 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) {
4033         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4034         JNIEnv *env;
4035         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4036         if (get_jenv_res == JNI_EDETACHED) {
4037                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4038         } else {
4039                 DO_ASSERT(get_jenv_res == JNI_OK);
4040         }
4041         LDKTransaction htlc_tx_var = htlc_tx;
4042         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
4043         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
4044         Transaction_free(htlc_tx_var);
4045         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
4046         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
4047         LDKHTLCOutputInCommitment htlc_var = *htlc;
4048         int64_t htlc_ref = 0;
4049         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4050         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4051         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4052         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4053         htlc_ref = (uintptr_t)htlc_var.inner;
4054         if (htlc_var.is_owned) {
4055                 htlc_ref |= 1;
4056         }
4057         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4058         CHECK(obj != NULL);
4059         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
4060         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4061                 (*env)->ExceptionDescribe(env);
4062                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
4063         }
4064         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4065         CHECK_ACCESS(ret_ptr);
4066         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4067         FREE((void*)ret);
4068         if (get_jenv_res == JNI_EDETACHED) {
4069                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4070         }
4071         return ret_conv;
4072 }
4073 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
4074         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4075         JNIEnv *env;
4076         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4077         if (get_jenv_res == JNI_EDETACHED) {
4078                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4079         } else {
4080                 DO_ASSERT(get_jenv_res == JNI_OK);
4081         }
4082         LDKClosingTransaction closing_tx_var = *closing_tx;
4083         int64_t closing_tx_ref = 0;
4084         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
4085         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4086         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4087         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
4088         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
4089         if (closing_tx_var.is_owned) {
4090                 closing_tx_ref |= 1;
4091         }
4092         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4093         CHECK(obj != NULL);
4094         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
4095         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4096                 (*env)->ExceptionDescribe(env);
4097                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
4098         }
4099         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4100         CHECK_ACCESS(ret_ptr);
4101         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4102         FREE((void*)ret);
4103         if (get_jenv_res == JNI_EDETACHED) {
4104                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4105         }
4106         return ret_conv;
4107 }
4108 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
4109         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4110         JNIEnv *env;
4111         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4112         if (get_jenv_res == JNI_EDETACHED) {
4113                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4114         } else {
4115                 DO_ASSERT(get_jenv_res == JNI_OK);
4116         }
4117         LDKUnsignedChannelAnnouncement msg_var = *msg;
4118         int64_t msg_ref = 0;
4119         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
4120         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4121         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4122         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4123         msg_ref = (uintptr_t)msg_var.inner;
4124         if (msg_var.is_owned) {
4125                 msg_ref |= 1;
4126         }
4127         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4128         CHECK(obj != NULL);
4129         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
4130         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4131                 (*env)->ExceptionDescribe(env);
4132                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
4133         }
4134         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4135         CHECK_ACCESS(ret_ptr);
4136         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
4137         FREE((void*)ret);
4138         if (get_jenv_res == JNI_EDETACHED) {
4139                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4140         }
4141         return ret_conv;
4142 }
4143 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
4144         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4145         JNIEnv *env;
4146         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4147         if (get_jenv_res == JNI_EDETACHED) {
4148                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4149         } else {
4150                 DO_ASSERT(get_jenv_res == JNI_OK);
4151         }
4152         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
4153         int64_t channel_parameters_ref = 0;
4154         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
4155         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4156         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4157         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
4158         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
4159         if (channel_parameters_var.is_owned) {
4160                 channel_parameters_ref |= 1;
4161         }
4162         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4163         CHECK(obj != NULL);
4164         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
4165         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4166                 (*env)->ExceptionDescribe(env);
4167                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
4168         }
4169         if (get_jenv_res == JNI_EDETACHED) {
4170                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4171         }
4172 }
4173 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
4174         jclass c = (*env)->GetObjectClass(env, o);
4175         CHECK(c != NULL);
4176         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
4177         atomic_init(&calls->refcnt, 1);
4178         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4179         calls->o = (*env)->NewWeakGlobalRef(env, o);
4180         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
4181         CHECK(calls->get_per_commitment_point_meth != NULL);
4182         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
4183         CHECK(calls->release_commitment_secret_meth != NULL);
4184         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
4185         CHECK(calls->validate_holder_commitment_meth != NULL);
4186         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
4187         CHECK(calls->channel_keys_id_meth != NULL);
4188         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
4189         CHECK(calls->sign_counterparty_commitment_meth != NULL);
4190         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
4191         CHECK(calls->validate_counterparty_revocation_meth != NULL);
4192         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
4193         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
4194         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
4195         CHECK(calls->sign_justice_revoked_output_meth != NULL);
4196         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
4197         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
4198         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
4199         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
4200         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
4201         CHECK(calls->sign_closing_transaction_meth != NULL);
4202         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
4203         CHECK(calls->sign_channel_announcement_meth != NULL);
4204         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
4205         CHECK(calls->ready_channel_meth != NULL);
4206
4207         LDKChannelPublicKeys pubkeys_conv;
4208         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4209         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4210         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4211
4212         LDKBaseSign ret = {
4213                 .this_arg = (void*) calls,
4214                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
4215                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
4216                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
4217                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
4218                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
4219                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
4220                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
4221                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
4222                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
4223                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
4224                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
4225                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
4226                 .ready_channel = ready_channel_LDKBaseSign_jcall,
4227                 .free = LDKBaseSign_JCalls_free,
4228                 .pubkeys = pubkeys_conv,
4229                 .set_pubkeys = NULL,
4230         };
4231         return ret;
4232 }
4233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
4234         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
4235         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
4236         return (uint64_t)res_ptr;
4237 }
4238 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) {
4239         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4240         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4241         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4242         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
4243         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
4244         return ret_arr;
4245 }
4246
4247 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
4248         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4249         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4250         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4251         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4252         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
4253         return ret_arr;
4254 }
4255
4256 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) {
4257         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4258         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4259         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4260         LDKHolderCommitmentTransaction holder_tx_conv;
4261         holder_tx_conv.inner = (void*)(holder_tx & (~1));
4262         holder_tx_conv.is_owned = false;
4263         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
4264         LDKCVec_PaymentPreimageZ preimages_constr;
4265         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
4266         if (preimages_constr.datalen > 0)
4267                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4268         else
4269                 preimages_constr.data = NULL;
4270         for (size_t i = 0; i < preimages_constr.datalen; i++) {
4271                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
4272                 LDKThirtyTwoBytes preimages_conv_8_ref;
4273                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
4274                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
4275                 preimages_constr.data[i] = preimages_conv_8_ref;
4276         }
4277         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4278         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
4279         return (int64_t)ret_conv;
4280 }
4281
4282 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
4283         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4284         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4285         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4286         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4287         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
4288         return ret_arr;
4289 }
4290
4291 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) {
4292         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4293         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4294         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4295         LDKCommitmentTransaction commitment_tx_conv;
4296         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4297         commitment_tx_conv.is_owned = false;
4298         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4299         LDKCVec_PaymentPreimageZ preimages_constr;
4300         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
4301         if (preimages_constr.datalen > 0)
4302                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4303         else
4304                 preimages_constr.data = NULL;
4305         for (size_t i = 0; i < preimages_constr.datalen; i++) {
4306                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
4307                 LDKThirtyTwoBytes preimages_conv_8_ref;
4308                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
4309                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
4310                 preimages_constr.data[i] = preimages_conv_8_ref;
4311         }
4312         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4313         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
4314         return (int64_t)ret_conv;
4315 }
4316
4317 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) {
4318         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4319         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4320         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4321         unsigned char secret_arr[32];
4322         CHECK((*env)->GetArrayLength(env, secret) == 32);
4323         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
4324         unsigned char (*secret_ref)[32] = &secret_arr;
4325         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4326         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
4327         return (int64_t)ret_conv;
4328 }
4329
4330 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) {
4331         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4332         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4333         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4334         LDKHolderCommitmentTransaction commitment_tx_conv;
4335         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4336         commitment_tx_conv.is_owned = false;
4337         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4338         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4339         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
4340         return (int64_t)ret_conv;
4341 }
4342
4343 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) {
4344         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4345         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4346         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4347         LDKTransaction justice_tx_ref;
4348         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
4349         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4350         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
4351         justice_tx_ref.data_is_owned = true;
4352         unsigned char per_commitment_key_arr[32];
4353         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
4354         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
4355         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4356         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4357         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
4358         return (int64_t)ret_conv;
4359 }
4360
4361 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) {
4362         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4363         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4364         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4365         LDKTransaction justice_tx_ref;
4366         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
4367         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4368         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
4369         justice_tx_ref.data_is_owned = true;
4370         unsigned char per_commitment_key_arr[32];
4371         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
4372         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
4373         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4374         LDKHTLCOutputInCommitment htlc_conv;
4375         htlc_conv.inner = (void*)(htlc & (~1));
4376         htlc_conv.is_owned = false;
4377         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4378         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4379         *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);
4380         return (int64_t)ret_conv;
4381 }
4382
4383 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) {
4384         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4385         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4386         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4387         LDKTransaction htlc_tx_ref;
4388         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
4389         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
4390         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
4391         htlc_tx_ref.data_is_owned = true;
4392         LDKPublicKey per_commitment_point_ref;
4393         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
4394         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
4395         LDKHTLCOutputInCommitment htlc_conv;
4396         htlc_conv.inner = (void*)(htlc & (~1));
4397         htlc_conv.is_owned = false;
4398         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4399         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4400         *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);
4401         return (int64_t)ret_conv;
4402 }
4403
4404 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) {
4405         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4406         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4407         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4408         LDKClosingTransaction closing_tx_conv;
4409         closing_tx_conv.inner = (void*)(closing_tx & (~1));
4410         closing_tx_conv.is_owned = false;
4411         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
4412         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4413         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
4414         return (int64_t)ret_conv;
4415 }
4416
4417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
4418         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4419         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4420         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4421         LDKUnsignedChannelAnnouncement msg_conv;
4422         msg_conv.inner = (void*)(msg & (~1));
4423         msg_conv.is_owned = false;
4424         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
4425         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
4426         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
4427         return (int64_t)ret_conv;
4428 }
4429
4430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
4431         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4432         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4433         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4434         LDKChannelTransactionParameters channel_parameters_conv;
4435         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
4436         channel_parameters_conv.is_owned = false;
4437         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
4438         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
4439 }
4440
4441 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
4442         if (this_arg->set_pubkeys != NULL)
4443                 this_arg->set_pubkeys(this_arg);
4444         return this_arg->pubkeys;
4445 }
4446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
4447         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4448         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4449         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4450         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
4451         int64_t ret_ref = 0;
4452         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4453         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4455         ret_ref = (uintptr_t)ret_var.inner;
4456         if (ret_var.is_owned) {
4457                 ret_ref |= 1;
4458         }
4459         return ret_ref;
4460 }
4461
4462 typedef struct LDKSign_JCalls {
4463         atomic_size_t refcnt;
4464         JavaVM *vm;
4465         jweak o;
4466         LDKBaseSign_JCalls* BaseSign;
4467         jmethodID write_meth;
4468 } LDKSign_JCalls;
4469 static void LDKSign_JCalls_free(void* this_arg) {
4470         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4471         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4472                 JNIEnv *env;
4473                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4474                 if (get_jenv_res == JNI_EDETACHED) {
4475                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4476                 } else {
4477                         DO_ASSERT(get_jenv_res == JNI_OK);
4478                 }
4479                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4480                 if (get_jenv_res == JNI_EDETACHED) {
4481                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4482                 }
4483                 FREE(j_calls);
4484         }
4485 }
4486 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
4487         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4488         JNIEnv *env;
4489         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4490         if (get_jenv_res == JNI_EDETACHED) {
4491                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4492         } else {
4493                 DO_ASSERT(get_jenv_res == JNI_OK);
4494         }
4495         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4496         CHECK(obj != NULL);
4497         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
4498         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4499                 (*env)->ExceptionDescribe(env);
4500                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
4501         }
4502         LDKCVec_u8Z ret_ref;
4503         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4504         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4505         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4506         if (get_jenv_res == JNI_EDETACHED) {
4507                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4508         }
4509         return ret_ref;
4510 }
4511 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
4512         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
4513         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4514         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
4515 }
4516 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
4517         jclass c = (*env)->GetObjectClass(env, o);
4518         CHECK(c != NULL);
4519         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
4520         atomic_init(&calls->refcnt, 1);
4521         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4522         calls->o = (*env)->NewWeakGlobalRef(env, o);
4523         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
4524         CHECK(calls->write_meth != NULL);
4525
4526         LDKChannelPublicKeys pubkeys_conv;
4527         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4528         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4529         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4530
4531         LDKSign ret = {
4532                 .this_arg = (void*) calls,
4533                 .write = write_LDKSign_jcall,
4534                 .cloned = LDKSign_JCalls_cloned,
4535                 .free = LDKSign_JCalls_free,
4536                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
4537         };
4538         calls->BaseSign = ret.BaseSign.this_arg;
4539         return ret;
4540 }
4541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
4542         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
4543         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
4544         return (uint64_t)res_ptr;
4545 }
4546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
4547         LDKSign *inp = (LDKSign *)(arg & ~1);
4548         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
4549         DO_ASSERT((res_ptr & 1) == 0);
4550         return (int64_t)(res_ptr | 1);
4551 }
4552 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
4553         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4554         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4555         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
4556         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4557         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4558         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4559         CVec_u8Z_free(ret_var);
4560         return ret_arr;
4561 }
4562
4563 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4564 CHECK(owner->result_ok);
4565         return Sign_clone(&*owner->contents.result);
4566 }
4567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4568         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4569         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4570         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
4571         return (int64_t)ret_ret;
4572 }
4573
4574 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4575 CHECK(!owner->result_ok);
4576         return DecodeError_clone(&*owner->contents.err);
4577 }
4578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4579         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4580         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
4581         int64_t ret_ref = 0;
4582         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4583         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4585         ret_ref = (uintptr_t)ret_var.inner;
4586         if (ret_var.is_owned) {
4587                 ret_ref |= 1;
4588         }
4589         return ret_ref;
4590 }
4591
4592 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4593 CHECK(owner->result_ok);
4594         return *owner->contents.result;
4595 }
4596 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4597         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4598         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
4599         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
4600         return ret_arr;
4601 }
4602
4603 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4604 CHECK(!owner->result_ok);
4605         return *owner->contents.err;
4606 }
4607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4608         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4609         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
4610 }
4611
4612 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
4613         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
4614         for (size_t i = 0; i < ret.datalen; i++) {
4615                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
4616         }
4617         return ret;
4618 }
4619 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4620 CHECK(owner->result_ok);
4621         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
4622 }
4623 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4624         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4625         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
4626         jobjectArray ret_arr = NULL;
4627         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
4628         ;
4629         for (size_t i = 0; i < ret_var.datalen; i++) {
4630                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
4631                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
4632                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
4633                 CVec_u8Z_free(ret_conv_8_var);
4634                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
4635         }
4636         
4637         FREE(ret_var.data);
4638         return ret_arr;
4639 }
4640
4641 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4642 CHECK(!owner->result_ok);
4643         return *owner->contents.err;
4644 }
4645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4646         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4647         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
4648 }
4649
4650 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4651 CHECK(owner->result_ok);
4652         return InMemorySigner_clone(&*owner->contents.result);
4653 }
4654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4655         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4656         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
4657         int64_t ret_ref = 0;
4658         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4659         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4661         ret_ref = (uintptr_t)ret_var.inner;
4662         if (ret_var.is_owned) {
4663                 ret_ref |= 1;
4664         }
4665         return ret_ref;
4666 }
4667
4668 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4669 CHECK(!owner->result_ok);
4670         return DecodeError_clone(&*owner->contents.err);
4671 }
4672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4673         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4674         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
4675         int64_t ret_ref = 0;
4676         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4677         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4679         ret_ref = (uintptr_t)ret_var.inner;
4680         if (ret_var.is_owned) {
4681                 ret_ref |= 1;
4682         }
4683         return ret_ref;
4684 }
4685
4686 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
4687         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
4688         for (size_t i = 0; i < ret.datalen; i++) {
4689                 ret.data[i] = TxOut_clone(&orig->data[i]);
4690         }
4691         return ret;
4692 }
4693 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4694 CHECK(owner->result_ok);
4695         return *owner->contents.result;
4696 }
4697 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4698         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4699         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
4700         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4701         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4702         return ret_arr;
4703 }
4704
4705 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4706 CHECK(!owner->result_ok);
4707         return *owner->contents.err;
4708 }
4709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4710         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4711         CResult_TransactionNoneZ_get_err(owner_conv);
4712 }
4713
4714 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
4715         return ThirtyTwoBytes_clone(&owner->a);
4716 }
4717 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4718         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
4719         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4720         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
4721         return ret_arr;
4722 }
4723
4724 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
4725         return ChannelMonitor_clone(&owner->b);
4726 }
4727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4728         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
4729         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
4730         int64_t ret_ref = 0;
4731         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4732         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4734         ret_ref = (uintptr_t)ret_var.inner;
4735         if (ret_var.is_owned) {
4736                 ret_ref |= 1;
4737         }
4738         return ret_ref;
4739 }
4740
4741 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
4742         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
4743         for (size_t i = 0; i < ret.datalen; i++) {
4744                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
4745         }
4746         return ret;
4747 }
4748 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
4749 CHECK(owner->result_ok);
4750         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
4751 }
4752 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4753         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
4754         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
4755         int64_tArray ret_arr = NULL;
4756         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4757         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4758         for (size_t j = 0; j < ret_var.datalen; j++) {
4759                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
4760                 *ret_conv_35_conv = ret_var.data[j];
4761                 ret_arr_ptr[j] = ((int64_t)ret_conv_35_conv);
4762         }
4763         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4764         FREE(ret_var.data);
4765         return ret_arr;
4766 }
4767
4768 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
4769 CHECK(!owner->result_ok);
4770         return *owner->contents.err;
4771 }
4772 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4773         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
4774         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
4775         return ret_conv;
4776 }
4777
4778 static jclass LDKCOption_u16Z_Some_class = NULL;
4779 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
4780 static jclass LDKCOption_u16Z_None_class = NULL;
4781 static jmethodID LDKCOption_u16Z_None_meth = NULL;
4782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
4783         LDKCOption_u16Z_Some_class =
4784                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
4785         CHECK(LDKCOption_u16Z_Some_class != NULL);
4786         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
4787         CHECK(LDKCOption_u16Z_Some_meth != NULL);
4788         LDKCOption_u16Z_None_class =
4789                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
4790         CHECK(LDKCOption_u16Z_None_class != NULL);
4791         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
4792         CHECK(LDKCOption_u16Z_None_meth != NULL);
4793 }
4794 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4795         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4796         switch(obj->tag) {
4797                 case LDKCOption_u16Z_Some: {
4798                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
4799                 }
4800                 case LDKCOption_u16Z_None: {
4801                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
4802                 }
4803                 default: abort();
4804         }
4805 }
4806 static jclass LDKAPIError_APIMisuseError_class = NULL;
4807 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
4808 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
4809 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
4810 static jclass LDKAPIError_RouteError_class = NULL;
4811 static jmethodID LDKAPIError_RouteError_meth = NULL;
4812 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
4813 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
4814 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
4815 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
4816 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
4817 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
4818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
4819         LDKAPIError_APIMisuseError_class =
4820                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
4821         CHECK(LDKAPIError_APIMisuseError_class != NULL);
4822         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
4823         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
4824         LDKAPIError_FeeRateTooHigh_class =
4825                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
4826         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
4827         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
4828         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
4829         LDKAPIError_RouteError_class =
4830                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
4831         CHECK(LDKAPIError_RouteError_class != NULL);
4832         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
4833         CHECK(LDKAPIError_RouteError_meth != NULL);
4834         LDKAPIError_ChannelUnavailable_class =
4835                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
4836         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
4837         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
4838         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
4839         LDKAPIError_MonitorUpdateFailed_class =
4840                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed"));
4841         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
4842         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
4843         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
4844         LDKAPIError_IncompatibleShutdownScript_class =
4845                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
4846         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
4847         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
4848         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
4849 }
4850 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4851         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4852         switch(obj->tag) {
4853                 case LDKAPIError_APIMisuseError: {
4854                         LDKStr err_str = obj->api_misuse_error.err;
4855                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4856                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
4857                 }
4858                 case LDKAPIError_FeeRateTooHigh: {
4859                         LDKStr err_str = obj->fee_rate_too_high.err;
4860                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4861                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
4862                 }
4863                 case LDKAPIError_RouteError: {
4864                         LDKStr err_str = obj->route_error.err;
4865                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4866                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
4867                 }
4868                 case LDKAPIError_ChannelUnavailable: {
4869                         LDKStr err_str = obj->channel_unavailable.err;
4870                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4871                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
4872                 }
4873                 case LDKAPIError_MonitorUpdateFailed: {
4874                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
4875                 }
4876                 case LDKAPIError_IncompatibleShutdownScript: {
4877                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
4878                         int64_t script_ref = 0;
4879                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4880                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4881                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
4882                         script_ref = (uintptr_t)script_var.inner & ~1;
4883                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
4884                 }
4885                 default: abort();
4886         }
4887 }
4888 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4889 CHECK(owner->result_ok);
4890         return *owner->contents.result;
4891 }
4892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4893         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4894         CResult_NoneAPIErrorZ_get_ok(owner_conv);
4895 }
4896
4897 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4898 CHECK(!owner->result_ok);
4899         return APIError_clone(&*owner->contents.err);
4900 }
4901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4902         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4903         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4904         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
4905         int64_t ret_ref = (uintptr_t)ret_copy;
4906         return ret_ref;
4907 }
4908
4909 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
4910         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
4911         for (size_t i = 0; i < ret.datalen; i++) {
4912                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
4913         }
4914         return ret;
4915 }
4916 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
4917         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
4918         for (size_t i = 0; i < ret.datalen; i++) {
4919                 ret.data[i] = APIError_clone(&orig->data[i]);
4920         }
4921         return ret;
4922 }
4923 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4924 CHECK(owner->result_ok);
4925         return ThirtyTwoBytes_clone(&*owner->contents.result);
4926 }
4927 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4928         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4929         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4930         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
4931         return ret_arr;
4932 }
4933
4934 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4935 CHECK(!owner->result_ok);
4936         return APIError_clone(&*owner->contents.err);
4937 }
4938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4939         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4940         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4941         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
4942         int64_t ret_ref = (uintptr_t)ret_copy;
4943         return ret_ref;
4944 }
4945
4946 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
4947 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
4948 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
4949 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
4950 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
4951 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
4952 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
4953 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
4954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
4955         LDKPaymentSendFailure_ParameterError_class =
4956                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
4957         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
4958         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
4959         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
4960         LDKPaymentSendFailure_PathParameterError_class =
4961                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
4962         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
4963         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
4964         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
4965         LDKPaymentSendFailure_AllFailedRetrySafe_class =
4966                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
4967         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
4968         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
4969         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
4970         LDKPaymentSendFailure_PartialFailure_class =
4971                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
4972         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
4973         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
4974         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
4975 }
4976 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4977         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4978         switch(obj->tag) {
4979                 case LDKPaymentSendFailure_ParameterError: {
4980                         int64_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
4981                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
4982                 }
4983                 case LDKPaymentSendFailure_PathParameterError: {
4984                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
4985                         int64_tArray path_parameter_error_arr = NULL;
4986                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
4987                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
4988                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
4989                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4990                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
4991                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
4992                                 path_parameter_error_arr_ptr[w] = (int64_t)path_parameter_error_conv_22_conv;
4993                         }
4994                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
4995                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
4996                 }
4997                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
4998                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
4999                         int64_tArray all_failed_retry_safe_arr = NULL;
5000                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
5001                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
5002                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
5003                                 int64_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
5004                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
5005                         }
5006                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
5007                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
5008                 }
5009                 case LDKPaymentSendFailure_PartialFailure: {
5010                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
5011                         int64_tArray results_arr = NULL;
5012                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
5013                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
5014                         for (size_t w = 0; w < results_var.datalen; w++) {
5015                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5016                                 *results_conv_22_conv = results_var.data[w];
5017                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
5018                                 results_arr_ptr[w] = (int64_t)results_conv_22_conv;
5019                         }
5020                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
5021                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
5022                         int64_t failed_paths_retry_ref = 0;
5023                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
5024                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5025                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5026                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
5027                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
5028                         }
5029                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
5030                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
5031                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
5032                 }
5033                 default: abort();
5034         }
5035 }
5036 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
5037 CHECK(owner->result_ok);
5038         return ThirtyTwoBytes_clone(&*owner->contents.result);
5039 }
5040 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5041         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
5042         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5043         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data);
5044         return ret_arr;
5045 }
5046
5047 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
5048 CHECK(!owner->result_ok);
5049         return PaymentSendFailure_clone(&*owner->contents.err);
5050 }
5051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5052         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
5053         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5054         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
5055         int64_t ret_ref = (uintptr_t)ret_copy;
5056         return ret_ref;
5057 }
5058
5059 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5060 CHECK(owner->result_ok);
5061         return *owner->contents.result;
5062 }
5063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5064         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
5065         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
5066 }
5067
5068 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5069 CHECK(!owner->result_ok);
5070         return PaymentSendFailure_clone(&*owner->contents.err);
5071 }
5072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5073         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
5074         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5075         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
5076         int64_t ret_ref = (uintptr_t)ret_copy;
5077         return ret_ref;
5078 }
5079
5080 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
5081         return ThirtyTwoBytes_clone(&owner->a);
5082 }
5083 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5084         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
5085         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5086         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
5087         return ret_arr;
5088 }
5089
5090 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
5091         return ThirtyTwoBytes_clone(&owner->b);
5092 }
5093 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5094         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
5095         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5096         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
5097         return ret_arr;
5098 }
5099
5100 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5101 CHECK(owner->result_ok);
5102         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
5103 }
5104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5105         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
5106         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
5107         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
5108         return ((int64_t)ret_conv);
5109 }
5110
5111 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5112 CHECK(!owner->result_ok);
5113         return PaymentSendFailure_clone(&*owner->contents.err);
5114 }
5115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5116         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
5117         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5118         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
5119         int64_t ret_ref = (uintptr_t)ret_copy;
5120         return ret_ref;
5121 }
5122
5123 static jclass LDKNetAddress_IPv4_class = NULL;
5124 static jmethodID LDKNetAddress_IPv4_meth = NULL;
5125 static jclass LDKNetAddress_IPv6_class = NULL;
5126 static jmethodID LDKNetAddress_IPv6_meth = NULL;
5127 static jclass LDKNetAddress_OnionV2_class = NULL;
5128 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
5129 static jclass LDKNetAddress_OnionV3_class = NULL;
5130 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
5131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
5132         LDKNetAddress_IPv4_class =
5133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
5134         CHECK(LDKNetAddress_IPv4_class != NULL);
5135         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
5136         CHECK(LDKNetAddress_IPv4_meth != NULL);
5137         LDKNetAddress_IPv6_class =
5138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
5139         CHECK(LDKNetAddress_IPv6_class != NULL);
5140         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
5141         CHECK(LDKNetAddress_IPv6_meth != NULL);
5142         LDKNetAddress_OnionV2_class =
5143                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
5144         CHECK(LDKNetAddress_OnionV2_class != NULL);
5145         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
5146         CHECK(LDKNetAddress_OnionV2_meth != NULL);
5147         LDKNetAddress_OnionV3_class =
5148                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
5149         CHECK(LDKNetAddress_OnionV3_class != NULL);
5150         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
5151         CHECK(LDKNetAddress_OnionV3_meth != NULL);
5152 }
5153 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5154         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
5155         switch(obj->tag) {
5156                 case LDKNetAddress_IPv4: {
5157                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
5158                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
5159                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
5160                 }
5161                 case LDKNetAddress_IPv6: {
5162                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
5163                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
5164                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
5165                 }
5166                 case LDKNetAddress_OnionV2: {
5167                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
5168                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
5169                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
5170                 }
5171                 case LDKNetAddress_OnionV3: {
5172                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
5173                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
5174                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, obj->onion_v3.checksum, obj->onion_v3.version, obj->onion_v3.port);
5175                 }
5176                 default: abort();
5177         }
5178 }
5179 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
5180         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
5181         for (size_t i = 0; i < ret.datalen; i++) {
5182                 ret.data[i] = NetAddress_clone(&orig->data[i]);
5183         }
5184         return ret;
5185 }
5186 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
5187         return ThirtyTwoBytes_clone(&owner->a);
5188 }
5189 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5190         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
5191         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5192         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
5193         return ret_arr;
5194 }
5195
5196 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
5197         return ThirtyTwoBytes_clone(&owner->b);
5198 }
5199 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5200         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
5201         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5202         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
5203         return ret_arr;
5204 }
5205
5206 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5207 CHECK(owner->result_ok);
5208         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5209 }
5210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5211         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5212         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5213         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
5214         return ((int64_t)ret_conv);
5215 }
5216
5217 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5218 CHECK(!owner->result_ok);
5219         return *owner->contents.err;
5220 }
5221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5222         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5223         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
5224 }
5225
5226 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5227 CHECK(owner->result_ok);
5228         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5229 }
5230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5231         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5232         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5233         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
5234         return ((int64_t)ret_conv);
5235 }
5236
5237 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5238 CHECK(!owner->result_ok);
5239         return APIError_clone(&*owner->contents.err);
5240 }
5241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5242         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5243         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5244         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
5245         int64_t ret_ref = (uintptr_t)ret_copy;
5246         return ret_ref;
5247 }
5248
5249 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5250 CHECK(owner->result_ok);
5251         return ThirtyTwoBytes_clone(&*owner->contents.result);
5252 }
5253 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5254         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5255         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5256         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
5257         return ret_arr;
5258 }
5259
5260 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5261 CHECK(!owner->result_ok);
5262         return *owner->contents.err;
5263 }
5264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5265         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5266         CResult_PaymentSecretNoneZ_get_err(owner_conv);
5267 }
5268
5269 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5270 CHECK(owner->result_ok);
5271         return ThirtyTwoBytes_clone(&*owner->contents.result);
5272 }
5273 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5274         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
5275         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5276         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
5277         return ret_arr;
5278 }
5279
5280 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5281 CHECK(!owner->result_ok);
5282         return APIError_clone(&*owner->contents.err);
5283 }
5284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5285         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
5286         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5287         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
5288         int64_t ret_ref = (uintptr_t)ret_copy;
5289         return ret_ref;
5290 }
5291
5292 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5293 CHECK(owner->result_ok);
5294         return ThirtyTwoBytes_clone(&*owner->contents.result);
5295 }
5296 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5297         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
5298         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5299         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
5300         return ret_arr;
5301 }
5302
5303 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5304 CHECK(!owner->result_ok);
5305         return APIError_clone(&*owner->contents.err);
5306 }
5307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5308         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
5309         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5310         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
5311         int64_t ret_ref = (uintptr_t)ret_copy;
5312         return ret_ref;
5313 }
5314
5315 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5316 CHECK(owner->result_ok);
5317         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
5318 }
5319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5320         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
5321         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
5322         int64_t ret_ref = 0;
5323         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5324         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5325         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5326         ret_ref = (uintptr_t)ret_var.inner;
5327         if (ret_var.is_owned) {
5328                 ret_ref |= 1;
5329         }
5330         return ret_ref;
5331 }
5332
5333 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5334 CHECK(!owner->result_ok);
5335         return DecodeError_clone(&*owner->contents.err);
5336 }
5337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5338         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
5339         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
5340         int64_t ret_ref = 0;
5341         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5342         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5344         ret_ref = (uintptr_t)ret_var.inner;
5345         if (ret_var.is_owned) {
5346                 ret_ref |= 1;
5347         }
5348         return ret_ref;
5349 }
5350
5351 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5352 CHECK(owner->result_ok);
5353         return ChannelCounterparty_clone(&*owner->contents.result);
5354 }
5355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5356         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
5357         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
5358         int64_t ret_ref = 0;
5359         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5360         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5362         ret_ref = (uintptr_t)ret_var.inner;
5363         if (ret_var.is_owned) {
5364                 ret_ref |= 1;
5365         }
5366         return ret_ref;
5367 }
5368
5369 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5370 CHECK(!owner->result_ok);
5371         return DecodeError_clone(&*owner->contents.err);
5372 }
5373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5374         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
5375         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
5376         int64_t ret_ref = 0;
5377         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5378         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5379         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5380         ret_ref = (uintptr_t)ret_var.inner;
5381         if (ret_var.is_owned) {
5382                 ret_ref |= 1;
5383         }
5384         return ret_ref;
5385 }
5386
5387 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5388 CHECK(owner->result_ok);
5389         return ChannelDetails_clone(&*owner->contents.result);
5390 }
5391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5392         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5393         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
5394         int64_t ret_ref = 0;
5395         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5396         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5398         ret_ref = (uintptr_t)ret_var.inner;
5399         if (ret_var.is_owned) {
5400                 ret_ref |= 1;
5401         }
5402         return ret_ref;
5403 }
5404
5405 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5406 CHECK(!owner->result_ok);
5407         return DecodeError_clone(&*owner->contents.err);
5408 }
5409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5410         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5411         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
5412         int64_t ret_ref = 0;
5413         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5414         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5416         ret_ref = (uintptr_t)ret_var.inner;
5417         if (ret_var.is_owned) {
5418                 ret_ref |= 1;
5419         }
5420         return ret_ref;
5421 }
5422
5423 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5424 CHECK(owner->result_ok);
5425         return PhantomRouteHints_clone(&*owner->contents.result);
5426 }
5427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5428         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5429         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
5430         int64_t ret_ref = 0;
5431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5434         ret_ref = (uintptr_t)ret_var.inner;
5435         if (ret_var.is_owned) {
5436                 ret_ref |= 1;
5437         }
5438         return ret_ref;
5439 }
5440
5441 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5442 CHECK(!owner->result_ok);
5443         return DecodeError_clone(&*owner->contents.err);
5444 }
5445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5446         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5447         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
5448         int64_t ret_ref = 0;
5449         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5450         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5452         ret_ref = (uintptr_t)ret_var.inner;
5453         if (ret_var.is_owned) {
5454                 ret_ref |= 1;
5455         }
5456         return ret_ref;
5457 }
5458
5459 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
5460         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
5461         for (size_t i = 0; i < ret.datalen; i++) {
5462                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
5463         }
5464         return ret;
5465 }
5466 typedef struct LDKWatch_JCalls {
5467         atomic_size_t refcnt;
5468         JavaVM *vm;
5469         jweak o;
5470         jmethodID watch_channel_meth;
5471         jmethodID update_channel_meth;
5472         jmethodID release_pending_monitor_events_meth;
5473 } LDKWatch_JCalls;
5474 static void LDKWatch_JCalls_free(void* this_arg) {
5475         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5476         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5477                 JNIEnv *env;
5478                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5479                 if (get_jenv_res == JNI_EDETACHED) {
5480                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5481                 } else {
5482                         DO_ASSERT(get_jenv_res == JNI_OK);
5483                 }
5484                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5485                 if (get_jenv_res == JNI_EDETACHED) {
5486                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5487                 }
5488                 FREE(j_calls);
5489         }
5490 }
5491 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
5492         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5493         JNIEnv *env;
5494         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5495         if (get_jenv_res == JNI_EDETACHED) {
5496                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5497         } else {
5498                 DO_ASSERT(get_jenv_res == JNI_OK);
5499         }
5500         LDKOutPoint funding_txo_var = funding_txo;
5501         int64_t funding_txo_ref = 0;
5502         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5503         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5504         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5505         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5506         if (funding_txo_var.is_owned) {
5507                 funding_txo_ref |= 1;
5508         }
5509         LDKChannelMonitor monitor_var = monitor;
5510         int64_t monitor_ref = 0;
5511         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5512         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5513         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
5514         monitor_ref = (uintptr_t)monitor_var.inner;
5515         if (monitor_var.is_owned) {
5516                 monitor_ref |= 1;
5517         }
5518         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5519         CHECK(obj != NULL);
5520         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
5521         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5522                 (*env)->ExceptionDescribe(env);
5523                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
5524         }
5525         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5526         CHECK_ACCESS(ret_ptr);
5527         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5528         FREE((void*)ret);
5529         if (get_jenv_res == JNI_EDETACHED) {
5530                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5531         }
5532         return ret_conv;
5533 }
5534 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
5535         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5536         JNIEnv *env;
5537         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5538         if (get_jenv_res == JNI_EDETACHED) {
5539                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5540         } else {
5541                 DO_ASSERT(get_jenv_res == JNI_OK);
5542         }
5543         LDKOutPoint funding_txo_var = funding_txo;
5544         int64_t funding_txo_ref = 0;
5545         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5546         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5547         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5548         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5549         if (funding_txo_var.is_owned) {
5550                 funding_txo_ref |= 1;
5551         }
5552         LDKChannelMonitorUpdate update_var = update;
5553         int64_t update_ref = 0;
5554         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5555         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5556         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
5557         update_ref = (uintptr_t)update_var.inner;
5558         if (update_var.is_owned) {
5559                 update_ref |= 1;
5560         }
5561         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5562         CHECK(obj != NULL);
5563         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
5564         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5565                 (*env)->ExceptionDescribe(env);
5566                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
5567         }
5568         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5569         CHECK_ACCESS(ret_ptr);
5570         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5571         FREE((void*)ret);
5572         if (get_jenv_res == JNI_EDETACHED) {
5573                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5574         }
5575         return ret_conv;
5576 }
5577 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
5578         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5579         JNIEnv *env;
5580         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5581         if (get_jenv_res == JNI_EDETACHED) {
5582                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5583         } else {
5584                 DO_ASSERT(get_jenv_res == JNI_OK);
5585         }
5586         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5587         CHECK(obj != NULL);
5588         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
5589         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5590                 (*env)->ExceptionDescribe(env);
5591                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
5592         }
5593         LDKCVec_MonitorEventZ ret_constr;
5594         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
5595         if (ret_constr.datalen > 0)
5596                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
5597         else
5598                 ret_constr.data = NULL;
5599         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
5600         for (size_t o = 0; o < ret_constr.datalen; o++) {
5601                 int64_t ret_conv_14 = ret_vals[o];
5602                 void* ret_conv_14_ptr = (void*)(((uintptr_t)ret_conv_14) & ~1);
5603                 CHECK_ACCESS(ret_conv_14_ptr);
5604                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
5605                 FREE((void*)ret_conv_14);
5606                 ret_constr.data[o] = ret_conv_14_conv;
5607         }
5608         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
5609         if (get_jenv_res == JNI_EDETACHED) {
5610                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5611         }
5612         return ret_constr;
5613 }
5614 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
5615         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
5616         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5617 }
5618 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
5619         jclass c = (*env)->GetObjectClass(env, o);
5620         CHECK(c != NULL);
5621         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
5622         atomic_init(&calls->refcnt, 1);
5623         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5624         calls->o = (*env)->NewWeakGlobalRef(env, o);
5625         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
5626         CHECK(calls->watch_channel_meth != NULL);
5627         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
5628         CHECK(calls->update_channel_meth != NULL);
5629         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
5630         CHECK(calls->release_pending_monitor_events_meth != NULL);
5631
5632         LDKWatch ret = {
5633                 .this_arg = (void*) calls,
5634                 .watch_channel = watch_channel_LDKWatch_jcall,
5635                 .update_channel = update_channel_LDKWatch_jcall,
5636                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
5637                 .free = LDKWatch_JCalls_free,
5638         };
5639         return ret;
5640 }
5641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
5642         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
5643         *res_ptr = LDKWatch_init(env, clz, o);
5644         return (uint64_t)res_ptr;
5645 }
5646 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) {
5647         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5648         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5649         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5650         LDKOutPoint funding_txo_conv;
5651         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5652         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5653         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5654         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5655         LDKChannelMonitor monitor_conv;
5656         monitor_conv.inner = (void*)(monitor & (~1));
5657         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
5658         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
5659         monitor_conv = ChannelMonitor_clone(&monitor_conv);
5660         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5661         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
5662         return (int64_t)ret_conv;
5663 }
5664
5665 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) {
5666         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5667         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5668         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5669         LDKOutPoint funding_txo_conv;
5670         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5671         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5672         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5673         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5674         LDKChannelMonitorUpdate update_conv;
5675         update_conv.inner = (void*)(update & (~1));
5676         update_conv.is_owned = (update & 1) || (update == 0);
5677         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
5678         update_conv = ChannelMonitorUpdate_clone(&update_conv);
5679         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5680         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
5681         return (int64_t)ret_conv;
5682 }
5683
5684 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
5685         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5686         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5687         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5688         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
5689         int64_tArray ret_arr = NULL;
5690         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5691         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5692         for (size_t o = 0; o < ret_var.datalen; o++) {
5693                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
5694                 *ret_conv_14_copy = ret_var.data[o];
5695                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
5696                 ret_arr_ptr[o] = ret_conv_14_ref;
5697         }
5698         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5699         FREE(ret_var.data);
5700         return ret_arr;
5701 }
5702
5703 typedef struct LDKBroadcasterInterface_JCalls {
5704         atomic_size_t refcnt;
5705         JavaVM *vm;
5706         jweak o;
5707         jmethodID broadcast_transaction_meth;
5708 } LDKBroadcasterInterface_JCalls;
5709 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
5710         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5711         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5712                 JNIEnv *env;
5713                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5714                 if (get_jenv_res == JNI_EDETACHED) {
5715                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5716                 } else {
5717                         DO_ASSERT(get_jenv_res == JNI_OK);
5718                 }
5719                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5720                 if (get_jenv_res == JNI_EDETACHED) {
5721                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5722                 }
5723                 FREE(j_calls);
5724         }
5725 }
5726 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
5727         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5728         JNIEnv *env;
5729         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5730         if (get_jenv_res == JNI_EDETACHED) {
5731                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5732         } else {
5733                 DO_ASSERT(get_jenv_res == JNI_OK);
5734         }
5735         LDKTransaction tx_var = tx;
5736         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
5737         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
5738         Transaction_free(tx_var);
5739         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5740         CHECK(obj != NULL);
5741         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
5742         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5743                 (*env)->ExceptionDescribe(env);
5744                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
5745         }
5746         if (get_jenv_res == JNI_EDETACHED) {
5747                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5748         }
5749 }
5750 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
5751         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
5752         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5753 }
5754 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
5755         jclass c = (*env)->GetObjectClass(env, o);
5756         CHECK(c != NULL);
5757         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
5758         atomic_init(&calls->refcnt, 1);
5759         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5760         calls->o = (*env)->NewWeakGlobalRef(env, o);
5761         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
5762         CHECK(calls->broadcast_transaction_meth != NULL);
5763
5764         LDKBroadcasterInterface ret = {
5765                 .this_arg = (void*) calls,
5766                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
5767                 .free = LDKBroadcasterInterface_JCalls_free,
5768         };
5769         return ret;
5770 }
5771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
5772         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
5773         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
5774         return (uint64_t)res_ptr;
5775 }
5776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
5777         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5778         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5779         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
5780         LDKTransaction tx_ref;
5781         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
5782         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
5783         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
5784         tx_ref.data_is_owned = true;
5785         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
5786 }
5787
5788 typedef struct LDKKeysInterface_JCalls {
5789         atomic_size_t refcnt;
5790         JavaVM *vm;
5791         jweak o;
5792         jmethodID get_node_secret_meth;
5793         jmethodID get_destination_script_meth;
5794         jmethodID get_shutdown_scriptpubkey_meth;
5795         jmethodID get_channel_signer_meth;
5796         jmethodID get_secure_random_bytes_meth;
5797         jmethodID read_chan_signer_meth;
5798         jmethodID sign_invoice_meth;
5799         jmethodID get_inbound_payment_key_material_meth;
5800 } LDKKeysInterface_JCalls;
5801 static void LDKKeysInterface_JCalls_free(void* this_arg) {
5802         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5803         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5804                 JNIEnv *env;
5805                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5806                 if (get_jenv_res == JNI_EDETACHED) {
5807                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5808                 } else {
5809                         DO_ASSERT(get_jenv_res == JNI_OK);
5810                 }
5811                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5812                 if (get_jenv_res == JNI_EDETACHED) {
5813                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5814                 }
5815                 FREE(j_calls);
5816         }
5817 }
5818 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
5819         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5820         JNIEnv *env;
5821         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5822         if (get_jenv_res == JNI_EDETACHED) {
5823                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5824         } else {
5825                 DO_ASSERT(get_jenv_res == JNI_OK);
5826         }
5827         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
5828         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5829         CHECK(obj != NULL);
5830         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
5831         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5832                 (*env)->ExceptionDescribe(env);
5833                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
5834         }
5835         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5836         CHECK_ACCESS(ret_ptr);
5837         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
5838         FREE((void*)ret);
5839         if (get_jenv_res == JNI_EDETACHED) {
5840                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5841         }
5842         return ret_conv;
5843 }
5844 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
5845         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5846         JNIEnv *env;
5847         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5848         if (get_jenv_res == JNI_EDETACHED) {
5849                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5850         } else {
5851                 DO_ASSERT(get_jenv_res == JNI_OK);
5852         }
5853         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5854         CHECK(obj != NULL);
5855         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
5856         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5857                 (*env)->ExceptionDescribe(env);
5858                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
5859         }
5860         LDKCVec_u8Z ret_ref;
5861         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5862         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5863         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5864         if (get_jenv_res == JNI_EDETACHED) {
5865                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5866         }
5867         return ret_ref;
5868 }
5869 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
5870         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5871         JNIEnv *env;
5872         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5873         if (get_jenv_res == JNI_EDETACHED) {
5874                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5875         } else {
5876                 DO_ASSERT(get_jenv_res == JNI_OK);
5877         }
5878         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5879         CHECK(obj != NULL);
5880         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
5881         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5882                 (*env)->ExceptionDescribe(env);
5883                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
5884         }
5885         LDKShutdownScript ret_conv;
5886         ret_conv.inner = (void*)(ret & (~1));
5887         ret_conv.is_owned = (ret & 1) || (ret == 0);
5888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
5889         if (get_jenv_res == JNI_EDETACHED) {
5890                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5891         }
5892         return ret_conv;
5893 }
5894 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
5895         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5896         JNIEnv *env;
5897         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5898         if (get_jenv_res == JNI_EDETACHED) {
5899                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5900         } else {
5901                 DO_ASSERT(get_jenv_res == JNI_OK);
5902         }
5903         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5904         CHECK(obj != NULL);
5905         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
5906         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5907                 (*env)->ExceptionDescribe(env);
5908                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
5909         }
5910         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5911         CHECK_ACCESS(ret_ptr);
5912         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
5913         FREE((void*)ret);
5914         if (get_jenv_res == JNI_EDETACHED) {
5915                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5916         }
5917         return ret_conv;
5918 }
5919 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
5920         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5921         JNIEnv *env;
5922         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5923         if (get_jenv_res == JNI_EDETACHED) {
5924                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5925         } else {
5926                 DO_ASSERT(get_jenv_res == JNI_OK);
5927         }
5928         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5929         CHECK(obj != NULL);
5930         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
5931         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5932                 (*env)->ExceptionDescribe(env);
5933                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
5934         }
5935         LDKThirtyTwoBytes ret_ref;
5936         CHECK((*env)->GetArrayLength(env, ret) == 32);
5937         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5938         if (get_jenv_res == JNI_EDETACHED) {
5939                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5940         }
5941         return ret_ref;
5942 }
5943 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
5944         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5945         JNIEnv *env;
5946         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5947         if (get_jenv_res == JNI_EDETACHED) {
5948                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5949         } else {
5950                 DO_ASSERT(get_jenv_res == JNI_OK);
5951         }
5952         LDKu8slice reader_var = reader;
5953         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
5954         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
5955         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5956         CHECK(obj != NULL);
5957         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
5958         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5959                 (*env)->ExceptionDescribe(env);
5960                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
5961         }
5962         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5963         CHECK_ACCESS(ret_ptr);
5964         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
5965         FREE((void*)ret);
5966         if (get_jenv_res == JNI_EDETACHED) {
5967                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5968         }
5969         return ret_conv;
5970 }
5971 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
5972         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5973         JNIEnv *env;
5974         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5975         if (get_jenv_res == JNI_EDETACHED) {
5976                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5977         } else {
5978                 DO_ASSERT(get_jenv_res == JNI_OK);
5979         }
5980         LDKu8slice hrp_bytes_var = hrp_bytes;
5981         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
5982         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
5983         LDKCVec_u5Z invoice_data_var = invoice_data;
5984         jobjectArray invoice_data_arr = NULL;
5985         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
5986         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
5987         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
5988                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
5989                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
5990         }
5991         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
5992         FREE(invoice_data_var.data);
5993         jclass receipient_conv = LDKRecipient_to_java(env, receipient);
5994         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5995         CHECK(obj != NULL);
5996         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
5997         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5998                 (*env)->ExceptionDescribe(env);
5999                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
6000         }
6001         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6002         CHECK_ACCESS(ret_ptr);
6003         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
6004         FREE((void*)ret);
6005         if (get_jenv_res == JNI_EDETACHED) {
6006                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6007         }
6008         return ret_conv;
6009 }
6010 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
6011         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6012         JNIEnv *env;
6013         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6014         if (get_jenv_res == JNI_EDETACHED) {
6015                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6016         } else {
6017                 DO_ASSERT(get_jenv_res == JNI_OK);
6018         }
6019         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6020         CHECK(obj != NULL);
6021         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
6022         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6023                 (*env)->ExceptionDescribe(env);
6024                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
6025         }
6026         LDKThirtyTwoBytes ret_ref;
6027         CHECK((*env)->GetArrayLength(env, ret) == 32);
6028         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
6029         if (get_jenv_res == JNI_EDETACHED) {
6030                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6031         }
6032         return ret_ref;
6033 }
6034 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
6035         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
6036         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6037 }
6038 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
6039         jclass c = (*env)->GetObjectClass(env, o);
6040         CHECK(c != NULL);
6041         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
6042         atomic_init(&calls->refcnt, 1);
6043         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6044         calls->o = (*env)->NewWeakGlobalRef(env, o);
6045         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
6046         CHECK(calls->get_node_secret_meth != NULL);
6047         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
6048         CHECK(calls->get_destination_script_meth != NULL);
6049         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
6050         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
6051         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
6052         CHECK(calls->get_channel_signer_meth != NULL);
6053         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
6054         CHECK(calls->get_secure_random_bytes_meth != NULL);
6055         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
6056         CHECK(calls->read_chan_signer_meth != NULL);
6057         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
6058         CHECK(calls->sign_invoice_meth != NULL);
6059         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
6060         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
6061
6062         LDKKeysInterface ret = {
6063                 .this_arg = (void*) calls,
6064                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
6065                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
6066                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
6067                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
6068                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
6069                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
6070                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
6071                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
6072                 .free = LDKKeysInterface_JCalls_free,
6073         };
6074         return ret;
6075 }
6076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
6077         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
6078         *res_ptr = LDKKeysInterface_init(env, clz, o);
6079         return (uint64_t)res_ptr;
6080 }
6081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
6082         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6083         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6084         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6085         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
6086         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
6087         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
6088         return (int64_t)ret_conv;
6089 }
6090
6091 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
6092         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6093         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6094         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6095         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
6096         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6097         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6098         CVec_u8Z_free(ret_var);
6099         return ret_arr;
6100 }
6101
6102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
6103         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6104         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6105         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6106         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
6107         int64_t ret_ref = 0;
6108         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6109         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6110         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6111         ret_ref = (uintptr_t)ret_var.inner;
6112         if (ret_var.is_owned) {
6113                 ret_ref |= 1;
6114         }
6115         return ret_ref;
6116 }
6117
6118 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) {
6119         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6120         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6121         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6122         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
6123         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
6124         return (int64_t)ret_ret;
6125 }
6126
6127 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
6128         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6129         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6130         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6131         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6132         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
6133         return ret_arr;
6134 }
6135
6136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
6137         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6138         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6139         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6140         LDKu8slice reader_ref;
6141         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
6142         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
6143         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
6144         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
6145         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
6146         return (int64_t)ret_conv;
6147 }
6148
6149 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) {
6150         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6151         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6152         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6153         LDKu8slice hrp_bytes_ref;
6154         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
6155         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
6156         LDKCVec_u5Z invoice_data_constr;
6157         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
6158         if (invoice_data_constr.datalen > 0)
6159                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
6160         else
6161                 invoice_data_constr.data = NULL;
6162         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
6163         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
6164                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
6165                 
6166                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
6167         }
6168         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
6169         LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
6170         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
6171         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
6172         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
6173         return (int64_t)ret_conv;
6174 }
6175
6176 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
6177         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6178         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6179         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6180         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6181         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
6182         return ret_arr;
6183 }
6184
6185 typedef struct LDKFeeEstimator_JCalls {
6186         atomic_size_t refcnt;
6187         JavaVM *vm;
6188         jweak o;
6189         jmethodID get_est_sat_per_1000_weight_meth;
6190 } LDKFeeEstimator_JCalls;
6191 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
6192         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6193         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6194                 JNIEnv *env;
6195                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6196                 if (get_jenv_res == JNI_EDETACHED) {
6197                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6198                 } else {
6199                         DO_ASSERT(get_jenv_res == JNI_OK);
6200                 }
6201                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6202                 if (get_jenv_res == JNI_EDETACHED) {
6203                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6204                 }
6205                 FREE(j_calls);
6206         }
6207 }
6208 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
6209         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6210         JNIEnv *env;
6211         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6212         if (get_jenv_res == JNI_EDETACHED) {
6213                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6214         } else {
6215                 DO_ASSERT(get_jenv_res == JNI_OK);
6216         }
6217         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
6218         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6219         CHECK(obj != NULL);
6220         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
6221         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6222                 (*env)->ExceptionDescribe(env);
6223                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
6224         }
6225         if (get_jenv_res == JNI_EDETACHED) {
6226                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6227         }
6228         return ret;
6229 }
6230 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
6231         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
6232         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6233 }
6234 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
6235         jclass c = (*env)->GetObjectClass(env, o);
6236         CHECK(c != NULL);
6237         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
6238         atomic_init(&calls->refcnt, 1);
6239         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6240         calls->o = (*env)->NewWeakGlobalRef(env, o);
6241         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
6242         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
6243
6244         LDKFeeEstimator ret = {
6245                 .this_arg = (void*) calls,
6246                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
6247                 .free = LDKFeeEstimator_JCalls_free,
6248         };
6249         return ret;
6250 }
6251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
6252         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
6253         *res_ptr = LDKFeeEstimator_init(env, clz, o);
6254         return (uint64_t)res_ptr;
6255 }
6256 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) {
6257         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6258         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6259         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
6260         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
6261         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
6262         return ret_val;
6263 }
6264
6265 typedef struct LDKLogger_JCalls {
6266         atomic_size_t refcnt;
6267         JavaVM *vm;
6268         jweak o;
6269         jmethodID log_meth;
6270 } LDKLogger_JCalls;
6271 static void LDKLogger_JCalls_free(void* this_arg) {
6272         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
6273         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6274                 JNIEnv *env;
6275                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6276                 if (get_jenv_res == JNI_EDETACHED) {
6277                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6278                 } else {
6279                         DO_ASSERT(get_jenv_res == JNI_OK);
6280                 }
6281                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6282                 if (get_jenv_res == JNI_EDETACHED) {
6283                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6284                 }
6285                 FREE(j_calls);
6286         }
6287 }
6288 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
6289         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
6290         JNIEnv *env;
6291         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6292         if (get_jenv_res == JNI_EDETACHED) {
6293                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6294         } else {
6295                 DO_ASSERT(get_jenv_res == JNI_OK);
6296         }
6297         LDKRecord record_var = *record;
6298         int64_t record_ref = 0;
6299         record_var = Record_clone(&record_var);
6300         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6301         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6302         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
6303         record_ref = (uintptr_t)record_var.inner;
6304         if (record_var.is_owned) {
6305                 record_ref |= 1;
6306         }
6307         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6308         CHECK(obj != NULL);
6309         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
6310         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6311                 (*env)->ExceptionDescribe(env);
6312                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
6313         }
6314         if (get_jenv_res == JNI_EDETACHED) {
6315                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6316         }
6317 }
6318 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
6319         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
6320         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6321 }
6322 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
6323         jclass c = (*env)->GetObjectClass(env, o);
6324         CHECK(c != NULL);
6325         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
6326         atomic_init(&calls->refcnt, 1);
6327         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6328         calls->o = (*env)->NewWeakGlobalRef(env, o);
6329         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
6330         CHECK(calls->log_meth != NULL);
6331
6332         LDKLogger ret = {
6333                 .this_arg = (void*) calls,
6334                 .log = log_LDKLogger_jcall,
6335                 .free = LDKLogger_JCalls_free,
6336         };
6337         return ret;
6338 }
6339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
6340         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
6341         *res_ptr = LDKLogger_init(env, clz, o);
6342         return (uint64_t)res_ptr;
6343 }
6344 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6345         return ThirtyTwoBytes_clone(&owner->a);
6346 }
6347 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6348         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6349         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6350         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
6351         return ret_arr;
6352 }
6353
6354 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6355         return &owner->b;
6356 }
6357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6358         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6359         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
6360         int64_t ret_ref = 0;
6361         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6362         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6364         ret_ref = (uintptr_t)ret_var.inner & ~1;
6365         return ret_ref;
6366 }
6367
6368 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6369 CHECK(owner->result_ok);
6370         return &*owner->contents.result;
6371 }
6372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6373         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
6374         int64_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
6375         return ret_ret;
6376 }
6377
6378 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6379 CHECK(!owner->result_ok);
6380         return DecodeError_clone(&*owner->contents.err);
6381 }
6382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6383         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
6384         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
6385         int64_t ret_ref = 0;
6386         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6387         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6389         ret_ref = (uintptr_t)ret_var.inner;
6390         if (ret_var.is_owned) {
6391                 ret_ref |= 1;
6392         }
6393         return ret_ref;
6394 }
6395
6396 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
6397 CHECK(owner->result_ok);
6398         return ChannelConfig_clone(&*owner->contents.result);
6399 }
6400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6401         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
6402         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
6403         int64_t ret_ref = 0;
6404         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6405         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6407         ret_ref = (uintptr_t)ret_var.inner;
6408         if (ret_var.is_owned) {
6409                 ret_ref |= 1;
6410         }
6411         return ret_ref;
6412 }
6413
6414 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
6415 CHECK(!owner->result_ok);
6416         return DecodeError_clone(&*owner->contents.err);
6417 }
6418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6419         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
6420         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
6421         int64_t ret_ref = 0;
6422         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6423         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6425         ret_ref = (uintptr_t)ret_var.inner;
6426         if (ret_var.is_owned) {
6427                 ret_ref |= 1;
6428         }
6429         return ret_ref;
6430 }
6431
6432 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
6433 CHECK(owner->result_ok);
6434         return OutPoint_clone(&*owner->contents.result);
6435 }
6436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6437         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
6438         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
6439         int64_t ret_ref = 0;
6440         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6441         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6443         ret_ref = (uintptr_t)ret_var.inner;
6444         if (ret_var.is_owned) {
6445                 ret_ref |= 1;
6446         }
6447         return ret_ref;
6448 }
6449
6450 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
6451 CHECK(!owner->result_ok);
6452         return DecodeError_clone(&*owner->contents.err);
6453 }
6454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6455         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
6456         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
6457         int64_t ret_ref = 0;
6458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6461         ret_ref = (uintptr_t)ret_var.inner;
6462         if (ret_var.is_owned) {
6463                 ret_ref |= 1;
6464         }
6465         return ret_ref;
6466 }
6467
6468 typedef struct LDKType_JCalls {
6469         atomic_size_t refcnt;
6470         JavaVM *vm;
6471         jweak o;
6472         jmethodID type_id_meth;
6473         jmethodID debug_str_meth;
6474         jmethodID write_meth;
6475 } LDKType_JCalls;
6476 static void LDKType_JCalls_free(void* this_arg) {
6477         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6478         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6479                 JNIEnv *env;
6480                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6481                 if (get_jenv_res == JNI_EDETACHED) {
6482                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6483                 } else {
6484                         DO_ASSERT(get_jenv_res == JNI_OK);
6485                 }
6486                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6487                 if (get_jenv_res == JNI_EDETACHED) {
6488                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6489                 }
6490                 FREE(j_calls);
6491         }
6492 }
6493 uint16_t type_id_LDKType_jcall(const void* this_arg) {
6494         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6495         JNIEnv *env;
6496         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6497         if (get_jenv_res == JNI_EDETACHED) {
6498                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6499         } else {
6500                 DO_ASSERT(get_jenv_res == JNI_OK);
6501         }
6502         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6503         CHECK(obj != NULL);
6504         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
6505         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6506                 (*env)->ExceptionDescribe(env);
6507                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
6508         }
6509         if (get_jenv_res == JNI_EDETACHED) {
6510                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6511         }
6512         return ret;
6513 }
6514 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
6515         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6516         JNIEnv *env;
6517         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6518         if (get_jenv_res == JNI_EDETACHED) {
6519                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6520         } else {
6521                 DO_ASSERT(get_jenv_res == JNI_OK);
6522         }
6523         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6524         CHECK(obj != NULL);
6525         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
6526         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6527                 (*env)->ExceptionDescribe(env);
6528                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
6529         }
6530         LDKStr ret_conv = java_to_owned_str(env, ret);
6531         if (get_jenv_res == JNI_EDETACHED) {
6532                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6533         }
6534         return ret_conv;
6535 }
6536 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
6537         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6538         JNIEnv *env;
6539         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6540         if (get_jenv_res == JNI_EDETACHED) {
6541                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6542         } else {
6543                 DO_ASSERT(get_jenv_res == JNI_OK);
6544         }
6545         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6546         CHECK(obj != NULL);
6547         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
6548         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6549                 (*env)->ExceptionDescribe(env);
6550                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
6551         }
6552         LDKCVec_u8Z ret_ref;
6553         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6554         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6555         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6556         if (get_jenv_res == JNI_EDETACHED) {
6557                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6558         }
6559         return ret_ref;
6560 }
6561 static void LDKType_JCalls_cloned(LDKType* new_obj) {
6562         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
6563         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6564 }
6565 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
6566         jclass c = (*env)->GetObjectClass(env, o);
6567         CHECK(c != NULL);
6568         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
6569         atomic_init(&calls->refcnt, 1);
6570         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6571         calls->o = (*env)->NewWeakGlobalRef(env, o);
6572         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
6573         CHECK(calls->type_id_meth != NULL);
6574         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
6575         CHECK(calls->debug_str_meth != NULL);
6576         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
6577         CHECK(calls->write_meth != NULL);
6578
6579         LDKType ret = {
6580                 .this_arg = (void*) calls,
6581                 .type_id = type_id_LDKType_jcall,
6582                 .debug_str = debug_str_LDKType_jcall,
6583                 .write = write_LDKType_jcall,
6584                 .cloned = LDKType_JCalls_cloned,
6585                 .free = LDKType_JCalls_free,
6586         };
6587         return ret;
6588 }
6589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
6590         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
6591         *res_ptr = LDKType_init(env, clz, o);
6592         return (uint64_t)res_ptr;
6593 }
6594 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
6595         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6596         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6597         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6598         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
6599         return ret_val;
6600 }
6601
6602 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
6603         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6604         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6605         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6606         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
6607         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
6608         Str_free(ret_str);
6609         return ret_conv;
6610 }
6611
6612 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
6613         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6614         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6615         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6616         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
6617         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6618         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6619         CVec_u8Z_free(ret_var);
6620         return ret_arr;
6621 }
6622
6623 static jclass LDKCOption_TypeZ_Some_class = NULL;
6624 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
6625 static jclass LDKCOption_TypeZ_None_class = NULL;
6626 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
6627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
6628         LDKCOption_TypeZ_Some_class =
6629                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
6630         CHECK(LDKCOption_TypeZ_Some_class != NULL);
6631         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
6632         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
6633         LDKCOption_TypeZ_None_class =
6634                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
6635         CHECK(LDKCOption_TypeZ_None_class != NULL);
6636         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
6637         CHECK(LDKCOption_TypeZ_None_meth != NULL);
6638 }
6639 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6640         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
6641         switch(obj->tag) {
6642                 case LDKCOption_TypeZ_Some: {
6643                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
6644                         *some_ret = Type_clone(&obj->some);
6645                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (int64_t)some_ret);
6646                 }
6647                 case LDKCOption_TypeZ_None: {
6648                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
6649                 }
6650                 default: abort();
6651         }
6652 }
6653 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
6654 CHECK(owner->result_ok);
6655         return COption_TypeZ_clone(&*owner->contents.result);
6656 }
6657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6658         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
6659         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
6660         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
6661         int64_t ret_ref = (uintptr_t)ret_copy;
6662         return ret_ref;
6663 }
6664
6665 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
6666 CHECK(!owner->result_ok);
6667         return DecodeError_clone(&*owner->contents.err);
6668 }
6669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6670         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
6671         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
6672         int64_t ret_ref = 0;
6673         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6674         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6676         ret_ref = (uintptr_t)ret_var.inner;
6677         if (ret_var.is_owned) {
6678                 ret_ref |= 1;
6679         }
6680         return ret_ref;
6681 }
6682
6683 static jclass LDKPaymentError_Invoice_class = NULL;
6684 static jmethodID LDKPaymentError_Invoice_meth = NULL;
6685 static jclass LDKPaymentError_Routing_class = NULL;
6686 static jmethodID LDKPaymentError_Routing_meth = NULL;
6687 static jclass LDKPaymentError_Sending_class = NULL;
6688 static jmethodID LDKPaymentError_Sending_meth = NULL;
6689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
6690         LDKPaymentError_Invoice_class =
6691                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
6692         CHECK(LDKPaymentError_Invoice_class != NULL);
6693         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
6694         CHECK(LDKPaymentError_Invoice_meth != NULL);
6695         LDKPaymentError_Routing_class =
6696                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
6697         CHECK(LDKPaymentError_Routing_class != NULL);
6698         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
6699         CHECK(LDKPaymentError_Routing_meth != NULL);
6700         LDKPaymentError_Sending_class =
6701                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
6702         CHECK(LDKPaymentError_Sending_class != NULL);
6703         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
6704         CHECK(LDKPaymentError_Sending_meth != NULL);
6705 }
6706 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6707         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6708         switch(obj->tag) {
6709                 case LDKPaymentError_Invoice: {
6710                         LDKStr invoice_str = obj->invoice;
6711                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
6712                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
6713                 }
6714                 case LDKPaymentError_Routing: {
6715                         LDKLightningError routing_var = obj->routing;
6716                         int64_t routing_ref = 0;
6717                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6718                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6719                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
6720                         routing_ref = (uintptr_t)routing_var.inner & ~1;
6721                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
6722                 }
6723                 case LDKPaymentError_Sending: {
6724                         int64_t sending_ref = ((uintptr_t)&obj->sending) | 1;
6725                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
6726                 }
6727                 default: abort();
6728         }
6729 }
6730 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6731 CHECK(owner->result_ok);
6732         return ThirtyTwoBytes_clone(&*owner->contents.result);
6733 }
6734 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6735         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6736         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6737         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
6738         return ret_arr;
6739 }
6740
6741 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6742 CHECK(!owner->result_ok);
6743         return PaymentError_clone(&*owner->contents.err);
6744 }
6745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6746         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6747         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
6748         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
6749         int64_t ret_ref = (uintptr_t)ret_copy;
6750         return ret_ref;
6751 }
6752
6753 static jclass LDKParseError_Bech32Error_class = NULL;
6754 static jmethodID LDKParseError_Bech32Error_meth = NULL;
6755 static jclass LDKParseError_ParseAmountError_class = NULL;
6756 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
6757 static jclass LDKParseError_MalformedSignature_class = NULL;
6758 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
6759 static jclass LDKParseError_BadPrefix_class = NULL;
6760 static jmethodID LDKParseError_BadPrefix_meth = NULL;
6761 static jclass LDKParseError_UnknownCurrency_class = NULL;
6762 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
6763 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
6764 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
6765 static jclass LDKParseError_MalformedHRP_class = NULL;
6766 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
6767 static jclass LDKParseError_TooShortDataPart_class = NULL;
6768 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
6769 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
6770 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
6771 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
6772 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
6773 static jclass LDKParseError_PaddingError_class = NULL;
6774 static jmethodID LDKParseError_PaddingError_meth = NULL;
6775 static jclass LDKParseError_IntegerOverflowError_class = NULL;
6776 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
6777 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
6778 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
6779 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
6780 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
6781 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
6782 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
6783 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
6784 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
6785 static jclass LDKParseError_InvalidSliceLength_class = NULL;
6786 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
6787 static jclass LDKParseError_Skip_class = NULL;
6788 static jmethodID LDKParseError_Skip_meth = NULL;
6789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
6790         LDKParseError_Bech32Error_class =
6791                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
6792         CHECK(LDKParseError_Bech32Error_class != NULL);
6793         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
6794         CHECK(LDKParseError_Bech32Error_meth != NULL);
6795         LDKParseError_ParseAmountError_class =
6796                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
6797         CHECK(LDKParseError_ParseAmountError_class != NULL);
6798         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
6799         CHECK(LDKParseError_ParseAmountError_meth != NULL);
6800         LDKParseError_MalformedSignature_class =
6801                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
6802         CHECK(LDKParseError_MalformedSignature_class != NULL);
6803         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
6804         CHECK(LDKParseError_MalformedSignature_meth != NULL);
6805         LDKParseError_BadPrefix_class =
6806                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
6807         CHECK(LDKParseError_BadPrefix_class != NULL);
6808         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
6809         CHECK(LDKParseError_BadPrefix_meth != NULL);
6810         LDKParseError_UnknownCurrency_class =
6811                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
6812         CHECK(LDKParseError_UnknownCurrency_class != NULL);
6813         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
6814         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
6815         LDKParseError_UnknownSiPrefix_class =
6816                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
6817         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
6818         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
6819         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
6820         LDKParseError_MalformedHRP_class =
6821                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
6822         CHECK(LDKParseError_MalformedHRP_class != NULL);
6823         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
6824         CHECK(LDKParseError_MalformedHRP_meth != NULL);
6825         LDKParseError_TooShortDataPart_class =
6826                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
6827         CHECK(LDKParseError_TooShortDataPart_class != NULL);
6828         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
6829         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
6830         LDKParseError_UnexpectedEndOfTaggedFields_class =
6831                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
6832         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
6833         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
6834         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
6835         LDKParseError_DescriptionDecodeError_class =
6836                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
6837         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
6838         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
6839         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
6840         LDKParseError_PaddingError_class =
6841                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
6842         CHECK(LDKParseError_PaddingError_class != NULL);
6843         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
6844         CHECK(LDKParseError_PaddingError_meth != NULL);
6845         LDKParseError_IntegerOverflowError_class =
6846                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
6847         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
6848         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
6849         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
6850         LDKParseError_InvalidSegWitProgramLength_class =
6851                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
6852         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
6853         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
6854         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
6855         LDKParseError_InvalidPubKeyHashLength_class =
6856                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
6857         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
6858         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
6859         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
6860         LDKParseError_InvalidScriptHashLength_class =
6861                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
6862         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
6863         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
6864         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
6865         LDKParseError_InvalidRecoveryId_class =
6866                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
6867         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
6868         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
6869         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
6870         LDKParseError_InvalidSliceLength_class =
6871                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
6872         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
6873         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
6874         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
6875         LDKParseError_Skip_class =
6876                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
6877         CHECK(LDKParseError_Skip_class != NULL);
6878         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
6879         CHECK(LDKParseError_Skip_meth != NULL);
6880 }
6881 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6882         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6883         switch(obj->tag) {
6884                 case LDKParseError_Bech32Error: {
6885                         int64_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
6886                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
6887                 }
6888                 case LDKParseError_ParseAmountError: {
6889                         /*obj->parse_amount_error*/
6890                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
6891                 }
6892                 case LDKParseError_MalformedSignature: {
6893                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
6894                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
6895                 }
6896                 case LDKParseError_BadPrefix: {
6897                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
6898                 }
6899                 case LDKParseError_UnknownCurrency: {
6900                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
6901                 }
6902                 case LDKParseError_UnknownSiPrefix: {
6903                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
6904                 }
6905                 case LDKParseError_MalformedHRP: {
6906                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
6907                 }
6908                 case LDKParseError_TooShortDataPart: {
6909                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
6910                 }
6911                 case LDKParseError_UnexpectedEndOfTaggedFields: {
6912                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
6913                 }
6914                 case LDKParseError_DescriptionDecodeError: {
6915                         /*obj->description_decode_error*/
6916                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
6917                 }
6918                 case LDKParseError_PaddingError: {
6919                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
6920                 }
6921                 case LDKParseError_IntegerOverflowError: {
6922                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
6923                 }
6924                 case LDKParseError_InvalidSegWitProgramLength: {
6925                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
6926                 }
6927                 case LDKParseError_InvalidPubKeyHashLength: {
6928                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
6929                 }
6930                 case LDKParseError_InvalidScriptHashLength: {
6931                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
6932                 }
6933                 case LDKParseError_InvalidRecoveryId: {
6934                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
6935                 }
6936                 case LDKParseError_InvalidSliceLength: {
6937                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
6938                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
6939                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
6940                 }
6941                 case LDKParseError_Skip: {
6942                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
6943                 }
6944                 default: abort();
6945         }
6946 }
6947 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
6948 CHECK(owner->result_ok);
6949         return SiPrefix_clone(&*owner->contents.result);
6950 }
6951 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6952         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
6953         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
6954         return ret_conv;
6955 }
6956
6957 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
6958 CHECK(!owner->result_ok);
6959         return ParseError_clone(&*owner->contents.err);
6960 }
6961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6962         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
6963         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
6964         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
6965         int64_t ret_ref = (uintptr_t)ret_copy;
6966         return ret_ref;
6967 }
6968
6969 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
6970 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
6971 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
6972 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
6973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
6974         LDKParseOrSemanticError_ParseError_class =
6975                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
6976         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
6977         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
6978         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
6979         LDKParseOrSemanticError_SemanticError_class =
6980                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
6981         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
6982         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
6983         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
6984 }
6985 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6986         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
6987         switch(obj->tag) {
6988                 case LDKParseOrSemanticError_ParseError: {
6989                         int64_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
6990                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
6991                 }
6992                 case LDKParseOrSemanticError_SemanticError: {
6993                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
6994                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
6995                 }
6996                 default: abort();
6997         }
6998 }
6999 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7000 CHECK(owner->result_ok);
7001         return Invoice_clone(&*owner->contents.result);
7002 }
7003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7004         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7005         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
7006         int64_t ret_ref = 0;
7007         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7008         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7010         ret_ref = (uintptr_t)ret_var.inner;
7011         if (ret_var.is_owned) {
7012                 ret_ref |= 1;
7013         }
7014         return ret_ref;
7015 }
7016
7017 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7018 CHECK(!owner->result_ok);
7019         return ParseOrSemanticError_clone(&*owner->contents.err);
7020 }
7021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7022         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7023         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
7024         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
7025         int64_t ret_ref = (uintptr_t)ret_copy;
7026         return ret_ref;
7027 }
7028
7029 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7030 CHECK(owner->result_ok);
7031         return SignedRawInvoice_clone(&*owner->contents.result);
7032 }
7033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7034         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7035         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
7036         int64_t ret_ref = 0;
7037         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7038         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7040         ret_ref = (uintptr_t)ret_var.inner;
7041         if (ret_var.is_owned) {
7042                 ret_ref |= 1;
7043         }
7044         return ret_ref;
7045 }
7046
7047 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7048 CHECK(!owner->result_ok);
7049         return ParseError_clone(&*owner->contents.err);
7050 }
7051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7052         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7053         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7054         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
7055         int64_t ret_ref = (uintptr_t)ret_copy;
7056         return ret_ref;
7057 }
7058
7059 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7060         return RawInvoice_clone(&owner->a);
7061 }
7062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7063         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7064         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
7065         int64_t ret_ref = 0;
7066         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7067         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7069         ret_ref = (uintptr_t)ret_var.inner;
7070         if (ret_var.is_owned) {
7071                 ret_ref |= 1;
7072         }
7073         return ret_ref;
7074 }
7075
7076 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7077         return ThirtyTwoBytes_clone(&owner->b);
7078 }
7079 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7080         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7081         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7082         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
7083         return ret_arr;
7084 }
7085
7086 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7087         return InvoiceSignature_clone(&owner->c);
7088 }
7089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
7090         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7091         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
7092         int64_t ret_ref = 0;
7093         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7094         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7096         ret_ref = (uintptr_t)ret_var.inner;
7097         if (ret_var.is_owned) {
7098                 ret_ref |= 1;
7099         }
7100         return ret_ref;
7101 }
7102
7103 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
7104 CHECK(owner->result_ok);
7105         return PayeePubKey_clone(&*owner->contents.result);
7106 }
7107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7108         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
7109         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
7110         int64_t ret_ref = 0;
7111         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7112         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7114         ret_ref = (uintptr_t)ret_var.inner;
7115         if (ret_var.is_owned) {
7116                 ret_ref |= 1;
7117         }
7118         return ret_ref;
7119 }
7120
7121 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
7122 CHECK(!owner->result_ok);
7123         return *owner->contents.err;
7124 }
7125 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7126         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
7127         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
7128         return ret_conv;
7129 }
7130
7131 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
7132         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
7133         for (size_t i = 0; i < ret.datalen; i++) {
7134                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
7135         }
7136         return ret;
7137 }
7138 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
7139 CHECK(owner->result_ok);
7140         return PositiveTimestamp_clone(&*owner->contents.result);
7141 }
7142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7143         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
7144         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
7145         int64_t ret_ref = 0;
7146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7149         ret_ref = (uintptr_t)ret_var.inner;
7150         if (ret_var.is_owned) {
7151                 ret_ref |= 1;
7152         }
7153         return ret_ref;
7154 }
7155
7156 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
7157 CHECK(!owner->result_ok);
7158         return CreationError_clone(&*owner->contents.err);
7159 }
7160 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7161         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
7162         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
7163         return ret_conv;
7164 }
7165
7166 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
7167 CHECK(owner->result_ok);
7168         return *owner->contents.result;
7169 }
7170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7171         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
7172         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
7173 }
7174
7175 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
7176 CHECK(!owner->result_ok);
7177         return SemanticError_clone(&*owner->contents.err);
7178 }
7179 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7180         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
7181         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
7182         return ret_conv;
7183 }
7184
7185 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
7186 CHECK(owner->result_ok);
7187         return Invoice_clone(&*owner->contents.result);
7188 }
7189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7190         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
7191         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
7192         int64_t ret_ref = 0;
7193         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7194         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7196         ret_ref = (uintptr_t)ret_var.inner;
7197         if (ret_var.is_owned) {
7198                 ret_ref |= 1;
7199         }
7200         return ret_ref;
7201 }
7202
7203 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
7204 CHECK(!owner->result_ok);
7205         return SemanticError_clone(&*owner->contents.err);
7206 }
7207 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7208         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
7209         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
7210         return ret_conv;
7211 }
7212
7213 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
7214 CHECK(owner->result_ok);
7215         return Description_clone(&*owner->contents.result);
7216 }
7217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7218         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
7219         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
7220         int64_t ret_ref = 0;
7221         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7222         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7224         ret_ref = (uintptr_t)ret_var.inner;
7225         if (ret_var.is_owned) {
7226                 ret_ref |= 1;
7227         }
7228         return ret_ref;
7229 }
7230
7231 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
7232 CHECK(!owner->result_ok);
7233         return CreationError_clone(&*owner->contents.err);
7234 }
7235 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7236         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
7237         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
7238         return ret_conv;
7239 }
7240
7241 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
7242 CHECK(owner->result_ok);
7243         return PrivateRoute_clone(&*owner->contents.result);
7244 }
7245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7246         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
7247         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
7248         int64_t ret_ref = 0;
7249         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7250         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7252         ret_ref = (uintptr_t)ret_var.inner;
7253         if (ret_var.is_owned) {
7254                 ret_ref |= 1;
7255         }
7256         return ret_ref;
7257 }
7258
7259 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
7260 CHECK(!owner->result_ok);
7261         return CreationError_clone(&*owner->contents.err);
7262 }
7263 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7264         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
7265         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
7266         return ret_conv;
7267 }
7268
7269 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
7270 CHECK(owner->result_ok);
7271         return *owner->contents.result;
7272 }
7273 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7274         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
7275         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
7276         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
7277         return ret_conv;
7278 }
7279
7280 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
7281 CHECK(!owner->result_ok);
7282         return *owner->contents.err;
7283 }
7284 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7285         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
7286         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
7287         return ret_conv;
7288 }
7289
7290 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
7291 CHECK(owner->result_ok);
7292         return ChannelMonitorUpdate_clone(&*owner->contents.result);
7293 }
7294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7295         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
7296         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
7297         int64_t ret_ref = 0;
7298         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7299         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7300         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7301         ret_ref = (uintptr_t)ret_var.inner;
7302         if (ret_var.is_owned) {
7303                 ret_ref |= 1;
7304         }
7305         return ret_ref;
7306 }
7307
7308 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
7309 CHECK(!owner->result_ok);
7310         return DecodeError_clone(&*owner->contents.err);
7311 }
7312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7313         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
7314         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
7315         int64_t ret_ref = 0;
7316         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7317         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7319         ret_ref = (uintptr_t)ret_var.inner;
7320         if (ret_var.is_owned) {
7321                 ret_ref |= 1;
7322         }
7323         return ret_ref;
7324 }
7325
7326 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
7327 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
7328 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
7329 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
7330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
7331         LDKCOption_MonitorEventZ_Some_class =
7332                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
7333         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
7334         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
7335         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
7336         LDKCOption_MonitorEventZ_None_class =
7337                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
7338         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
7339         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
7340         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
7341 }
7342 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7343         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
7344         switch(obj->tag) {
7345                 case LDKCOption_MonitorEventZ_Some: {
7346                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
7347                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
7348                 }
7349                 case LDKCOption_MonitorEventZ_None: {
7350                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
7351                 }
7352                 default: abort();
7353         }
7354 }
7355 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
7356 CHECK(owner->result_ok);
7357         return COption_MonitorEventZ_clone(&*owner->contents.result);
7358 }
7359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7360         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
7361         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
7362         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
7363         int64_t ret_ref = (uintptr_t)ret_copy;
7364         return ret_ref;
7365 }
7366
7367 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
7368 CHECK(!owner->result_ok);
7369         return DecodeError_clone(&*owner->contents.err);
7370 }
7371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7372         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
7373         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
7374         int64_t ret_ref = 0;
7375         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7376         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7378         ret_ref = (uintptr_t)ret_var.inner;
7379         if (ret_var.is_owned) {
7380                 ret_ref |= 1;
7381         }
7382         return ret_ref;
7383 }
7384
7385 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
7386 CHECK(owner->result_ok);
7387         return HTLCUpdate_clone(&*owner->contents.result);
7388 }
7389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7390         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
7391         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
7392         int64_t ret_ref = 0;
7393         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7394         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7396         ret_ref = (uintptr_t)ret_var.inner;
7397         if (ret_var.is_owned) {
7398                 ret_ref |= 1;
7399         }
7400         return ret_ref;
7401 }
7402
7403 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
7404 CHECK(!owner->result_ok);
7405         return DecodeError_clone(&*owner->contents.err);
7406 }
7407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7408         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
7409         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
7410         int64_t ret_ref = 0;
7411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7414         ret_ref = (uintptr_t)ret_var.inner;
7415         if (ret_var.is_owned) {
7416                 ret_ref |= 1;
7417         }
7418         return ret_ref;
7419 }
7420
7421 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
7422         return OutPoint_clone(&owner->a);
7423 }
7424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7425         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
7426         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
7427         int64_t ret_ref = 0;
7428         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7429         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7431         ret_ref = (uintptr_t)ret_var.inner;
7432         if (ret_var.is_owned) {
7433                 ret_ref |= 1;
7434         }
7435         return ret_ref;
7436 }
7437
7438 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
7439         return CVec_u8Z_clone(&owner->b);
7440 }
7441 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7442         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
7443         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
7444         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7445         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7446         CVec_u8Z_free(ret_var);
7447         return ret_arr;
7448 }
7449
7450 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
7451         return owner->a;
7452 }
7453 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7454         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
7455         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(owner_conv);
7456         return ret_val;
7457 }
7458
7459 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
7460         return CVec_u8Z_clone(&owner->b);
7461 }
7462 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7463         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
7464         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
7465         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7466         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7467         CVec_u8Z_free(ret_var);
7468         return ret_arr;
7469 }
7470
7471 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
7472         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
7473         for (size_t i = 0; i < ret.datalen; i++) {
7474                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
7475         }
7476         return ret;
7477 }
7478 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
7479         return ThirtyTwoBytes_clone(&owner->a);
7480 }
7481 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7482         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
7483         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7484         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
7485         return ret_arr;
7486 }
7487
7488 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
7489         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
7490 }
7491 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7492         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
7493         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
7494         int64_tArray ret_arr = NULL;
7495         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7496         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7497         for (size_t v = 0; v < ret_var.datalen; v++) {
7498                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
7499                 *ret_conv_21_conv = ret_var.data[v];
7500                 ret_arr_ptr[v] = ((int64_t)ret_conv_21_conv);
7501         }
7502         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7503         FREE(ret_var.data);
7504         return ret_arr;
7505 }
7506
7507 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
7508         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 };
7509         for (size_t i = 0; i < ret.datalen; i++) {
7510                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
7511         }
7512         return ret;
7513 }
7514 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
7515         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
7516         for (size_t i = 0; i < ret.datalen; i++) {
7517                 ret.data[i] = Event_clone(&orig->data[i]);
7518         }
7519         return ret;
7520 }
7521 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
7522         return owner->a;
7523 }
7524 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7525         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
7526         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(owner_conv);
7527         return ret_val;
7528 }
7529
7530 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
7531         return TxOut_clone(&owner->b);
7532 }
7533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7534         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
7535         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
7536         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
7537         return (int64_t)ret_ref;
7538 }
7539
7540 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
7541         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
7542         for (size_t i = 0; i < ret.datalen; i++) {
7543                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
7544         }
7545         return ret;
7546 }
7547 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
7548         return ThirtyTwoBytes_clone(&owner->a);
7549 }
7550 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7551         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
7552         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7553         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
7554         return ret_arr;
7555 }
7556
7557 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
7558         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
7559 }
7560 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7561         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
7562         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
7563         int64_tArray ret_arr = NULL;
7564         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7565         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7566         for (size_t u = 0; u < ret_var.datalen; u++) {
7567                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7568                 *ret_conv_20_conv = ret_var.data[u];
7569                 ret_arr_ptr[u] = ((int64_t)ret_conv_20_conv);
7570         }
7571         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7572         FREE(ret_var.data);
7573         return ret_arr;
7574 }
7575
7576 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
7577         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 };
7578         for (size_t i = 0; i < ret.datalen; i++) {
7579                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
7580         }
7581         return ret;
7582 }
7583 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
7584 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
7585 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
7586 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
7587 static jclass LDKBalance_ContentiousClaimable_class = NULL;
7588 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
7589 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
7590 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
7591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
7592         LDKBalance_ClaimableOnChannelClose_class =
7593                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
7594         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
7595         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
7596         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
7597         LDKBalance_ClaimableAwaitingConfirmations_class =
7598                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
7599         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
7600         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
7601         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
7602         LDKBalance_ContentiousClaimable_class =
7603                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
7604         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
7605         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
7606         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
7607         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
7608                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout"));
7609         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
7610         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
7611         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
7612 }
7613 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7614         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
7615         switch(obj->tag) {
7616                 case LDKBalance_ClaimableOnChannelClose: {
7617                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, obj->claimable_on_channel_close.claimable_amount_satoshis);
7618                 }
7619                 case LDKBalance_ClaimableAwaitingConfirmations: {
7620                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, obj->claimable_awaiting_confirmations.claimable_amount_satoshis, obj->claimable_awaiting_confirmations.confirmation_height);
7621                 }
7622                 case LDKBalance_ContentiousClaimable: {
7623                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, obj->contentious_claimable.claimable_amount_satoshis, obj->contentious_claimable.timeout_height);
7624                 }
7625                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
7626                         return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis, obj->maybe_claimable_htlc_awaiting_timeout.claimable_height);
7627                 }
7628                 default: abort();
7629         }
7630 }
7631 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
7632         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
7633         for (size_t i = 0; i < ret.datalen; i++) {
7634                 ret.data[i] = Balance_clone(&orig->data[i]);
7635         }
7636         return ret;
7637 }
7638 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
7639 CHECK(owner->result_ok);
7640         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
7641 }
7642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7643         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
7644         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
7645         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
7646         return ((int64_t)ret_conv);
7647 }
7648
7649 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
7650 CHECK(!owner->result_ok);
7651         return DecodeError_clone(&*owner->contents.err);
7652 }
7653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7654         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
7655         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
7656         int64_t ret_ref = 0;
7657         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7658         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7660         ret_ref = (uintptr_t)ret_var.inner;
7661         if (ret_var.is_owned) {
7662                 ret_ref |= 1;
7663         }
7664         return ret_ref;
7665 }
7666
7667 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
7668 CHECK(owner->result_ok);
7669         return *owner->contents.result;
7670 }
7671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7672         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
7673         CResult_NoneLightningErrorZ_get_ok(owner_conv);
7674 }
7675
7676 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
7677 CHECK(!owner->result_ok);
7678         return LightningError_clone(&*owner->contents.err);
7679 }
7680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7681         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
7682         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
7683         int64_t ret_ref = 0;
7684         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7685         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7687         ret_ref = (uintptr_t)ret_var.inner;
7688         if (ret_var.is_owned) {
7689                 ret_ref |= 1;
7690         }
7691         return ret_ref;
7692 }
7693
7694 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
7695         return owner->a;
7696 }
7697 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7698         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
7699         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
7700         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
7701         return ret_arr;
7702 }
7703
7704 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
7705         return Type_clone(&owner->b);
7706 }
7707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7708         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
7709         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
7710         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
7711         return (int64_t)ret_ret;
7712 }
7713
7714 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
7715         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
7716         for (size_t i = 0; i < ret.datalen; i++) {
7717                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
7718         }
7719         return ret;
7720 }
7721 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
7722 CHECK(owner->result_ok);
7723         return *owner->contents.result;
7724 }
7725 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7726         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
7727         jboolean ret_val = CResult_boolLightningErrorZ_get_ok(owner_conv);
7728         return ret_val;
7729 }
7730
7731 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
7732 CHECK(!owner->result_ok);
7733         return LightningError_clone(&*owner->contents.err);
7734 }
7735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7736         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
7737         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
7738         int64_t ret_ref = 0;
7739         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7740         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7742         ret_ref = (uintptr_t)ret_var.inner;
7743         if (ret_var.is_owned) {
7744                 ret_ref |= 1;
7745         }
7746         return ret_ref;
7747 }
7748
7749 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
7750         return ChannelAnnouncement_clone(&owner->a);
7751 }
7752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7753         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
7754         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
7755         int64_t ret_ref = 0;
7756         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7757         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7759         ret_ref = (uintptr_t)ret_var.inner;
7760         if (ret_var.is_owned) {
7761                 ret_ref |= 1;
7762         }
7763         return ret_ref;
7764 }
7765
7766 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
7767         return ChannelUpdate_clone(&owner->b);
7768 }
7769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7770         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
7771         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
7772         int64_t ret_ref = 0;
7773         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7774         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7776         ret_ref = (uintptr_t)ret_var.inner;
7777         if (ret_var.is_owned) {
7778                 ret_ref |= 1;
7779         }
7780         return ret_ref;
7781 }
7782
7783 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
7784         return ChannelUpdate_clone(&owner->c);
7785 }
7786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
7787         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
7788         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
7789         int64_t ret_ref = 0;
7790         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7791         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7793         ret_ref = (uintptr_t)ret_var.inner;
7794         if (ret_var.is_owned) {
7795                 ret_ref |= 1;
7796         }
7797         return ret_ref;
7798 }
7799
7800 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
7801         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
7802         for (size_t i = 0; i < ret.datalen; i++) {
7803                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
7804         }
7805         return ret;
7806 }
7807 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
7808         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
7809         for (size_t i = 0; i < ret.datalen; i++) {
7810                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
7811         }
7812         return ret;
7813 }
7814 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
7815 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
7816 static jclass LDKCOption_NetAddressZ_None_class = NULL;
7817 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
7818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
7819         LDKCOption_NetAddressZ_Some_class =
7820                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
7821         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
7822         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
7823         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
7824         LDKCOption_NetAddressZ_None_class =
7825                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
7826         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
7827         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
7828         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
7829 }
7830 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7831         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
7832         switch(obj->tag) {
7833                 case LDKCOption_NetAddressZ_Some: {
7834                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
7835                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
7836                 }
7837                 case LDKCOption_NetAddressZ_None: {
7838                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
7839                 }
7840                 default: abort();
7841         }
7842 }
7843 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7844 CHECK(owner->result_ok);
7845         return CVec_u8Z_clone(&*owner->contents.result);
7846 }
7847 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7848         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
7849         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
7850         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7851         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7852         CVec_u8Z_free(ret_var);
7853         return ret_arr;
7854 }
7855
7856 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7857 CHECK(!owner->result_ok);
7858         return PeerHandleError_clone(&*owner->contents.err);
7859 }
7860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7861         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
7862         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
7863         int64_t ret_ref = 0;
7864         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7865         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7867         ret_ref = (uintptr_t)ret_var.inner;
7868         if (ret_var.is_owned) {
7869                 ret_ref |= 1;
7870         }
7871         return ret_ref;
7872 }
7873
7874 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
7875 CHECK(owner->result_ok);
7876         return *owner->contents.result;
7877 }
7878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7879         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
7880         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
7881 }
7882
7883 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
7884 CHECK(!owner->result_ok);
7885         return PeerHandleError_clone(&*owner->contents.err);
7886 }
7887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7888         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
7889         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
7890         int64_t ret_ref = 0;
7891         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7892         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7894         ret_ref = (uintptr_t)ret_var.inner;
7895         if (ret_var.is_owned) {
7896                 ret_ref |= 1;
7897         }
7898         return ret_ref;
7899 }
7900
7901 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
7902 CHECK(owner->result_ok);
7903         return *owner->contents.result;
7904 }
7905 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7906         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
7907         jboolean ret_val = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
7908         return ret_val;
7909 }
7910
7911 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
7912 CHECK(!owner->result_ok);
7913         return PeerHandleError_clone(&*owner->contents.err);
7914 }
7915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7916         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
7917         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
7918         int64_t ret_ref = 0;
7919         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7920         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7922         ret_ref = (uintptr_t)ret_var.inner;
7923         if (ret_var.is_owned) {
7924                 ret_ref |= 1;
7925         }
7926         return ret_ref;
7927 }
7928
7929 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
7930 CHECK(owner->result_ok);
7931         return NodeId_clone(&*owner->contents.result);
7932 }
7933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7934         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
7935         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
7936         int64_t ret_ref = 0;
7937         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7938         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7940         ret_ref = (uintptr_t)ret_var.inner;
7941         if (ret_var.is_owned) {
7942                 ret_ref |= 1;
7943         }
7944         return ret_ref;
7945 }
7946
7947 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
7948 CHECK(!owner->result_ok);
7949         return DecodeError_clone(&*owner->contents.err);
7950 }
7951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7952         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
7953         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
7954         int64_t ret_ref = 0;
7955         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7956         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7958         ret_ref = (uintptr_t)ret_var.inner;
7959         if (ret_var.is_owned) {
7960                 ret_ref |= 1;
7961         }
7962         return ret_ref;
7963 }
7964
7965 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
7966 CHECK(owner->result_ok);
7967         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
7968 }
7969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7970         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
7971         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
7972         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
7973         int64_t ret_ref = (uintptr_t)ret_copy;
7974         return ret_ref;
7975 }
7976
7977 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
7978 CHECK(!owner->result_ok);
7979         return DecodeError_clone(&*owner->contents.err);
7980 }
7981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7982         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
7983         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
7984         int64_t ret_ref = 0;
7985         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7986         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7988         ret_ref = (uintptr_t)ret_var.inner;
7989         if (ret_var.is_owned) {
7990                 ret_ref |= 1;
7991         }
7992         return ret_ref;
7993 }
7994
7995 typedef struct LDKAccess_JCalls {
7996         atomic_size_t refcnt;
7997         JavaVM *vm;
7998         jweak o;
7999         jmethodID get_utxo_meth;
8000 } LDKAccess_JCalls;
8001 static void LDKAccess_JCalls_free(void* this_arg) {
8002         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
8003         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8004                 JNIEnv *env;
8005                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8006                 if (get_jenv_res == JNI_EDETACHED) {
8007                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8008                 } else {
8009                         DO_ASSERT(get_jenv_res == JNI_OK);
8010                 }
8011                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8012                 if (get_jenv_res == JNI_EDETACHED) {
8013                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8014                 }
8015                 FREE(j_calls);
8016         }
8017 }
8018 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
8019         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
8020         JNIEnv *env;
8021         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8022         if (get_jenv_res == JNI_EDETACHED) {
8023                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8024         } else {
8025                 DO_ASSERT(get_jenv_res == JNI_OK);
8026         }
8027         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
8028         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
8029         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8030         CHECK(obj != NULL);
8031         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
8032         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8033                 (*env)->ExceptionDescribe(env);
8034                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
8035         }
8036         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8037         CHECK_ACCESS(ret_ptr);
8038         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
8039         FREE((void*)ret);
8040         if (get_jenv_res == JNI_EDETACHED) {
8041                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8042         }
8043         return ret_conv;
8044 }
8045 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
8046         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
8047         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8048 }
8049 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
8050         jclass c = (*env)->GetObjectClass(env, o);
8051         CHECK(c != NULL);
8052         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
8053         atomic_init(&calls->refcnt, 1);
8054         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8055         calls->o = (*env)->NewWeakGlobalRef(env, o);
8056         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
8057         CHECK(calls->get_utxo_meth != NULL);
8058
8059         LDKAccess ret = {
8060                 .this_arg = (void*) calls,
8061                 .get_utxo = get_utxo_LDKAccess_jcall,
8062                 .free = LDKAccess_JCalls_free,
8063         };
8064         return ret;
8065 }
8066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
8067         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
8068         *res_ptr = LDKAccess_init(env, clz, o);
8069         return (uint64_t)res_ptr;
8070 }
8071 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) {
8072         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8073         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8074         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
8075         unsigned char genesis_hash_arr[32];
8076         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
8077         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
8078         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
8079         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8080         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
8081         return (int64_t)ret_conv;
8082 }
8083
8084 static jclass LDKCOption_AccessZ_Some_class = NULL;
8085 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
8086 static jclass LDKCOption_AccessZ_None_class = NULL;
8087 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
8088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
8089         LDKCOption_AccessZ_Some_class =
8090                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
8091         CHECK(LDKCOption_AccessZ_Some_class != NULL);
8092         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
8093         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
8094         LDKCOption_AccessZ_None_class =
8095                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
8096         CHECK(LDKCOption_AccessZ_None_class != NULL);
8097         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
8098         CHECK(LDKCOption_AccessZ_None_meth != NULL);
8099 }
8100 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8101         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
8102         switch(obj->tag) {
8103                 case LDKCOption_AccessZ_Some: {
8104                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
8105                         *some_ret = obj->some;
8106                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
8107                         if ((*some_ret).free == LDKAccess_JCalls_free) {
8108                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8109                                 LDKAccess_JCalls_cloned(&(*some_ret));
8110                         }
8111                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (int64_t)some_ret);
8112                 }
8113                 case LDKCOption_AccessZ_None: {
8114                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
8115                 }
8116                 default: abort();
8117         }
8118 }
8119 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
8120 CHECK(owner->result_ok);
8121         return ChannelUpdateInfo_clone(&*owner->contents.result);
8122 }
8123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8124         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
8125         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
8126         int64_t ret_ref = 0;
8127         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8128         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8129         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8130         ret_ref = (uintptr_t)ret_var.inner;
8131         if (ret_var.is_owned) {
8132                 ret_ref |= 1;
8133         }
8134         return ret_ref;
8135 }
8136
8137 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
8138 CHECK(!owner->result_ok);
8139         return DecodeError_clone(&*owner->contents.err);
8140 }
8141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8142         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
8143         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
8144         int64_t ret_ref = 0;
8145         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8146         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8148         ret_ref = (uintptr_t)ret_var.inner;
8149         if (ret_var.is_owned) {
8150                 ret_ref |= 1;
8151         }
8152         return ret_ref;
8153 }
8154
8155 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
8156 CHECK(owner->result_ok);
8157         return ChannelInfo_clone(&*owner->contents.result);
8158 }
8159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8160         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
8161         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
8162         int64_t ret_ref = 0;
8163         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8164         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8166         ret_ref = (uintptr_t)ret_var.inner;
8167         if (ret_var.is_owned) {
8168                 ret_ref |= 1;
8169         }
8170         return ret_ref;
8171 }
8172
8173 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
8174 CHECK(!owner->result_ok);
8175         return DecodeError_clone(&*owner->contents.err);
8176 }
8177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8178         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
8179         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
8180         int64_t ret_ref = 0;
8181         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8182         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8184         ret_ref = (uintptr_t)ret_var.inner;
8185         if (ret_var.is_owned) {
8186                 ret_ref |= 1;
8187         }
8188         return ret_ref;
8189 }
8190
8191 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
8192 CHECK(owner->result_ok);
8193         return RoutingFees_clone(&*owner->contents.result);
8194 }
8195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8196         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
8197         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
8198         int64_t ret_ref = 0;
8199         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8200         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8202         ret_ref = (uintptr_t)ret_var.inner;
8203         if (ret_var.is_owned) {
8204                 ret_ref |= 1;
8205         }
8206         return ret_ref;
8207 }
8208
8209 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
8210 CHECK(!owner->result_ok);
8211         return DecodeError_clone(&*owner->contents.err);
8212 }
8213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8214         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
8215         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
8216         int64_t ret_ref = 0;
8217         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8218         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8219         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8220         ret_ref = (uintptr_t)ret_var.inner;
8221         if (ret_var.is_owned) {
8222                 ret_ref |= 1;
8223         }
8224         return ret_ref;
8225 }
8226
8227 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
8228 CHECK(owner->result_ok);
8229         return NodeAnnouncementInfo_clone(&*owner->contents.result);
8230 }
8231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8232         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
8233         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
8234         int64_t ret_ref = 0;
8235         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8236         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8238         ret_ref = (uintptr_t)ret_var.inner;
8239         if (ret_var.is_owned) {
8240                 ret_ref |= 1;
8241         }
8242         return ret_ref;
8243 }
8244
8245 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
8246 CHECK(!owner->result_ok);
8247         return DecodeError_clone(&*owner->contents.err);
8248 }
8249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8250         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
8251         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
8252         int64_t ret_ref = 0;
8253         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8254         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8256         ret_ref = (uintptr_t)ret_var.inner;
8257         if (ret_var.is_owned) {
8258                 ret_ref |= 1;
8259         }
8260         return ret_ref;
8261 }
8262
8263 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
8264         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
8265         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
8266         return ret;
8267 }
8268 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
8269 CHECK(owner->result_ok);
8270         return NodeInfo_clone(&*owner->contents.result);
8271 }
8272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8273         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
8274         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
8275         int64_t ret_ref = 0;
8276         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8277         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8279         ret_ref = (uintptr_t)ret_var.inner;
8280         if (ret_var.is_owned) {
8281                 ret_ref |= 1;
8282         }
8283         return ret_ref;
8284 }
8285
8286 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
8287 CHECK(!owner->result_ok);
8288         return DecodeError_clone(&*owner->contents.err);
8289 }
8290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8291         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
8292         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
8293         int64_t ret_ref = 0;
8294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8297         ret_ref = (uintptr_t)ret_var.inner;
8298         if (ret_var.is_owned) {
8299                 ret_ref |= 1;
8300         }
8301         return ret_ref;
8302 }
8303
8304 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
8305 CHECK(owner->result_ok);
8306         return NetworkGraph_clone(&*owner->contents.result);
8307 }
8308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8309         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
8310         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
8311         int64_t ret_ref = 0;
8312         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8313         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8315         ret_ref = (uintptr_t)ret_var.inner;
8316         if (ret_var.is_owned) {
8317                 ret_ref |= 1;
8318         }
8319         return ret_ref;
8320 }
8321
8322 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
8323 CHECK(!owner->result_ok);
8324         return DecodeError_clone(&*owner->contents.err);
8325 }
8326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8327         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
8328         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
8329         int64_t ret_ref = 0;
8330         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8331         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8333         ret_ref = (uintptr_t)ret_var.inner;
8334         if (ret_var.is_owned) {
8335                 ret_ref |= 1;
8336         }
8337         return ret_ref;
8338 }
8339
8340 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
8341 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
8342 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
8343 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
8344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
8345         LDKCOption_CVec_NetAddressZZ_Some_class =
8346                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
8347         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
8348         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
8349         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
8350         LDKCOption_CVec_NetAddressZZ_None_class =
8351                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
8352         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
8353         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
8354         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
8355 }
8356 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8357         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
8358         switch(obj->tag) {
8359                 case LDKCOption_CVec_NetAddressZZ_Some: {
8360                         LDKCVec_NetAddressZ some_var = obj->some;
8361                         int64_tArray some_arr = NULL;
8362                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
8363                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
8364                         for (size_t m = 0; m < some_var.datalen; m++) {
8365                                 int64_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
8366                                 some_arr_ptr[m] = some_conv_12_ref;
8367                         }
8368                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
8369                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
8370                 }
8371                 case LDKCOption_CVec_NetAddressZZ_None: {
8372                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
8373                 }
8374                 default: abort();
8375         }
8376 }
8377 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8378 CHECK(owner->result_ok);
8379         return NetAddress_clone(&*owner->contents.result);
8380 }
8381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8382         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8383         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
8384         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
8385         int64_t ret_ref = (uintptr_t)ret_copy;
8386         return ret_ref;
8387 }
8388
8389 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8390 CHECK(!owner->result_ok);
8391         return DecodeError_clone(&*owner->contents.err);
8392 }
8393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8394         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8395         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
8396         int64_t ret_ref = 0;
8397         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8398         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8400         ret_ref = (uintptr_t)ret_var.inner;
8401         if (ret_var.is_owned) {
8402                 ret_ref |= 1;
8403         }
8404         return ret_ref;
8405 }
8406
8407 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
8408         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
8409         for (size_t i = 0; i < ret.datalen; i++) {
8410                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
8411         }
8412         return ret;
8413 }
8414 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
8415         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
8416         for (size_t i = 0; i < ret.datalen; i++) {
8417                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
8418         }
8419         return ret;
8420 }
8421 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
8422         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
8423         for (size_t i = 0; i < ret.datalen; i++) {
8424                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
8425         }
8426         return ret;
8427 }
8428 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
8429         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
8430         for (size_t i = 0; i < ret.datalen; i++) {
8431                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
8432         }
8433         return ret;
8434 }
8435 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8436 CHECK(owner->result_ok);
8437         return AcceptChannel_clone(&*owner->contents.result);
8438 }
8439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8440         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8441         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
8442         int64_t ret_ref = 0;
8443         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8444         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8446         ret_ref = (uintptr_t)ret_var.inner;
8447         if (ret_var.is_owned) {
8448                 ret_ref |= 1;
8449         }
8450         return ret_ref;
8451 }
8452
8453 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8454 CHECK(!owner->result_ok);
8455         return DecodeError_clone(&*owner->contents.err);
8456 }
8457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8458         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8459         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
8460         int64_t ret_ref = 0;
8461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8464         ret_ref = (uintptr_t)ret_var.inner;
8465         if (ret_var.is_owned) {
8466                 ret_ref |= 1;
8467         }
8468         return ret_ref;
8469 }
8470
8471 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8472 CHECK(owner->result_ok);
8473         return AnnouncementSignatures_clone(&*owner->contents.result);
8474 }
8475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8476         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8477         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
8478         int64_t ret_ref = 0;
8479         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8480         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8482         ret_ref = (uintptr_t)ret_var.inner;
8483         if (ret_var.is_owned) {
8484                 ret_ref |= 1;
8485         }
8486         return ret_ref;
8487 }
8488
8489 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8490 CHECK(!owner->result_ok);
8491         return DecodeError_clone(&*owner->contents.err);
8492 }
8493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8494         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8495         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
8496         int64_t ret_ref = 0;
8497         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8498         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8499         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8500         ret_ref = (uintptr_t)ret_var.inner;
8501         if (ret_var.is_owned) {
8502                 ret_ref |= 1;
8503         }
8504         return ret_ref;
8505 }
8506
8507 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8508 CHECK(owner->result_ok);
8509         return ChannelReestablish_clone(&*owner->contents.result);
8510 }
8511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8512         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8513         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(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 struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8526 CHECK(!owner->result_ok);
8527         return DecodeError_clone(&*owner->contents.err);
8528 }
8529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8530         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8531         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
8532         int64_t ret_ref = 0;
8533         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8534         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8536         ret_ref = (uintptr_t)ret_var.inner;
8537         if (ret_var.is_owned) {
8538                 ret_ref |= 1;
8539         }
8540         return ret_ref;
8541 }
8542
8543 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8544 CHECK(owner->result_ok);
8545         return ClosingSigned_clone(&*owner->contents.result);
8546 }
8547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8548         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8549         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
8550         int64_t ret_ref = 0;
8551         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8552         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8554         ret_ref = (uintptr_t)ret_var.inner;
8555         if (ret_var.is_owned) {
8556                 ret_ref |= 1;
8557         }
8558         return ret_ref;
8559 }
8560
8561 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8562 CHECK(!owner->result_ok);
8563         return DecodeError_clone(&*owner->contents.err);
8564 }
8565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8566         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8567         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
8568         int64_t ret_ref = 0;
8569         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8570         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8571         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8572         ret_ref = (uintptr_t)ret_var.inner;
8573         if (ret_var.is_owned) {
8574                 ret_ref |= 1;
8575         }
8576         return ret_ref;
8577 }
8578
8579 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8580 CHECK(owner->result_ok);
8581         return ClosingSignedFeeRange_clone(&*owner->contents.result);
8582 }
8583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8584         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
8585         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
8586         int64_t ret_ref = 0;
8587         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8588         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8590         ret_ref = (uintptr_t)ret_var.inner;
8591         if (ret_var.is_owned) {
8592                 ret_ref |= 1;
8593         }
8594         return ret_ref;
8595 }
8596
8597 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8598 CHECK(!owner->result_ok);
8599         return DecodeError_clone(&*owner->contents.err);
8600 }
8601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8602         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
8603         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
8604         int64_t ret_ref = 0;
8605         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8606         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8608         ret_ref = (uintptr_t)ret_var.inner;
8609         if (ret_var.is_owned) {
8610                 ret_ref |= 1;
8611         }
8612         return ret_ref;
8613 }
8614
8615 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8616 CHECK(owner->result_ok);
8617         return CommitmentSigned_clone(&*owner->contents.result);
8618 }
8619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8620         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
8621         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
8622         int64_t ret_ref = 0;
8623         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8624         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8626         ret_ref = (uintptr_t)ret_var.inner;
8627         if (ret_var.is_owned) {
8628                 ret_ref |= 1;
8629         }
8630         return ret_ref;
8631 }
8632
8633 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8634 CHECK(!owner->result_ok);
8635         return DecodeError_clone(&*owner->contents.err);
8636 }
8637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8638         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
8639         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
8640         int64_t ret_ref = 0;
8641         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8642         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8643         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8644         ret_ref = (uintptr_t)ret_var.inner;
8645         if (ret_var.is_owned) {
8646                 ret_ref |= 1;
8647         }
8648         return ret_ref;
8649 }
8650
8651 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8652 CHECK(owner->result_ok);
8653         return FundingCreated_clone(&*owner->contents.result);
8654 }
8655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8656         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
8657         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
8658         int64_t ret_ref = 0;
8659         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8660         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8661         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8662         ret_ref = (uintptr_t)ret_var.inner;
8663         if (ret_var.is_owned) {
8664                 ret_ref |= 1;
8665         }
8666         return ret_ref;
8667 }
8668
8669 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8670 CHECK(!owner->result_ok);
8671         return DecodeError_clone(&*owner->contents.err);
8672 }
8673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8674         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
8675         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
8676         int64_t ret_ref = 0;
8677         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8678         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8680         ret_ref = (uintptr_t)ret_var.inner;
8681         if (ret_var.is_owned) {
8682                 ret_ref |= 1;
8683         }
8684         return ret_ref;
8685 }
8686
8687 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8688 CHECK(owner->result_ok);
8689         return FundingSigned_clone(&*owner->contents.result);
8690 }
8691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8692         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
8693         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
8694         int64_t ret_ref = 0;
8695         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8696         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8698         ret_ref = (uintptr_t)ret_var.inner;
8699         if (ret_var.is_owned) {
8700                 ret_ref |= 1;
8701         }
8702         return ret_ref;
8703 }
8704
8705 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8706 CHECK(!owner->result_ok);
8707         return DecodeError_clone(&*owner->contents.err);
8708 }
8709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8710         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
8711         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
8712         int64_t ret_ref = 0;
8713         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8714         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8715         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8716         ret_ref = (uintptr_t)ret_var.inner;
8717         if (ret_var.is_owned) {
8718                 ret_ref |= 1;
8719         }
8720         return ret_ref;
8721 }
8722
8723 static inline struct LDKFundingLocked CResult_FundingLockedDecodeErrorZ_get_ok(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
8724 CHECK(owner->result_ok);
8725         return FundingLocked_clone(&*owner->contents.result);
8726 }
8727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8728         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
8729         LDKFundingLocked ret_var = CResult_FundingLockedDecodeErrorZ_get_ok(owner_conv);
8730         int64_t ret_ref = 0;
8731         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8732         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8734         ret_ref = (uintptr_t)ret_var.inner;
8735         if (ret_var.is_owned) {
8736                 ret_ref |= 1;
8737         }
8738         return ret_ref;
8739 }
8740
8741 static inline struct LDKDecodeError CResult_FundingLockedDecodeErrorZ_get_err(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
8742 CHECK(!owner->result_ok);
8743         return DecodeError_clone(&*owner->contents.err);
8744 }
8745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8746         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
8747         LDKDecodeError ret_var = CResult_FundingLockedDecodeErrorZ_get_err(owner_conv);
8748         int64_t ret_ref = 0;
8749         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8750         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8752         ret_ref = (uintptr_t)ret_var.inner;
8753         if (ret_var.is_owned) {
8754                 ret_ref |= 1;
8755         }
8756         return ret_ref;
8757 }
8758
8759 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8760 CHECK(owner->result_ok);
8761         return Init_clone(&*owner->contents.result);
8762 }
8763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8764         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
8765         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
8766         int64_t ret_ref = 0;
8767         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8768         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8770         ret_ref = (uintptr_t)ret_var.inner;
8771         if (ret_var.is_owned) {
8772                 ret_ref |= 1;
8773         }
8774         return ret_ref;
8775 }
8776
8777 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8778 CHECK(!owner->result_ok);
8779         return DecodeError_clone(&*owner->contents.err);
8780 }
8781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8782         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
8783         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
8784         int64_t ret_ref = 0;
8785         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8786         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8787         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8788         ret_ref = (uintptr_t)ret_var.inner;
8789         if (ret_var.is_owned) {
8790                 ret_ref |= 1;
8791         }
8792         return ret_ref;
8793 }
8794
8795 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8796 CHECK(owner->result_ok);
8797         return OpenChannel_clone(&*owner->contents.result);
8798 }
8799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8800         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
8801         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
8802         int64_t ret_ref = 0;
8803         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8804         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8806         ret_ref = (uintptr_t)ret_var.inner;
8807         if (ret_var.is_owned) {
8808                 ret_ref |= 1;
8809         }
8810         return ret_ref;
8811 }
8812
8813 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8814 CHECK(!owner->result_ok);
8815         return DecodeError_clone(&*owner->contents.err);
8816 }
8817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8818         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
8819         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
8820         int64_t ret_ref = 0;
8821         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8822         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8824         ret_ref = (uintptr_t)ret_var.inner;
8825         if (ret_var.is_owned) {
8826                 ret_ref |= 1;
8827         }
8828         return ret_ref;
8829 }
8830
8831 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8832 CHECK(owner->result_ok);
8833         return RevokeAndACK_clone(&*owner->contents.result);
8834 }
8835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8836         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
8837         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
8838         int64_t ret_ref = 0;
8839         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8840         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8841         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8842         ret_ref = (uintptr_t)ret_var.inner;
8843         if (ret_var.is_owned) {
8844                 ret_ref |= 1;
8845         }
8846         return ret_ref;
8847 }
8848
8849 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8850 CHECK(!owner->result_ok);
8851         return DecodeError_clone(&*owner->contents.err);
8852 }
8853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8854         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
8855         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
8856         int64_t ret_ref = 0;
8857         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8858         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8860         ret_ref = (uintptr_t)ret_var.inner;
8861         if (ret_var.is_owned) {
8862                 ret_ref |= 1;
8863         }
8864         return ret_ref;
8865 }
8866
8867 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8868 CHECK(owner->result_ok);
8869         return Shutdown_clone(&*owner->contents.result);
8870 }
8871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8872         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
8873         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
8874         int64_t ret_ref = 0;
8875         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8876         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8877         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8878         ret_ref = (uintptr_t)ret_var.inner;
8879         if (ret_var.is_owned) {
8880                 ret_ref |= 1;
8881         }
8882         return ret_ref;
8883 }
8884
8885 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8886 CHECK(!owner->result_ok);
8887         return DecodeError_clone(&*owner->contents.err);
8888 }
8889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8890         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
8891         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
8892         int64_t ret_ref = 0;
8893         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8894         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8896         ret_ref = (uintptr_t)ret_var.inner;
8897         if (ret_var.is_owned) {
8898                 ret_ref |= 1;
8899         }
8900         return ret_ref;
8901 }
8902
8903 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8904 CHECK(owner->result_ok);
8905         return UpdateFailHTLC_clone(&*owner->contents.result);
8906 }
8907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8908         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
8909         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
8910         int64_t ret_ref = 0;
8911         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8912         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8914         ret_ref = (uintptr_t)ret_var.inner;
8915         if (ret_var.is_owned) {
8916                 ret_ref |= 1;
8917         }
8918         return ret_ref;
8919 }
8920
8921 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8922 CHECK(!owner->result_ok);
8923         return DecodeError_clone(&*owner->contents.err);
8924 }
8925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8926         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
8927         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
8928         int64_t ret_ref = 0;
8929         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8930         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8932         ret_ref = (uintptr_t)ret_var.inner;
8933         if (ret_var.is_owned) {
8934                 ret_ref |= 1;
8935         }
8936         return ret_ref;
8937 }
8938
8939 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
8940 CHECK(owner->result_ok);
8941         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
8942 }
8943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8944         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
8945         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
8946         int64_t ret_ref = 0;
8947         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8948         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8950         ret_ref = (uintptr_t)ret_var.inner;
8951         if (ret_var.is_owned) {
8952                 ret_ref |= 1;
8953         }
8954         return ret_ref;
8955 }
8956
8957 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
8958 CHECK(!owner->result_ok);
8959         return DecodeError_clone(&*owner->contents.err);
8960 }
8961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8962         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
8963         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
8964         int64_t ret_ref = 0;
8965         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8966         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8968         ret_ref = (uintptr_t)ret_var.inner;
8969         if (ret_var.is_owned) {
8970                 ret_ref |= 1;
8971         }
8972         return ret_ref;
8973 }
8974
8975 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
8976 CHECK(owner->result_ok);
8977         return UpdateFee_clone(&*owner->contents.result);
8978 }
8979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8980         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
8981         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
8982         int64_t ret_ref = 0;
8983         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8984         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8986         ret_ref = (uintptr_t)ret_var.inner;
8987         if (ret_var.is_owned) {
8988                 ret_ref |= 1;
8989         }
8990         return ret_ref;
8991 }
8992
8993 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
8994 CHECK(!owner->result_ok);
8995         return DecodeError_clone(&*owner->contents.err);
8996 }
8997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8998         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
8999         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
9000         int64_t ret_ref = 0;
9001         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9002         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9004         ret_ref = (uintptr_t)ret_var.inner;
9005         if (ret_var.is_owned) {
9006                 ret_ref |= 1;
9007         }
9008         return ret_ref;
9009 }
9010
9011 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9012 CHECK(owner->result_ok);
9013         return UpdateFulfillHTLC_clone(&*owner->contents.result);
9014 }
9015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9016         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9017         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
9018         int64_t ret_ref = 0;
9019         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9020         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9021         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9022         ret_ref = (uintptr_t)ret_var.inner;
9023         if (ret_var.is_owned) {
9024                 ret_ref |= 1;
9025         }
9026         return ret_ref;
9027 }
9028
9029 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9030 CHECK(!owner->result_ok);
9031         return DecodeError_clone(&*owner->contents.err);
9032 }
9033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9034         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9035         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
9036         int64_t ret_ref = 0;
9037         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9038         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9040         ret_ref = (uintptr_t)ret_var.inner;
9041         if (ret_var.is_owned) {
9042                 ret_ref |= 1;
9043         }
9044         return ret_ref;
9045 }
9046
9047 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9048 CHECK(owner->result_ok);
9049         return UpdateAddHTLC_clone(&*owner->contents.result);
9050 }
9051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9052         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9053         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
9054         int64_t ret_ref = 0;
9055         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9056         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9058         ret_ref = (uintptr_t)ret_var.inner;
9059         if (ret_var.is_owned) {
9060                 ret_ref |= 1;
9061         }
9062         return ret_ref;
9063 }
9064
9065 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9066 CHECK(!owner->result_ok);
9067         return DecodeError_clone(&*owner->contents.err);
9068 }
9069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9070         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9071         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
9072         int64_t ret_ref = 0;
9073         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9074         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9076         ret_ref = (uintptr_t)ret_var.inner;
9077         if (ret_var.is_owned) {
9078                 ret_ref |= 1;
9079         }
9080         return ret_ref;
9081 }
9082
9083 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9084 CHECK(owner->result_ok);
9085         return Ping_clone(&*owner->contents.result);
9086 }
9087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9088         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9089         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
9090         int64_t ret_ref = 0;
9091         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9092         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9094         ret_ref = (uintptr_t)ret_var.inner;
9095         if (ret_var.is_owned) {
9096                 ret_ref |= 1;
9097         }
9098         return ret_ref;
9099 }
9100
9101 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9102 CHECK(!owner->result_ok);
9103         return DecodeError_clone(&*owner->contents.err);
9104 }
9105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9106         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9107         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
9108         int64_t ret_ref = 0;
9109         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9110         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9112         ret_ref = (uintptr_t)ret_var.inner;
9113         if (ret_var.is_owned) {
9114                 ret_ref |= 1;
9115         }
9116         return ret_ref;
9117 }
9118
9119 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9120 CHECK(owner->result_ok);
9121         return Pong_clone(&*owner->contents.result);
9122 }
9123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9124         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9125         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
9126         int64_t ret_ref = 0;
9127         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9128         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9129         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9130         ret_ref = (uintptr_t)ret_var.inner;
9131         if (ret_var.is_owned) {
9132                 ret_ref |= 1;
9133         }
9134         return ret_ref;
9135 }
9136
9137 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9138 CHECK(!owner->result_ok);
9139         return DecodeError_clone(&*owner->contents.err);
9140 }
9141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9142         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9143         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
9144         int64_t ret_ref = 0;
9145         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9146         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9148         ret_ref = (uintptr_t)ret_var.inner;
9149         if (ret_var.is_owned) {
9150                 ret_ref |= 1;
9151         }
9152         return ret_ref;
9153 }
9154
9155 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9156 CHECK(owner->result_ok);
9157         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
9158 }
9159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9160         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9161         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9162         int64_t ret_ref = 0;
9163         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9164         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9166         ret_ref = (uintptr_t)ret_var.inner;
9167         if (ret_var.is_owned) {
9168                 ret_ref |= 1;
9169         }
9170         return ret_ref;
9171 }
9172
9173 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9174 CHECK(!owner->result_ok);
9175         return DecodeError_clone(&*owner->contents.err);
9176 }
9177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9178         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9179         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9180         int64_t ret_ref = 0;
9181         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9182         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9184         ret_ref = (uintptr_t)ret_var.inner;
9185         if (ret_var.is_owned) {
9186                 ret_ref |= 1;
9187         }
9188         return ret_ref;
9189 }
9190
9191 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9192 CHECK(owner->result_ok);
9193         return ChannelAnnouncement_clone(&*owner->contents.result);
9194 }
9195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9196         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9197         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9198         int64_t ret_ref = 0;
9199         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9200         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9202         ret_ref = (uintptr_t)ret_var.inner;
9203         if (ret_var.is_owned) {
9204                 ret_ref |= 1;
9205         }
9206         return ret_ref;
9207 }
9208
9209 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9210 CHECK(!owner->result_ok);
9211         return DecodeError_clone(&*owner->contents.err);
9212 }
9213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9214         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9215         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9216         int64_t ret_ref = 0;
9217         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9218         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9219         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9220         ret_ref = (uintptr_t)ret_var.inner;
9221         if (ret_var.is_owned) {
9222                 ret_ref |= 1;
9223         }
9224         return ret_ref;
9225 }
9226
9227 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9228 CHECK(owner->result_ok);
9229         return UnsignedChannelUpdate_clone(&*owner->contents.result);
9230 }
9231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9232         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9233         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9234         int64_t ret_ref = 0;
9235         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9236         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9238         ret_ref = (uintptr_t)ret_var.inner;
9239         if (ret_var.is_owned) {
9240                 ret_ref |= 1;
9241         }
9242         return ret_ref;
9243 }
9244
9245 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9246 CHECK(!owner->result_ok);
9247         return DecodeError_clone(&*owner->contents.err);
9248 }
9249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9250         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9251         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
9252         int64_t ret_ref = 0;
9253         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9254         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9256         ret_ref = (uintptr_t)ret_var.inner;
9257         if (ret_var.is_owned) {
9258                 ret_ref |= 1;
9259         }
9260         return ret_ref;
9261 }
9262
9263 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9264 CHECK(owner->result_ok);
9265         return ChannelUpdate_clone(&*owner->contents.result);
9266 }
9267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9268         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9269         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9270         int64_t ret_ref = 0;
9271         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9272         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9273         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9274         ret_ref = (uintptr_t)ret_var.inner;
9275         if (ret_var.is_owned) {
9276                 ret_ref |= 1;
9277         }
9278         return ret_ref;
9279 }
9280
9281 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9282 CHECK(!owner->result_ok);
9283         return DecodeError_clone(&*owner->contents.err);
9284 }
9285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9286         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9287         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
9288         int64_t ret_ref = 0;
9289         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9290         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9292         ret_ref = (uintptr_t)ret_var.inner;
9293         if (ret_var.is_owned) {
9294                 ret_ref |= 1;
9295         }
9296         return ret_ref;
9297 }
9298
9299 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9300 CHECK(owner->result_ok);
9301         return ErrorMessage_clone(&*owner->contents.result);
9302 }
9303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9304         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9305         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
9306         int64_t ret_ref = 0;
9307         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9308         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9309         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9310         ret_ref = (uintptr_t)ret_var.inner;
9311         if (ret_var.is_owned) {
9312                 ret_ref |= 1;
9313         }
9314         return ret_ref;
9315 }
9316
9317 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9318 CHECK(!owner->result_ok);
9319         return DecodeError_clone(&*owner->contents.err);
9320 }
9321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9322         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9323         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
9324         int64_t ret_ref = 0;
9325         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9326         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9328         ret_ref = (uintptr_t)ret_var.inner;
9329         if (ret_var.is_owned) {
9330                 ret_ref |= 1;
9331         }
9332         return ret_ref;
9333 }
9334
9335 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9336 CHECK(owner->result_ok);
9337         return WarningMessage_clone(&*owner->contents.result);
9338 }
9339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9340         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9341         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
9342         int64_t ret_ref = 0;
9343         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9344         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9345         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9346         ret_ref = (uintptr_t)ret_var.inner;
9347         if (ret_var.is_owned) {
9348                 ret_ref |= 1;
9349         }
9350         return ret_ref;
9351 }
9352
9353 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9354 CHECK(!owner->result_ok);
9355         return DecodeError_clone(&*owner->contents.err);
9356 }
9357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9358         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9359         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
9360         int64_t ret_ref = 0;
9361         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9362         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9364         ret_ref = (uintptr_t)ret_var.inner;
9365         if (ret_var.is_owned) {
9366                 ret_ref |= 1;
9367         }
9368         return ret_ref;
9369 }
9370
9371 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9372 CHECK(owner->result_ok);
9373         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
9374 }
9375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9376         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9377         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9378         int64_t ret_ref = 0;
9379         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9380         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9381         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9382         ret_ref = (uintptr_t)ret_var.inner;
9383         if (ret_var.is_owned) {
9384                 ret_ref |= 1;
9385         }
9386         return ret_ref;
9387 }
9388
9389 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9390 CHECK(!owner->result_ok);
9391         return DecodeError_clone(&*owner->contents.err);
9392 }
9393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9394         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9395         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9396         int64_t ret_ref = 0;
9397         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9398         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9400         ret_ref = (uintptr_t)ret_var.inner;
9401         if (ret_var.is_owned) {
9402                 ret_ref |= 1;
9403         }
9404         return ret_ref;
9405 }
9406
9407 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9408 CHECK(owner->result_ok);
9409         return NodeAnnouncement_clone(&*owner->contents.result);
9410 }
9411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9412         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9413         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9414         int64_t ret_ref = 0;
9415         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9416         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9418         ret_ref = (uintptr_t)ret_var.inner;
9419         if (ret_var.is_owned) {
9420                 ret_ref |= 1;
9421         }
9422         return ret_ref;
9423 }
9424
9425 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9426 CHECK(!owner->result_ok);
9427         return DecodeError_clone(&*owner->contents.err);
9428 }
9429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9430         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9431         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9432         int64_t ret_ref = 0;
9433         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9434         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9436         ret_ref = (uintptr_t)ret_var.inner;
9437         if (ret_var.is_owned) {
9438                 ret_ref |= 1;
9439         }
9440         return ret_ref;
9441 }
9442
9443 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9444 CHECK(owner->result_ok);
9445         return QueryShortChannelIds_clone(&*owner->contents.result);
9446 }
9447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9448         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9449         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
9450         int64_t ret_ref = 0;
9451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9454         ret_ref = (uintptr_t)ret_var.inner;
9455         if (ret_var.is_owned) {
9456                 ret_ref |= 1;
9457         }
9458         return ret_ref;
9459 }
9460
9461 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9462 CHECK(!owner->result_ok);
9463         return DecodeError_clone(&*owner->contents.err);
9464 }
9465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9466         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9467         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
9468         int64_t ret_ref = 0;
9469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9472         ret_ref = (uintptr_t)ret_var.inner;
9473         if (ret_var.is_owned) {
9474                 ret_ref |= 1;
9475         }
9476         return ret_ref;
9477 }
9478
9479 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9480 CHECK(owner->result_ok);
9481         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
9482 }
9483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9484         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9485         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
9486         int64_t ret_ref = 0;
9487         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9488         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9490         ret_ref = (uintptr_t)ret_var.inner;
9491         if (ret_var.is_owned) {
9492                 ret_ref |= 1;
9493         }
9494         return ret_ref;
9495 }
9496
9497 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9498 CHECK(!owner->result_ok);
9499         return DecodeError_clone(&*owner->contents.err);
9500 }
9501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9502         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9503         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
9504         int64_t ret_ref = 0;
9505         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9506         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9508         ret_ref = (uintptr_t)ret_var.inner;
9509         if (ret_var.is_owned) {
9510                 ret_ref |= 1;
9511         }
9512         return ret_ref;
9513 }
9514
9515 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9516 CHECK(owner->result_ok);
9517         return QueryChannelRange_clone(&*owner->contents.result);
9518 }
9519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9520         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9521         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
9522         int64_t ret_ref = 0;
9523         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9524         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9526         ret_ref = (uintptr_t)ret_var.inner;
9527         if (ret_var.is_owned) {
9528                 ret_ref |= 1;
9529         }
9530         return ret_ref;
9531 }
9532
9533 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9534 CHECK(!owner->result_ok);
9535         return DecodeError_clone(&*owner->contents.err);
9536 }
9537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9538         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9539         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
9540         int64_t ret_ref = 0;
9541         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9542         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9543         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9544         ret_ref = (uintptr_t)ret_var.inner;
9545         if (ret_var.is_owned) {
9546                 ret_ref |= 1;
9547         }
9548         return ret_ref;
9549 }
9550
9551 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9552 CHECK(owner->result_ok);
9553         return ReplyChannelRange_clone(&*owner->contents.result);
9554 }
9555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9556         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9557         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
9558         int64_t ret_ref = 0;
9559         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9560         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9562         ret_ref = (uintptr_t)ret_var.inner;
9563         if (ret_var.is_owned) {
9564                 ret_ref |= 1;
9565         }
9566         return ret_ref;
9567 }
9568
9569 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9570 CHECK(!owner->result_ok);
9571         return DecodeError_clone(&*owner->contents.err);
9572 }
9573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9574         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9575         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
9576         int64_t ret_ref = 0;
9577         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9578         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9580         ret_ref = (uintptr_t)ret_var.inner;
9581         if (ret_var.is_owned) {
9582                 ret_ref |= 1;
9583         }
9584         return ret_ref;
9585 }
9586
9587 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9588 CHECK(owner->result_ok);
9589         return GossipTimestampFilter_clone(&*owner->contents.result);
9590 }
9591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9592         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
9593         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
9594         int64_t ret_ref = 0;
9595         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9596         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9598         ret_ref = (uintptr_t)ret_var.inner;
9599         if (ret_var.is_owned) {
9600                 ret_ref |= 1;
9601         }
9602         return ret_ref;
9603 }
9604
9605 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9606 CHECK(!owner->result_ok);
9607         return DecodeError_clone(&*owner->contents.err);
9608 }
9609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9610         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
9611         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
9612         int64_t ret_ref = 0;
9613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9616         ret_ref = (uintptr_t)ret_var.inner;
9617         if (ret_var.is_owned) {
9618                 ret_ref |= 1;
9619         }
9620         return ret_ref;
9621 }
9622
9623 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
9624         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
9625         for (size_t i = 0; i < ret.datalen; i++) {
9626                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
9627         }
9628         return ret;
9629 }
9630 static jclass LDKSignOrCreationError_SignError_class = NULL;
9631 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
9632 static jclass LDKSignOrCreationError_CreationError_class = NULL;
9633 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
9634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
9635         LDKSignOrCreationError_SignError_class =
9636                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
9637         CHECK(LDKSignOrCreationError_SignError_class != NULL);
9638         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
9639         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
9640         LDKSignOrCreationError_CreationError_class =
9641                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
9642         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
9643         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
9644         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
9645 }
9646 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9647         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
9648         switch(obj->tag) {
9649                 case LDKSignOrCreationError_SignError: {
9650                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
9651                 }
9652                 case LDKSignOrCreationError_CreationError: {
9653                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
9654                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
9655                 }
9656                 default: abort();
9657         }
9658 }
9659 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9660 CHECK(owner->result_ok);
9661         return Invoice_clone(&*owner->contents.result);
9662 }
9663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9664         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
9665         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
9666         int64_t ret_ref = 0;
9667         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9668         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9670         ret_ref = (uintptr_t)ret_var.inner;
9671         if (ret_var.is_owned) {
9672                 ret_ref |= 1;
9673         }
9674         return ret_ref;
9675 }
9676
9677 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9678 CHECK(!owner->result_ok);
9679         return SignOrCreationError_clone(&*owner->contents.err);
9680 }
9681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9682         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
9683         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
9684         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
9685         int64_t ret_ref = (uintptr_t)ret_copy;
9686         return ret_ref;
9687 }
9688
9689 typedef struct LDKFilter_JCalls {
9690         atomic_size_t refcnt;
9691         JavaVM *vm;
9692         jweak o;
9693         jmethodID register_tx_meth;
9694         jmethodID register_output_meth;
9695 } LDKFilter_JCalls;
9696 static void LDKFilter_JCalls_free(void* this_arg) {
9697         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9698         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9699                 JNIEnv *env;
9700                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9701                 if (get_jenv_res == JNI_EDETACHED) {
9702                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9703                 } else {
9704                         DO_ASSERT(get_jenv_res == JNI_OK);
9705                 }
9706                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9707                 if (get_jenv_res == JNI_EDETACHED) {
9708                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9709                 }
9710                 FREE(j_calls);
9711         }
9712 }
9713 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
9714         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9715         JNIEnv *env;
9716         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9717         if (get_jenv_res == JNI_EDETACHED) {
9718                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9719         } else {
9720                 DO_ASSERT(get_jenv_res == JNI_OK);
9721         }
9722         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
9723         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
9724         LDKu8slice script_pubkey_var = script_pubkey;
9725         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
9726         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
9727         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9728         CHECK(obj != NULL);
9729         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
9730         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9731                 (*env)->ExceptionDescribe(env);
9732                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
9733         }
9734         if (get_jenv_res == JNI_EDETACHED) {
9735                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9736         }
9737 }
9738 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
9739         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9740         JNIEnv *env;
9741         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9742         if (get_jenv_res == JNI_EDETACHED) {
9743                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9744         } else {
9745                 DO_ASSERT(get_jenv_res == JNI_OK);
9746         }
9747         LDKWatchedOutput output_var = output;
9748         int64_t output_ref = 0;
9749         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9750         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9751         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
9752         output_ref = (uintptr_t)output_var.inner;
9753         if (output_var.is_owned) {
9754                 output_ref |= 1;
9755         }
9756         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9757         CHECK(obj != NULL);
9758         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
9759         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9760                 (*env)->ExceptionDescribe(env);
9761                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
9762         }
9763         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9764         CHECK_ACCESS(ret_ptr);
9765         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
9766         FREE((void*)ret);
9767         if (get_jenv_res == JNI_EDETACHED) {
9768                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9769         }
9770         return ret_conv;
9771 }
9772 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
9773         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
9774         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9775 }
9776 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
9777         jclass c = (*env)->GetObjectClass(env, o);
9778         CHECK(c != NULL);
9779         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
9780         atomic_init(&calls->refcnt, 1);
9781         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9782         calls->o = (*env)->NewWeakGlobalRef(env, o);
9783         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
9784         CHECK(calls->register_tx_meth != NULL);
9785         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
9786         CHECK(calls->register_output_meth != NULL);
9787
9788         LDKFilter ret = {
9789                 .this_arg = (void*) calls,
9790                 .register_tx = register_tx_LDKFilter_jcall,
9791                 .register_output = register_output_LDKFilter_jcall,
9792                 .free = LDKFilter_JCalls_free,
9793         };
9794         return ret;
9795 }
9796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
9797         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
9798         *res_ptr = LDKFilter_init(env, clz, o);
9799         return (uint64_t)res_ptr;
9800 }
9801 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) {
9802         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9803         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9804         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
9805         unsigned char txid_arr[32];
9806         CHECK((*env)->GetArrayLength(env, txid) == 32);
9807         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
9808         unsigned char (*txid_ref)[32] = &txid_arr;
9809         LDKu8slice script_pubkey_ref;
9810         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
9811         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
9812         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
9813         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
9814 }
9815
9816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
9817         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9818         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9819         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
9820         LDKWatchedOutput output_conv;
9821         output_conv.inner = (void*)(output & (~1));
9822         output_conv.is_owned = (output & 1) || (output == 0);
9823         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
9824         output_conv = WatchedOutput_clone(&output_conv);
9825         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9826         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
9827         int64_t ret_ref = (uintptr_t)ret_copy;
9828         return ret_ref;
9829 }
9830
9831 static jclass LDKCOption_FilterZ_Some_class = NULL;
9832 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
9833 static jclass LDKCOption_FilterZ_None_class = NULL;
9834 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
9835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
9836         LDKCOption_FilterZ_Some_class =
9837                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
9838         CHECK(LDKCOption_FilterZ_Some_class != NULL);
9839         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
9840         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
9841         LDKCOption_FilterZ_None_class =
9842                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
9843         CHECK(LDKCOption_FilterZ_None_class != NULL);
9844         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
9845         CHECK(LDKCOption_FilterZ_None_meth != NULL);
9846 }
9847 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9848         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
9849         switch(obj->tag) {
9850                 case LDKCOption_FilterZ_Some: {
9851                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
9852                         *some_ret = obj->some;
9853                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
9854                         if ((*some_ret).free == LDKFilter_JCalls_free) {
9855                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9856                                 LDKFilter_JCalls_cloned(&(*some_ret));
9857                         }
9858                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (int64_t)some_ret);
9859                 }
9860                 case LDKCOption_FilterZ_None: {
9861                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
9862                 }
9863                 default: abort();
9864         }
9865 }
9866 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
9867 CHECK(owner->result_ok);
9868         return &*owner->contents.result;
9869 }
9870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9871         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
9872         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
9873         int64_t ret_ref = 0;
9874         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9875         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9877         ret_ref = (uintptr_t)ret_var.inner & ~1;
9878         return ret_ref;
9879 }
9880
9881 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
9882 CHECK(!owner->result_ok);
9883         return *owner->contents.err;
9884 }
9885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9886         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
9887         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
9888 }
9889
9890 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
9891         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
9892         for (size_t i = 0; i < ret.datalen; i++) {
9893                 ret.data[i] = OutPoint_clone(&orig->data[i]);
9894         }
9895         return ret;
9896 }
9897 typedef struct LDKMessageSendEventsProvider_JCalls {
9898         atomic_size_t refcnt;
9899         JavaVM *vm;
9900         jweak o;
9901         jmethodID get_and_clear_pending_msg_events_meth;
9902 } LDKMessageSendEventsProvider_JCalls;
9903 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
9904         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
9905         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9906                 JNIEnv *env;
9907                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9908                 if (get_jenv_res == JNI_EDETACHED) {
9909                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9910                 } else {
9911                         DO_ASSERT(get_jenv_res == JNI_OK);
9912                 }
9913                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9914                 if (get_jenv_res == JNI_EDETACHED) {
9915                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9916                 }
9917                 FREE(j_calls);
9918         }
9919 }
9920 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
9921         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
9922         JNIEnv *env;
9923         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9924         if (get_jenv_res == JNI_EDETACHED) {
9925                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9926         } else {
9927                 DO_ASSERT(get_jenv_res == JNI_OK);
9928         }
9929         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9930         CHECK(obj != NULL);
9931         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
9932         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9933                 (*env)->ExceptionDescribe(env);
9934                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
9935         }
9936         LDKCVec_MessageSendEventZ ret_constr;
9937         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9938         if (ret_constr.datalen > 0)
9939                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
9940         else
9941                 ret_constr.data = NULL;
9942         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9943         for (size_t s = 0; s < ret_constr.datalen; s++) {
9944                 int64_t ret_conv_18 = ret_vals[s];
9945                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
9946                 CHECK_ACCESS(ret_conv_18_ptr);
9947                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
9948                 FREE((void*)ret_conv_18);
9949                 ret_constr.data[s] = ret_conv_18_conv;
9950         }
9951         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9952         if (get_jenv_res == JNI_EDETACHED) {
9953                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9954         }
9955         return ret_constr;
9956 }
9957 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
9958         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
9959         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9960 }
9961 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
9962         jclass c = (*env)->GetObjectClass(env, o);
9963         CHECK(c != NULL);
9964         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
9965         atomic_init(&calls->refcnt, 1);
9966         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9967         calls->o = (*env)->NewWeakGlobalRef(env, o);
9968         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
9969         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
9970
9971         LDKMessageSendEventsProvider ret = {
9972                 .this_arg = (void*) calls,
9973                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
9974                 .free = LDKMessageSendEventsProvider_JCalls_free,
9975         };
9976         return ret;
9977 }
9978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
9979         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
9980         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
9981         return (uint64_t)res_ptr;
9982 }
9983 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
9984         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9985         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9986         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
9987         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
9988         int64_tArray ret_arr = NULL;
9989         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9990         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9991         for (size_t s = 0; s < ret_var.datalen; s++) {
9992                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
9993                 *ret_conv_18_copy = ret_var.data[s];
9994                 int64_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
9995                 ret_arr_ptr[s] = ret_conv_18_ref;
9996         }
9997         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9998         FREE(ret_var.data);
9999         return ret_arr;
10000 }
10001
10002 typedef struct LDKEventHandler_JCalls {
10003         atomic_size_t refcnt;
10004         JavaVM *vm;
10005         jweak o;
10006         jmethodID handle_event_meth;
10007 } LDKEventHandler_JCalls;
10008 static void LDKEventHandler_JCalls_free(void* this_arg) {
10009         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10010         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10011                 JNIEnv *env;
10012                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10013                 if (get_jenv_res == JNI_EDETACHED) {
10014                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10015                 } else {
10016                         DO_ASSERT(get_jenv_res == JNI_OK);
10017                 }
10018                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10019                 if (get_jenv_res == JNI_EDETACHED) {
10020                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10021                 }
10022                 FREE(j_calls);
10023         }
10024 }
10025 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
10026         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10027         JNIEnv *env;
10028         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10029         if (get_jenv_res == JNI_EDETACHED) {
10030                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10031         } else {
10032                 DO_ASSERT(get_jenv_res == JNI_OK);
10033         }
10034         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
10035         *ret_event = Event_clone(event);
10036         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10037         CHECK(obj != NULL);
10038         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (int64_t)ret_event);
10039         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10040                 (*env)->ExceptionDescribe(env);
10041                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
10042         }
10043         if (get_jenv_res == JNI_EDETACHED) {
10044                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10045         }
10046 }
10047 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
10048         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
10049         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10050 }
10051 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
10052         jclass c = (*env)->GetObjectClass(env, o);
10053         CHECK(c != NULL);
10054         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
10055         atomic_init(&calls->refcnt, 1);
10056         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10057         calls->o = (*env)->NewWeakGlobalRef(env, o);
10058         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
10059         CHECK(calls->handle_event_meth != NULL);
10060
10061         LDKEventHandler ret = {
10062                 .this_arg = (void*) calls,
10063                 .handle_event = handle_event_LDKEventHandler_jcall,
10064                 .free = LDKEventHandler_JCalls_free,
10065         };
10066         return ret;
10067 }
10068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
10069         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10070         *res_ptr = LDKEventHandler_init(env, clz, o);
10071         return (uint64_t)res_ptr;
10072 }
10073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
10074         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10075         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10076         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
10077         LDKEvent* event_conv = (LDKEvent*)event;
10078         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
10079 }
10080
10081 typedef struct LDKEventsProvider_JCalls {
10082         atomic_size_t refcnt;
10083         JavaVM *vm;
10084         jweak o;
10085         jmethodID process_pending_events_meth;
10086 } LDKEventsProvider_JCalls;
10087 static void LDKEventsProvider_JCalls_free(void* this_arg) {
10088         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10089         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10090                 JNIEnv *env;
10091                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10092                 if (get_jenv_res == JNI_EDETACHED) {
10093                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10094                 } else {
10095                         DO_ASSERT(get_jenv_res == JNI_OK);
10096                 }
10097                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10098                 if (get_jenv_res == JNI_EDETACHED) {
10099                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10100                 }
10101                 FREE(j_calls);
10102         }
10103 }
10104 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
10105         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10106         JNIEnv *env;
10107         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10108         if (get_jenv_res == JNI_EDETACHED) {
10109                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10110         } else {
10111                 DO_ASSERT(get_jenv_res == JNI_OK);
10112         }
10113         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10114         *handler_ret = handler;
10115         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10116         CHECK(obj != NULL);
10117         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (int64_t)handler_ret);
10118         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10119                 (*env)->ExceptionDescribe(env);
10120                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
10121         }
10122         if (get_jenv_res == JNI_EDETACHED) {
10123                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10124         }
10125 }
10126 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
10127         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
10128         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10129 }
10130 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10131         jclass c = (*env)->GetObjectClass(env, o);
10132         CHECK(c != NULL);
10133         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
10134         atomic_init(&calls->refcnt, 1);
10135         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10136         calls->o = (*env)->NewWeakGlobalRef(env, o);
10137         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
10138         CHECK(calls->process_pending_events_meth != NULL);
10139
10140         LDKEventsProvider ret = {
10141                 .this_arg = (void*) calls,
10142                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
10143                 .free = LDKEventsProvider_JCalls_free,
10144         };
10145         return ret;
10146 }
10147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10148         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
10149         *res_ptr = LDKEventsProvider_init(env, clz, o);
10150         return (uint64_t)res_ptr;
10151 }
10152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
10153         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10154         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10155         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
10156         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
10157         CHECK_ACCESS(handler_ptr);
10158         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
10159         if (handler_conv.free == LDKEventHandler_JCalls_free) {
10160                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10161                 LDKEventHandler_JCalls_cloned(&handler_conv);
10162         }
10163         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
10164 }
10165
10166 typedef struct LDKListen_JCalls {
10167         atomic_size_t refcnt;
10168         JavaVM *vm;
10169         jweak o;
10170         jmethodID block_connected_meth;
10171         jmethodID block_disconnected_meth;
10172 } LDKListen_JCalls;
10173 static void LDKListen_JCalls_free(void* this_arg) {
10174         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10175         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10176                 JNIEnv *env;
10177                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10178                 if (get_jenv_res == JNI_EDETACHED) {
10179                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10180                 } else {
10181                         DO_ASSERT(get_jenv_res == JNI_OK);
10182                 }
10183                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10184                 if (get_jenv_res == JNI_EDETACHED) {
10185                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10186                 }
10187                 FREE(j_calls);
10188         }
10189 }
10190 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
10191         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10192         JNIEnv *env;
10193         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10194         if (get_jenv_res == JNI_EDETACHED) {
10195                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10196         } else {
10197                 DO_ASSERT(get_jenv_res == JNI_OK);
10198         }
10199         LDKu8slice block_var = block;
10200         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
10201         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
10202         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10203         CHECK(obj != NULL);
10204         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
10205         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10206                 (*env)->ExceptionDescribe(env);
10207                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
10208         }
10209         if (get_jenv_res == JNI_EDETACHED) {
10210                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10211         }
10212 }
10213 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
10214         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10215         JNIEnv *env;
10216         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10217         if (get_jenv_res == JNI_EDETACHED) {
10218                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10219         } else {
10220                 DO_ASSERT(get_jenv_res == JNI_OK);
10221         }
10222         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10223         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10224         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10225         CHECK(obj != NULL);
10226         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
10227         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10228                 (*env)->ExceptionDescribe(env);
10229                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
10230         }
10231         if (get_jenv_res == JNI_EDETACHED) {
10232                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10233         }
10234 }
10235 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
10236         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
10237         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10238 }
10239 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
10240         jclass c = (*env)->GetObjectClass(env, o);
10241         CHECK(c != NULL);
10242         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
10243         atomic_init(&calls->refcnt, 1);
10244         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10245         calls->o = (*env)->NewWeakGlobalRef(env, o);
10246         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
10247         CHECK(calls->block_connected_meth != NULL);
10248         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
10249         CHECK(calls->block_disconnected_meth != NULL);
10250
10251         LDKListen ret = {
10252                 .this_arg = (void*) calls,
10253                 .block_connected = block_connected_LDKListen_jcall,
10254                 .block_disconnected = block_disconnected_LDKListen_jcall,
10255                 .free = LDKListen_JCalls_free,
10256         };
10257         return ret;
10258 }
10259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
10260         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
10261         *res_ptr = LDKListen_init(env, clz, o);
10262         return (uint64_t)res_ptr;
10263 }
10264 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) {
10265         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10266         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10267         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
10268         LDKu8slice block_ref;
10269         block_ref.datalen = (*env)->GetArrayLength(env, block);
10270         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
10271         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
10272         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
10273 }
10274
10275 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) {
10276         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10277         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10278         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
10279         unsigned char header_arr[80];
10280         CHECK((*env)->GetArrayLength(env, header) == 80);
10281         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10282         unsigned char (*header_ref)[80] = &header_arr;
10283         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
10284 }
10285
10286 typedef struct LDKConfirm_JCalls {
10287         atomic_size_t refcnt;
10288         JavaVM *vm;
10289         jweak o;
10290         jmethodID transactions_confirmed_meth;
10291         jmethodID transaction_unconfirmed_meth;
10292         jmethodID best_block_updated_meth;
10293         jmethodID get_relevant_txids_meth;
10294 } LDKConfirm_JCalls;
10295 static void LDKConfirm_JCalls_free(void* this_arg) {
10296         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10297         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10298                 JNIEnv *env;
10299                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10300                 if (get_jenv_res == JNI_EDETACHED) {
10301                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10302                 } else {
10303                         DO_ASSERT(get_jenv_res == JNI_OK);
10304                 }
10305                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10306                 if (get_jenv_res == JNI_EDETACHED) {
10307                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10308                 }
10309                 FREE(j_calls);
10310         }
10311 }
10312 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
10313         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10314         JNIEnv *env;
10315         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10316         if (get_jenv_res == JNI_EDETACHED) {
10317                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10318         } else {
10319                 DO_ASSERT(get_jenv_res == JNI_OK);
10320         }
10321         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10322         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10323         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
10324         int64_tArray txdata_arr = NULL;
10325         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
10326         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
10327         for (size_t c = 0; c < txdata_var.datalen; c++) {
10328                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10329                 *txdata_conv_28_conv = txdata_var.data[c];
10330                 txdata_arr_ptr[c] = ((int64_t)txdata_conv_28_conv);
10331         }
10332         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
10333         FREE(txdata_var.data);
10334         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10335         CHECK(obj != NULL);
10336         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
10337         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10338                 (*env)->ExceptionDescribe(env);
10339                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
10340         }
10341         if (get_jenv_res == JNI_EDETACHED) {
10342                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10343         }
10344 }
10345 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
10346         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10347         JNIEnv *env;
10348         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10349         if (get_jenv_res == JNI_EDETACHED) {
10350                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10351         } else {
10352                 DO_ASSERT(get_jenv_res == JNI_OK);
10353         }
10354         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
10355         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
10356         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10357         CHECK(obj != NULL);
10358         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
10359         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10360                 (*env)->ExceptionDescribe(env);
10361                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
10362         }
10363         if (get_jenv_res == JNI_EDETACHED) {
10364                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10365         }
10366 }
10367 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
10368         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10369         JNIEnv *env;
10370         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10371         if (get_jenv_res == JNI_EDETACHED) {
10372                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10373         } else {
10374                 DO_ASSERT(get_jenv_res == JNI_OK);
10375         }
10376         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10377         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10378         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10379         CHECK(obj != NULL);
10380         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
10381         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10382                 (*env)->ExceptionDescribe(env);
10383                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
10384         }
10385         if (get_jenv_res == JNI_EDETACHED) {
10386                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10387         }
10388 }
10389 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
10390         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10391         JNIEnv *env;
10392         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10393         if (get_jenv_res == JNI_EDETACHED) {
10394                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10395         } else {
10396                 DO_ASSERT(get_jenv_res == JNI_OK);
10397         }
10398         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10399         CHECK(obj != NULL);
10400         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
10401         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10402                 (*env)->ExceptionDescribe(env);
10403                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
10404         }
10405         LDKCVec_TxidZ ret_constr;
10406         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10407         if (ret_constr.datalen > 0)
10408                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
10409         else
10410                 ret_constr.data = NULL;
10411         for (size_t i = 0; i < ret_constr.datalen; i++) {
10412                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
10413                 LDKThirtyTwoBytes ret_conv_8_ref;
10414                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
10415                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
10416                 ret_constr.data[i] = ret_conv_8_ref;
10417         }
10418         if (get_jenv_res == JNI_EDETACHED) {
10419                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10420         }
10421         return ret_constr;
10422 }
10423 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
10424         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
10425         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10426 }
10427 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
10428         jclass c = (*env)->GetObjectClass(env, o);
10429         CHECK(c != NULL);
10430         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
10431         atomic_init(&calls->refcnt, 1);
10432         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10433         calls->o = (*env)->NewWeakGlobalRef(env, o);
10434         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
10435         CHECK(calls->transactions_confirmed_meth != NULL);
10436         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
10437         CHECK(calls->transaction_unconfirmed_meth != NULL);
10438         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
10439         CHECK(calls->best_block_updated_meth != NULL);
10440         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
10441         CHECK(calls->get_relevant_txids_meth != NULL);
10442
10443         LDKConfirm ret = {
10444                 .this_arg = (void*) calls,
10445                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
10446                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
10447                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
10448                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
10449                 .free = LDKConfirm_JCalls_free,
10450         };
10451         return ret;
10452 }
10453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
10454         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
10455         *res_ptr = LDKConfirm_init(env, clz, o);
10456         return (uint64_t)res_ptr;
10457 }
10458 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) {
10459         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10460         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10461         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10462         unsigned char header_arr[80];
10463         CHECK((*env)->GetArrayLength(env, header) == 80);
10464         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10465         unsigned char (*header_ref)[80] = &header_arr;
10466         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
10467         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
10468         if (txdata_constr.datalen > 0)
10469                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10470         else
10471                 txdata_constr.data = NULL;
10472         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
10473         for (size_t c = 0; c < txdata_constr.datalen; c++) {
10474                 int64_t txdata_conv_28 = txdata_vals[c];
10475                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
10476                 CHECK_ACCESS(txdata_conv_28_ptr);
10477                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
10478                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
10479                 txdata_constr.data[c] = txdata_conv_28_conv;
10480         }
10481         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
10482         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
10483 }
10484
10485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
10486         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10487         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10488         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10489         unsigned char txid_arr[32];
10490         CHECK((*env)->GetArrayLength(env, txid) == 32);
10491         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
10492         unsigned char (*txid_ref)[32] = &txid_arr;
10493         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
10494 }
10495
10496 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) {
10497         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10498         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10499         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10500         unsigned char header_arr[80];
10501         CHECK((*env)->GetArrayLength(env, header) == 80);
10502         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10503         unsigned char (*header_ref)[80] = &header_arr;
10504         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
10505 }
10506
10507 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
10508         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10509         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10510         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10511         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
10512         jobjectArray ret_arr = NULL;
10513         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
10514         ;
10515         for (size_t i = 0; i < ret_var.datalen; i++) {
10516                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
10517                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
10518                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
10519         }
10520         
10521         FREE(ret_var.data);
10522         return ret_arr;
10523 }
10524
10525 typedef struct LDKPersist_JCalls {
10526         atomic_size_t refcnt;
10527         JavaVM *vm;
10528         jweak o;
10529         jmethodID persist_new_channel_meth;
10530         jmethodID update_persisted_channel_meth;
10531 } LDKPersist_JCalls;
10532 static void LDKPersist_JCalls_free(void* this_arg) {
10533         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10534         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10535                 JNIEnv *env;
10536                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10537                 if (get_jenv_res == JNI_EDETACHED) {
10538                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10539                 } else {
10540                         DO_ASSERT(get_jenv_res == JNI_OK);
10541                 }
10542                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10543                 if (get_jenv_res == JNI_EDETACHED) {
10544                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10545                 }
10546                 FREE(j_calls);
10547         }
10548 }
10549 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
10550         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10551         JNIEnv *env;
10552         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10553         if (get_jenv_res == JNI_EDETACHED) {
10554                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10555         } else {
10556                 DO_ASSERT(get_jenv_res == JNI_OK);
10557         }
10558         LDKOutPoint channel_id_var = channel_id;
10559         int64_t channel_id_ref = 0;
10560         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10561         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10562         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
10563         channel_id_ref = (uintptr_t)channel_id_var.inner;
10564         if (channel_id_var.is_owned) {
10565                 channel_id_ref |= 1;
10566         }
10567         LDKChannelMonitor data_var = *data;
10568         int64_t data_ref = 0;
10569         data_var = ChannelMonitor_clone(&data_var);
10570         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10571         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10572         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
10573         data_ref = (uintptr_t)data_var.inner;
10574         if (data_var.is_owned) {
10575                 data_ref |= 1;
10576         }
10577         LDKMonitorUpdateId update_id_var = update_id;
10578         int64_t update_id_ref = 0;
10579         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10580         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10581         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
10582         update_id_ref = (uintptr_t)update_id_var.inner;
10583         if (update_id_var.is_owned) {
10584                 update_id_ref |= 1;
10585         }
10586         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10587         CHECK(obj != NULL);
10588         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
10589         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10590                 (*env)->ExceptionDescribe(env);
10591                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
10592         }
10593         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10594         CHECK_ACCESS(ret_ptr);
10595         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
10596         FREE((void*)ret);
10597         if (get_jenv_res == JNI_EDETACHED) {
10598                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10599         }
10600         return ret_conv;
10601 }
10602 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
10603         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10604         JNIEnv *env;
10605         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10606         if (get_jenv_res == JNI_EDETACHED) {
10607                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10608         } else {
10609                 DO_ASSERT(get_jenv_res == JNI_OK);
10610         }
10611         LDKOutPoint channel_id_var = channel_id;
10612         int64_t channel_id_ref = 0;
10613         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10614         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10615         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
10616         channel_id_ref = (uintptr_t)channel_id_var.inner;
10617         if (channel_id_var.is_owned) {
10618                 channel_id_ref |= 1;
10619         }
10620         LDKChannelMonitorUpdate update_var = *update;
10621         int64_t update_ref = 0;
10622         if ((uintptr_t)update_var.inner > 4096) {
10623                 update_var = ChannelMonitorUpdate_clone(&update_var);
10624                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10625                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10626         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
10627                 update_ref = (uintptr_t)update_var.inner;
10628                 if (update_var.is_owned) {
10629                         update_ref |= 1;
10630                 }
10631         }
10632         LDKChannelMonitor data_var = *data;
10633         int64_t data_ref = 0;
10634         data_var = ChannelMonitor_clone(&data_var);
10635         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10636         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10637         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
10638         data_ref = (uintptr_t)data_var.inner;
10639         if (data_var.is_owned) {
10640                 data_ref |= 1;
10641         }
10642         LDKMonitorUpdateId update_id_var = update_id;
10643         int64_t update_id_ref = 0;
10644         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10645         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10646         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
10647         update_id_ref = (uintptr_t)update_id_var.inner;
10648         if (update_id_var.is_owned) {
10649                 update_id_ref |= 1;
10650         }
10651         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10652         CHECK(obj != NULL);
10653         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
10654         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10655                 (*env)->ExceptionDescribe(env);
10656                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
10657         }
10658         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10659         CHECK_ACCESS(ret_ptr);
10660         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
10661         FREE((void*)ret);
10662         if (get_jenv_res == JNI_EDETACHED) {
10663                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10664         }
10665         return ret_conv;
10666 }
10667 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
10668         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
10669         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10670 }
10671 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
10672         jclass c = (*env)->GetObjectClass(env, o);
10673         CHECK(c != NULL);
10674         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
10675         atomic_init(&calls->refcnt, 1);
10676         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10677         calls->o = (*env)->NewWeakGlobalRef(env, o);
10678         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
10679         CHECK(calls->persist_new_channel_meth != NULL);
10680         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
10681         CHECK(calls->update_persisted_channel_meth != NULL);
10682
10683         LDKPersist ret = {
10684                 .this_arg = (void*) calls,
10685                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
10686                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
10687                 .free = LDKPersist_JCalls_free,
10688         };
10689         return ret;
10690 }
10691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
10692         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
10693         *res_ptr = LDKPersist_init(env, clz, o);
10694         return (uint64_t)res_ptr;
10695 }
10696 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) {
10697         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10698         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10699         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
10700         LDKOutPoint channel_id_conv;
10701         channel_id_conv.inner = (void*)(channel_id & (~1));
10702         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
10703         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
10704         channel_id_conv = OutPoint_clone(&channel_id_conv);
10705         LDKChannelMonitor data_conv;
10706         data_conv.inner = (void*)(data & (~1));
10707         data_conv.is_owned = false;
10708         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
10709         LDKMonitorUpdateId update_id_conv;
10710         update_id_conv.inner = (void*)(update_id & (~1));
10711         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
10712         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
10713         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
10714         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10715         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
10716         return (int64_t)ret_conv;
10717 }
10718
10719 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) {
10720         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10721         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10722         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
10723         LDKOutPoint channel_id_conv;
10724         channel_id_conv.inner = (void*)(channel_id & (~1));
10725         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
10726         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
10727         channel_id_conv = OutPoint_clone(&channel_id_conv);
10728         LDKChannelMonitorUpdate update_conv;
10729         update_conv.inner = (void*)(update & (~1));
10730         update_conv.is_owned = false;
10731         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
10732         LDKChannelMonitor data_conv;
10733         data_conv.inner = (void*)(data & (~1));
10734         data_conv.is_owned = false;
10735         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
10736         LDKMonitorUpdateId update_id_conv;
10737         update_id_conv.inner = (void*)(update_id & (~1));
10738         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
10739         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
10740         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
10741         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10742         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
10743         return (int64_t)ret_conv;
10744 }
10745
10746 typedef struct LDKChannelMessageHandler_JCalls {
10747         atomic_size_t refcnt;
10748         JavaVM *vm;
10749         jweak o;
10750         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
10751         jmethodID handle_open_channel_meth;
10752         jmethodID handle_accept_channel_meth;
10753         jmethodID handle_funding_created_meth;
10754         jmethodID handle_funding_signed_meth;
10755         jmethodID handle_funding_locked_meth;
10756         jmethodID handle_shutdown_meth;
10757         jmethodID handle_closing_signed_meth;
10758         jmethodID handle_update_add_htlc_meth;
10759         jmethodID handle_update_fulfill_htlc_meth;
10760         jmethodID handle_update_fail_htlc_meth;
10761         jmethodID handle_update_fail_malformed_htlc_meth;
10762         jmethodID handle_commitment_signed_meth;
10763         jmethodID handle_revoke_and_ack_meth;
10764         jmethodID handle_update_fee_meth;
10765         jmethodID handle_announcement_signatures_meth;
10766         jmethodID peer_disconnected_meth;
10767         jmethodID peer_connected_meth;
10768         jmethodID handle_channel_reestablish_meth;
10769         jmethodID handle_channel_update_meth;
10770         jmethodID handle_error_meth;
10771 } LDKChannelMessageHandler_JCalls;
10772 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
10773         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10774         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10775                 JNIEnv *env;
10776                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10777                 if (get_jenv_res == JNI_EDETACHED) {
10778                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10779                 } else {
10780                         DO_ASSERT(get_jenv_res == JNI_OK);
10781                 }
10782                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10783                 if (get_jenv_res == JNI_EDETACHED) {
10784                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10785                 }
10786                 FREE(j_calls);
10787         }
10788 }
10789 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
10790         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10791         JNIEnv *env;
10792         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10793         if (get_jenv_res == JNI_EDETACHED) {
10794                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10795         } else {
10796                 DO_ASSERT(get_jenv_res == JNI_OK);
10797         }
10798         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10799         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10800         LDKInitFeatures their_features_var = their_features;
10801         int64_t their_features_ref = 0;
10802         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10803         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10804         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10805         their_features_ref = (uintptr_t)their_features_var.inner;
10806         if (their_features_var.is_owned) {
10807                 their_features_ref |= 1;
10808         }
10809         LDKOpenChannel msg_var = *msg;
10810         int64_t msg_ref = 0;
10811         msg_var = OpenChannel_clone(&msg_var);
10812         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10813         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10814         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10815         msg_ref = (uintptr_t)msg_var.inner;
10816         if (msg_var.is_owned) {
10817                 msg_ref |= 1;
10818         }
10819         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10820         CHECK(obj != NULL);
10821         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
10822         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10823                 (*env)->ExceptionDescribe(env);
10824                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
10825         }
10826         if (get_jenv_res == JNI_EDETACHED) {
10827                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10828         }
10829 }
10830 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
10831         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10832         JNIEnv *env;
10833         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10834         if (get_jenv_res == JNI_EDETACHED) {
10835                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10836         } else {
10837                 DO_ASSERT(get_jenv_res == JNI_OK);
10838         }
10839         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10840         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10841         LDKInitFeatures their_features_var = their_features;
10842         int64_t their_features_ref = 0;
10843         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10844         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10845         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10846         their_features_ref = (uintptr_t)their_features_var.inner;
10847         if (their_features_var.is_owned) {
10848                 their_features_ref |= 1;
10849         }
10850         LDKAcceptChannel msg_var = *msg;
10851         int64_t msg_ref = 0;
10852         msg_var = AcceptChannel_clone(&msg_var);
10853         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10854         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10855         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10856         msg_ref = (uintptr_t)msg_var.inner;
10857         if (msg_var.is_owned) {
10858                 msg_ref |= 1;
10859         }
10860         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10861         CHECK(obj != NULL);
10862         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
10863         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10864                 (*env)->ExceptionDescribe(env);
10865                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
10866         }
10867         if (get_jenv_res == JNI_EDETACHED) {
10868                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10869         }
10870 }
10871 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
10872         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10873         JNIEnv *env;
10874         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10875         if (get_jenv_res == JNI_EDETACHED) {
10876                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10877         } else {
10878                 DO_ASSERT(get_jenv_res == JNI_OK);
10879         }
10880         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10881         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10882         LDKFundingCreated msg_var = *msg;
10883         int64_t msg_ref = 0;
10884         msg_var = FundingCreated_clone(&msg_var);
10885         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10886         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10887         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10888         msg_ref = (uintptr_t)msg_var.inner;
10889         if (msg_var.is_owned) {
10890                 msg_ref |= 1;
10891         }
10892         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10893         CHECK(obj != NULL);
10894         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
10895         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10896                 (*env)->ExceptionDescribe(env);
10897                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
10898         }
10899         if (get_jenv_res == JNI_EDETACHED) {
10900                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10901         }
10902 }
10903 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
10904         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10905         JNIEnv *env;
10906         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10907         if (get_jenv_res == JNI_EDETACHED) {
10908                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10909         } else {
10910                 DO_ASSERT(get_jenv_res == JNI_OK);
10911         }
10912         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10913         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10914         LDKFundingSigned msg_var = *msg;
10915         int64_t msg_ref = 0;
10916         msg_var = FundingSigned_clone(&msg_var);
10917         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10918         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10919         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10920         msg_ref = (uintptr_t)msg_var.inner;
10921         if (msg_var.is_owned) {
10922                 msg_ref |= 1;
10923         }
10924         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10925         CHECK(obj != NULL);
10926         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
10927         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10928                 (*env)->ExceptionDescribe(env);
10929                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
10930         }
10931         if (get_jenv_res == JNI_EDETACHED) {
10932                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10933         }
10934 }
10935 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
10936         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10937         JNIEnv *env;
10938         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10939         if (get_jenv_res == JNI_EDETACHED) {
10940                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10941         } else {
10942                 DO_ASSERT(get_jenv_res == JNI_OK);
10943         }
10944         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10945         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10946         LDKFundingLocked msg_var = *msg;
10947         int64_t msg_ref = 0;
10948         msg_var = FundingLocked_clone(&msg_var);
10949         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10950         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10951         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10952         msg_ref = (uintptr_t)msg_var.inner;
10953         if (msg_var.is_owned) {
10954                 msg_ref |= 1;
10955         }
10956         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10957         CHECK(obj != NULL);
10958         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
10959         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10960                 (*env)->ExceptionDescribe(env);
10961                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
10962         }
10963         if (get_jenv_res == JNI_EDETACHED) {
10964                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10965         }
10966 }
10967 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
10968         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10969         JNIEnv *env;
10970         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10971         if (get_jenv_res == JNI_EDETACHED) {
10972                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10973         } else {
10974                 DO_ASSERT(get_jenv_res == JNI_OK);
10975         }
10976         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10977         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10978         LDKInitFeatures their_features_var = *their_features;
10979         int64_t their_features_ref = 0;
10980         their_features_var = InitFeatures_clone(&their_features_var);
10981         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10982         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10983         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10984         their_features_ref = (uintptr_t)their_features_var.inner;
10985         if (their_features_var.is_owned) {
10986                 their_features_ref |= 1;
10987         }
10988         LDKShutdown msg_var = *msg;
10989         int64_t msg_ref = 0;
10990         msg_var = Shutdown_clone(&msg_var);
10991         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10992         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10993         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10994         msg_ref = (uintptr_t)msg_var.inner;
10995         if (msg_var.is_owned) {
10996                 msg_ref |= 1;
10997         }
10998         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10999         CHECK(obj != NULL);
11000         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
11001         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11002                 (*env)->ExceptionDescribe(env);
11003                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
11004         }
11005         if (get_jenv_res == JNI_EDETACHED) {
11006                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11007         }
11008 }
11009 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
11010         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11011         JNIEnv *env;
11012         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11013         if (get_jenv_res == JNI_EDETACHED) {
11014                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11015         } else {
11016                 DO_ASSERT(get_jenv_res == JNI_OK);
11017         }
11018         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11019         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11020         LDKClosingSigned msg_var = *msg;
11021         int64_t msg_ref = 0;
11022         msg_var = ClosingSigned_clone(&msg_var);
11023         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11024         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11025         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11026         msg_ref = (uintptr_t)msg_var.inner;
11027         if (msg_var.is_owned) {
11028                 msg_ref |= 1;
11029         }
11030         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11031         CHECK(obj != NULL);
11032         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
11033         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11034                 (*env)->ExceptionDescribe(env);
11035                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
11036         }
11037         if (get_jenv_res == JNI_EDETACHED) {
11038                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11039         }
11040 }
11041 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
11042         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11043         JNIEnv *env;
11044         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11045         if (get_jenv_res == JNI_EDETACHED) {
11046                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11047         } else {
11048                 DO_ASSERT(get_jenv_res == JNI_OK);
11049         }
11050         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11051         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11052         LDKUpdateAddHTLC msg_var = *msg;
11053         int64_t msg_ref = 0;
11054         msg_var = UpdateAddHTLC_clone(&msg_var);
11055         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11056         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11057         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11058         msg_ref = (uintptr_t)msg_var.inner;
11059         if (msg_var.is_owned) {
11060                 msg_ref |= 1;
11061         }
11062         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11063         CHECK(obj != NULL);
11064         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
11065         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11066                 (*env)->ExceptionDescribe(env);
11067                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
11068         }
11069         if (get_jenv_res == JNI_EDETACHED) {
11070                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11071         }
11072 }
11073 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
11074         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11075         JNIEnv *env;
11076         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11077         if (get_jenv_res == JNI_EDETACHED) {
11078                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11079         } else {
11080                 DO_ASSERT(get_jenv_res == JNI_OK);
11081         }
11082         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11083         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11084         LDKUpdateFulfillHTLC msg_var = *msg;
11085         int64_t msg_ref = 0;
11086         msg_var = UpdateFulfillHTLC_clone(&msg_var);
11087         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11088         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11089         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11090         msg_ref = (uintptr_t)msg_var.inner;
11091         if (msg_var.is_owned) {
11092                 msg_ref |= 1;
11093         }
11094         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11095         CHECK(obj != NULL);
11096         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
11097         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11098                 (*env)->ExceptionDescribe(env);
11099                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
11100         }
11101         if (get_jenv_res == JNI_EDETACHED) {
11102                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11103         }
11104 }
11105 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
11106         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11107         JNIEnv *env;
11108         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11109         if (get_jenv_res == JNI_EDETACHED) {
11110                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11111         } else {
11112                 DO_ASSERT(get_jenv_res == JNI_OK);
11113         }
11114         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11115         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11116         LDKUpdateFailHTLC msg_var = *msg;
11117         int64_t msg_ref = 0;
11118         msg_var = UpdateFailHTLC_clone(&msg_var);
11119         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11120         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11121         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11122         msg_ref = (uintptr_t)msg_var.inner;
11123         if (msg_var.is_owned) {
11124                 msg_ref |= 1;
11125         }
11126         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11127         CHECK(obj != NULL);
11128         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
11129         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11130                 (*env)->ExceptionDescribe(env);
11131                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
11132         }
11133         if (get_jenv_res == JNI_EDETACHED) {
11134                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11135         }
11136 }
11137 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
11138         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11139         JNIEnv *env;
11140         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11141         if (get_jenv_res == JNI_EDETACHED) {
11142                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11143         } else {
11144                 DO_ASSERT(get_jenv_res == JNI_OK);
11145         }
11146         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11147         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11148         LDKUpdateFailMalformedHTLC msg_var = *msg;
11149         int64_t msg_ref = 0;
11150         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
11151         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11152         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11153         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11154         msg_ref = (uintptr_t)msg_var.inner;
11155         if (msg_var.is_owned) {
11156                 msg_ref |= 1;
11157         }
11158         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11159         CHECK(obj != NULL);
11160         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
11161         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11162                 (*env)->ExceptionDescribe(env);
11163                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
11164         }
11165         if (get_jenv_res == JNI_EDETACHED) {
11166                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11167         }
11168 }
11169 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
11170         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11171         JNIEnv *env;
11172         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11173         if (get_jenv_res == JNI_EDETACHED) {
11174                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11175         } else {
11176                 DO_ASSERT(get_jenv_res == JNI_OK);
11177         }
11178         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11179         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11180         LDKCommitmentSigned msg_var = *msg;
11181         int64_t msg_ref = 0;
11182         msg_var = CommitmentSigned_clone(&msg_var);
11183         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11184         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11185         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11186         msg_ref = (uintptr_t)msg_var.inner;
11187         if (msg_var.is_owned) {
11188                 msg_ref |= 1;
11189         }
11190         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11191         CHECK(obj != NULL);
11192         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
11193         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11194                 (*env)->ExceptionDescribe(env);
11195                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
11196         }
11197         if (get_jenv_res == JNI_EDETACHED) {
11198                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11199         }
11200 }
11201 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
11202         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11203         JNIEnv *env;
11204         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11205         if (get_jenv_res == JNI_EDETACHED) {
11206                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11207         } else {
11208                 DO_ASSERT(get_jenv_res == JNI_OK);
11209         }
11210         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11211         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11212         LDKRevokeAndACK msg_var = *msg;
11213         int64_t msg_ref = 0;
11214         msg_var = RevokeAndACK_clone(&msg_var);
11215         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11216         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11217         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11218         msg_ref = (uintptr_t)msg_var.inner;
11219         if (msg_var.is_owned) {
11220                 msg_ref |= 1;
11221         }
11222         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11223         CHECK(obj != NULL);
11224         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
11225         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11226                 (*env)->ExceptionDescribe(env);
11227                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
11228         }
11229         if (get_jenv_res == JNI_EDETACHED) {
11230                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11231         }
11232 }
11233 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
11234         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11235         JNIEnv *env;
11236         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11237         if (get_jenv_res == JNI_EDETACHED) {
11238                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11239         } else {
11240                 DO_ASSERT(get_jenv_res == JNI_OK);
11241         }
11242         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11243         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11244         LDKUpdateFee msg_var = *msg;
11245         int64_t msg_ref = 0;
11246         msg_var = UpdateFee_clone(&msg_var);
11247         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11248         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11249         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11250         msg_ref = (uintptr_t)msg_var.inner;
11251         if (msg_var.is_owned) {
11252                 msg_ref |= 1;
11253         }
11254         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11255         CHECK(obj != NULL);
11256         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
11257         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11258                 (*env)->ExceptionDescribe(env);
11259                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
11260         }
11261         if (get_jenv_res == JNI_EDETACHED) {
11262                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11263         }
11264 }
11265 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
11266         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11267         JNIEnv *env;
11268         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11269         if (get_jenv_res == JNI_EDETACHED) {
11270                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11271         } else {
11272                 DO_ASSERT(get_jenv_res == JNI_OK);
11273         }
11274         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11275         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11276         LDKAnnouncementSignatures msg_var = *msg;
11277         int64_t msg_ref = 0;
11278         msg_var = AnnouncementSignatures_clone(&msg_var);
11279         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11280         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11281         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11282         msg_ref = (uintptr_t)msg_var.inner;
11283         if (msg_var.is_owned) {
11284                 msg_ref |= 1;
11285         }
11286         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11287         CHECK(obj != NULL);
11288         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
11289         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11290                 (*env)->ExceptionDescribe(env);
11291                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
11292         }
11293         if (get_jenv_res == JNI_EDETACHED) {
11294                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11295         }
11296 }
11297 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
11298         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11299         JNIEnv *env;
11300         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11301         if (get_jenv_res == JNI_EDETACHED) {
11302                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11303         } else {
11304                 DO_ASSERT(get_jenv_res == JNI_OK);
11305         }
11306         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11307         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11308         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11309         CHECK(obj != NULL);
11310         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
11311         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11312                 (*env)->ExceptionDescribe(env);
11313                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
11314         }
11315         if (get_jenv_res == JNI_EDETACHED) {
11316                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11317         }
11318 }
11319 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
11320         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11321         JNIEnv *env;
11322         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11323         if (get_jenv_res == JNI_EDETACHED) {
11324                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11325         } else {
11326                 DO_ASSERT(get_jenv_res == JNI_OK);
11327         }
11328         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11329         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11330         LDKInit msg_var = *msg;
11331         int64_t msg_ref = 0;
11332         msg_var = Init_clone(&msg_var);
11333         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11334         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11335         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11336         msg_ref = (uintptr_t)msg_var.inner;
11337         if (msg_var.is_owned) {
11338                 msg_ref |= 1;
11339         }
11340         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11341         CHECK(obj != NULL);
11342         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
11343         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11344                 (*env)->ExceptionDescribe(env);
11345                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
11346         }
11347         if (get_jenv_res == JNI_EDETACHED) {
11348                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11349         }
11350 }
11351 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
11352         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_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         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11361         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11362         LDKChannelReestablish msg_var = *msg;
11363         int64_t msg_ref = 0;
11364         msg_var = ChannelReestablish_clone(&msg_var);
11365         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11366         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11367         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11368         msg_ref = (uintptr_t)msg_var.inner;
11369         if (msg_var.is_owned) {
11370                 msg_ref |= 1;
11371         }
11372         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11373         CHECK(obj != NULL);
11374         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
11375         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11376                 (*env)->ExceptionDescribe(env);
11377                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
11378         }
11379         if (get_jenv_res == JNI_EDETACHED) {
11380                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11381         }
11382 }
11383 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
11384         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11385         JNIEnv *env;
11386         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11387         if (get_jenv_res == JNI_EDETACHED) {
11388                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11389         } else {
11390                 DO_ASSERT(get_jenv_res == JNI_OK);
11391         }
11392         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11393         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11394         LDKChannelUpdate msg_var = *msg;
11395         int64_t msg_ref = 0;
11396         msg_var = ChannelUpdate_clone(&msg_var);
11397         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11398         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11399         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11400         msg_ref = (uintptr_t)msg_var.inner;
11401         if (msg_var.is_owned) {
11402                 msg_ref |= 1;
11403         }
11404         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11405         CHECK(obj != NULL);
11406         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
11407         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11408                 (*env)->ExceptionDescribe(env);
11409                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
11410         }
11411         if (get_jenv_res == JNI_EDETACHED) {
11412                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11413         }
11414 }
11415 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
11416         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11417         JNIEnv *env;
11418         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11419         if (get_jenv_res == JNI_EDETACHED) {
11420                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11421         } else {
11422                 DO_ASSERT(get_jenv_res == JNI_OK);
11423         }
11424         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11425         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11426         LDKErrorMessage msg_var = *msg;
11427         int64_t msg_ref = 0;
11428         msg_var = ErrorMessage_clone(&msg_var);
11429         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11430         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11431         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11432         msg_ref = (uintptr_t)msg_var.inner;
11433         if (msg_var.is_owned) {
11434                 msg_ref |= 1;
11435         }
11436         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11437         CHECK(obj != NULL);
11438         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
11439         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11440                 (*env)->ExceptionDescribe(env);
11441                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
11442         }
11443         if (get_jenv_res == JNI_EDETACHED) {
11444                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11445         }
11446 }
11447 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
11448         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
11449         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11450         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
11451 }
11452 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11453         jclass c = (*env)->GetObjectClass(env, o);
11454         CHECK(c != NULL);
11455         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
11456         atomic_init(&calls->refcnt, 1);
11457         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11458         calls->o = (*env)->NewWeakGlobalRef(env, o);
11459         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
11460         CHECK(calls->handle_open_channel_meth != NULL);
11461         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
11462         CHECK(calls->handle_accept_channel_meth != NULL);
11463         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
11464         CHECK(calls->handle_funding_created_meth != NULL);
11465         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
11466         CHECK(calls->handle_funding_signed_meth != NULL);
11467         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
11468         CHECK(calls->handle_funding_locked_meth != NULL);
11469         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
11470         CHECK(calls->handle_shutdown_meth != NULL);
11471         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
11472         CHECK(calls->handle_closing_signed_meth != NULL);
11473         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
11474         CHECK(calls->handle_update_add_htlc_meth != NULL);
11475         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
11476         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
11477         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
11478         CHECK(calls->handle_update_fail_htlc_meth != NULL);
11479         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
11480         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
11481         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
11482         CHECK(calls->handle_commitment_signed_meth != NULL);
11483         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
11484         CHECK(calls->handle_revoke_and_ack_meth != NULL);
11485         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
11486         CHECK(calls->handle_update_fee_meth != NULL);
11487         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
11488         CHECK(calls->handle_announcement_signatures_meth != NULL);
11489         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
11490         CHECK(calls->peer_disconnected_meth != NULL);
11491         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
11492         CHECK(calls->peer_connected_meth != NULL);
11493         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
11494         CHECK(calls->handle_channel_reestablish_meth != NULL);
11495         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
11496         CHECK(calls->handle_channel_update_meth != NULL);
11497         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
11498         CHECK(calls->handle_error_meth != NULL);
11499
11500         LDKChannelMessageHandler ret = {
11501                 .this_arg = (void*) calls,
11502                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
11503                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
11504                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
11505                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
11506                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
11507                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
11508                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
11509                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
11510                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
11511                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
11512                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
11513                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
11514                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
11515                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
11516                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
11517                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
11518                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
11519                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
11520                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
11521                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
11522                 .free = LDKChannelMessageHandler_JCalls_free,
11523                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
11524         };
11525         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
11526         return ret;
11527 }
11528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11529         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
11530         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
11531         return (uint64_t)res_ptr;
11532 }
11533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
11534         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
11535         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
11536         DO_ASSERT((res_ptr & 1) == 0);
11537         return (int64_t)(res_ptr | 1);
11538 }
11539 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) {
11540         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11541         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11542         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11543         LDKPublicKey their_node_id_ref;
11544         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11545         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11546         LDKInitFeatures their_features_conv;
11547         their_features_conv.inner = (void*)(their_features & (~1));
11548         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
11549         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11550         their_features_conv = InitFeatures_clone(&their_features_conv);
11551         LDKOpenChannel msg_conv;
11552         msg_conv.inner = (void*)(msg & (~1));
11553         msg_conv.is_owned = false;
11554         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11555         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
11556 }
11557
11558 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) {
11559         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11560         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11561         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11562         LDKPublicKey their_node_id_ref;
11563         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11564         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11565         LDKInitFeatures their_features_conv;
11566         their_features_conv.inner = (void*)(their_features & (~1));
11567         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
11568         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11569         their_features_conv = InitFeatures_clone(&their_features_conv);
11570         LDKAcceptChannel msg_conv;
11571         msg_conv.inner = (void*)(msg & (~1));
11572         msg_conv.is_owned = false;
11573         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11574         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
11575 }
11576
11577 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) {
11578         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11579         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11580         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11581         LDKPublicKey their_node_id_ref;
11582         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11583         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11584         LDKFundingCreated msg_conv;
11585         msg_conv.inner = (void*)(msg & (~1));
11586         msg_conv.is_owned = false;
11587         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11588         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11589 }
11590
11591 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) {
11592         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11593         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11594         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11595         LDKPublicKey their_node_id_ref;
11596         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11597         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11598         LDKFundingSigned msg_conv;
11599         msg_conv.inner = (void*)(msg & (~1));
11600         msg_conv.is_owned = false;
11601         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11602         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11603 }
11604
11605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
11606         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11607         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11608         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11609         LDKPublicKey their_node_id_ref;
11610         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11611         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11612         LDKFundingLocked msg_conv;
11613         msg_conv.inner = (void*)(msg & (~1));
11614         msg_conv.is_owned = false;
11615         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11616         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11617 }
11618
11619 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) {
11620         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11621         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11622         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11623         LDKPublicKey their_node_id_ref;
11624         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11625         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11626         LDKInitFeatures their_features_conv;
11627         their_features_conv.inner = (void*)(their_features & (~1));
11628         their_features_conv.is_owned = false;
11629         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11630         LDKShutdown msg_conv;
11631         msg_conv.inner = (void*)(msg & (~1));
11632         msg_conv.is_owned = false;
11633         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11634         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
11635 }
11636
11637 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) {
11638         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11639         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11640         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11641         LDKPublicKey their_node_id_ref;
11642         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11643         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11644         LDKClosingSigned msg_conv;
11645         msg_conv.inner = (void*)(msg & (~1));
11646         msg_conv.is_owned = false;
11647         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11648         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11649 }
11650
11651 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) {
11652         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11653         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11654         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11655         LDKPublicKey their_node_id_ref;
11656         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11657         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11658         LDKUpdateAddHTLC msg_conv;
11659         msg_conv.inner = (void*)(msg & (~1));
11660         msg_conv.is_owned = false;
11661         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11662         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11663 }
11664
11665 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) {
11666         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11667         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11668         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11669         LDKPublicKey their_node_id_ref;
11670         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11671         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11672         LDKUpdateFulfillHTLC msg_conv;
11673         msg_conv.inner = (void*)(msg & (~1));
11674         msg_conv.is_owned = false;
11675         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11676         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11677 }
11678
11679 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) {
11680         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11681         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11682         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11683         LDKPublicKey their_node_id_ref;
11684         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11685         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11686         LDKUpdateFailHTLC msg_conv;
11687         msg_conv.inner = (void*)(msg & (~1));
11688         msg_conv.is_owned = false;
11689         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11690         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11691 }
11692
11693 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) {
11694         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11695         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11696         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11697         LDKPublicKey their_node_id_ref;
11698         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11699         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11700         LDKUpdateFailMalformedHTLC msg_conv;
11701         msg_conv.inner = (void*)(msg & (~1));
11702         msg_conv.is_owned = false;
11703         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11704         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11705 }
11706
11707 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) {
11708         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11709         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11710         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11711         LDKPublicKey their_node_id_ref;
11712         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11713         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11714         LDKCommitmentSigned msg_conv;
11715         msg_conv.inner = (void*)(msg & (~1));
11716         msg_conv.is_owned = false;
11717         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11718         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11719 }
11720
11721 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) {
11722         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11723         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11724         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11725         LDKPublicKey their_node_id_ref;
11726         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11727         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11728         LDKRevokeAndACK msg_conv;
11729         msg_conv.inner = (void*)(msg & (~1));
11730         msg_conv.is_owned = false;
11731         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11732         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11733 }
11734
11735 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) {
11736         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11737         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11738         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11739         LDKPublicKey their_node_id_ref;
11740         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11741         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11742         LDKUpdateFee msg_conv;
11743         msg_conv.inner = (void*)(msg & (~1));
11744         msg_conv.is_owned = false;
11745         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11746         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11747 }
11748
11749 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) {
11750         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11751         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11752         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11753         LDKPublicKey their_node_id_ref;
11754         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11755         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11756         LDKAnnouncementSignatures msg_conv;
11757         msg_conv.inner = (void*)(msg & (~1));
11758         msg_conv.is_owned = false;
11759         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11760         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11761 }
11762
11763 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) {
11764         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11765         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11766         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11767         LDKPublicKey their_node_id_ref;
11768         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11769         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11770         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
11771 }
11772
11773 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) {
11774         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11775         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11776         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11777         LDKPublicKey their_node_id_ref;
11778         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11779         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11780         LDKInit msg_conv;
11781         msg_conv.inner = (void*)(msg & (~1));
11782         msg_conv.is_owned = false;
11783         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11784         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11785 }
11786
11787 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) {
11788         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11789         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11790         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11791         LDKPublicKey their_node_id_ref;
11792         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11793         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11794         LDKChannelReestablish msg_conv;
11795         msg_conv.inner = (void*)(msg & (~1));
11796         msg_conv.is_owned = false;
11797         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11798         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11799 }
11800
11801 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) {
11802         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11803         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11804         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11805         LDKPublicKey their_node_id_ref;
11806         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11807         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11808         LDKChannelUpdate msg_conv;
11809         msg_conv.inner = (void*)(msg & (~1));
11810         msg_conv.is_owned = false;
11811         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11812         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11813 }
11814
11815 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) {
11816         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11817         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11818         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11819         LDKPublicKey their_node_id_ref;
11820         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11821         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11822         LDKErrorMessage msg_conv;
11823         msg_conv.inner = (void*)(msg & (~1));
11824         msg_conv.is_owned = false;
11825         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11826         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11827 }
11828
11829 typedef struct LDKRoutingMessageHandler_JCalls {
11830         atomic_size_t refcnt;
11831         JavaVM *vm;
11832         jweak o;
11833         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
11834         jmethodID handle_node_announcement_meth;
11835         jmethodID handle_channel_announcement_meth;
11836         jmethodID handle_channel_update_meth;
11837         jmethodID get_next_channel_announcements_meth;
11838         jmethodID get_next_node_announcements_meth;
11839         jmethodID peer_connected_meth;
11840         jmethodID handle_reply_channel_range_meth;
11841         jmethodID handle_reply_short_channel_ids_end_meth;
11842         jmethodID handle_query_channel_range_meth;
11843         jmethodID handle_query_short_channel_ids_meth;
11844 } LDKRoutingMessageHandler_JCalls;
11845 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
11846         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11847         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11848                 JNIEnv *env;
11849                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11850                 if (get_jenv_res == JNI_EDETACHED) {
11851                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11852                 } else {
11853                         DO_ASSERT(get_jenv_res == JNI_OK);
11854                 }
11855                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11856                 if (get_jenv_res == JNI_EDETACHED) {
11857                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11858                 }
11859                 FREE(j_calls);
11860         }
11861 }
11862 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
11863         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11864         JNIEnv *env;
11865         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11866         if (get_jenv_res == JNI_EDETACHED) {
11867                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11868         } else {
11869                 DO_ASSERT(get_jenv_res == JNI_OK);
11870         }
11871         LDKNodeAnnouncement msg_var = *msg;
11872         int64_t msg_ref = 0;
11873         msg_var = NodeAnnouncement_clone(&msg_var);
11874         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11875         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11876         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11877         msg_ref = (uintptr_t)msg_var.inner;
11878         if (msg_var.is_owned) {
11879                 msg_ref |= 1;
11880         }
11881         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11882         CHECK(obj != NULL);
11883         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
11884         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11885                 (*env)->ExceptionDescribe(env);
11886                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
11887         }
11888         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11889         CHECK_ACCESS(ret_ptr);
11890         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11891         FREE((void*)ret);
11892         if (get_jenv_res == JNI_EDETACHED) {
11893                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11894         }
11895         return ret_conv;
11896 }
11897 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
11898         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11899         JNIEnv *env;
11900         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11901         if (get_jenv_res == JNI_EDETACHED) {
11902                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11903         } else {
11904                 DO_ASSERT(get_jenv_res == JNI_OK);
11905         }
11906         LDKChannelAnnouncement msg_var = *msg;
11907         int64_t msg_ref = 0;
11908         msg_var = ChannelAnnouncement_clone(&msg_var);
11909         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11910         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11911         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11912         msg_ref = (uintptr_t)msg_var.inner;
11913         if (msg_var.is_owned) {
11914                 msg_ref |= 1;
11915         }
11916         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11917         CHECK(obj != NULL);
11918         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
11919         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11920                 (*env)->ExceptionDescribe(env);
11921                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
11922         }
11923         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11924         CHECK_ACCESS(ret_ptr);
11925         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11926         FREE((void*)ret);
11927         if (get_jenv_res == JNI_EDETACHED) {
11928                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11929         }
11930         return ret_conv;
11931 }
11932 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
11933         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11934         JNIEnv *env;
11935         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11936         if (get_jenv_res == JNI_EDETACHED) {
11937                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11938         } else {
11939                 DO_ASSERT(get_jenv_res == JNI_OK);
11940         }
11941         LDKChannelUpdate msg_var = *msg;
11942         int64_t msg_ref = 0;
11943         msg_var = ChannelUpdate_clone(&msg_var);
11944         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11945         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11946         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11947         msg_ref = (uintptr_t)msg_var.inner;
11948         if (msg_var.is_owned) {
11949                 msg_ref |= 1;
11950         }
11951         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11952         CHECK(obj != NULL);
11953         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
11954         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11955                 (*env)->ExceptionDescribe(env);
11956                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
11957         }
11958         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11959         CHECK_ACCESS(ret_ptr);
11960         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11961         FREE((void*)ret);
11962         if (get_jenv_res == JNI_EDETACHED) {
11963                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11964         }
11965         return ret_conv;
11966 }
11967 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
11968         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11969         JNIEnv *env;
11970         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11971         if (get_jenv_res == JNI_EDETACHED) {
11972                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11973         } else {
11974                 DO_ASSERT(get_jenv_res == JNI_OK);
11975         }
11976         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11977         CHECK(obj != NULL);
11978         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
11979         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11980                 (*env)->ExceptionDescribe(env);
11981                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
11982         }
11983         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
11984         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11985         if (ret_constr.datalen > 0)
11986                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11987         else
11988                 ret_constr.data = NULL;
11989         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
11990         for (size_t h = 0; h < ret_constr.datalen; h++) {
11991                 int64_t ret_conv_59 = ret_vals[h];
11992                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
11993                 CHECK_ACCESS(ret_conv_59_ptr);
11994                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
11995                 FREE((void*)ret_conv_59);
11996                 ret_constr.data[h] = ret_conv_59_conv;
11997         }
11998         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
11999         if (get_jenv_res == JNI_EDETACHED) {
12000                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12001         }
12002         return ret_constr;
12003 }
12004 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
12005         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12006         JNIEnv *env;
12007         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12008         if (get_jenv_res == JNI_EDETACHED) {
12009                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12010         } else {
12011                 DO_ASSERT(get_jenv_res == JNI_OK);
12012         }
12013         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
12014         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
12015         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12016         CHECK(obj != NULL);
12017         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
12018         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12019                 (*env)->ExceptionDescribe(env);
12020                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
12021         }
12022         LDKCVec_NodeAnnouncementZ ret_constr;
12023         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12024         if (ret_constr.datalen > 0)
12025                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
12026         else
12027                 ret_constr.data = NULL;
12028         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12029         for (size_t s = 0; s < ret_constr.datalen; s++) {
12030                 int64_t ret_conv_18 = ret_vals[s];
12031                 LDKNodeAnnouncement ret_conv_18_conv;
12032                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
12033                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
12034                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
12035                 ret_constr.data[s] = ret_conv_18_conv;
12036         }
12037         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12038         if (get_jenv_res == JNI_EDETACHED) {
12039                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12040         }
12041         return ret_constr;
12042 }
12043 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
12044         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12045         JNIEnv *env;
12046         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12047         if (get_jenv_res == JNI_EDETACHED) {
12048                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12049         } else {
12050                 DO_ASSERT(get_jenv_res == JNI_OK);
12051         }
12052         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12053         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12054         LDKInit init_var = *init;
12055         int64_t init_ref = 0;
12056         init_var = Init_clone(&init_var);
12057         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12058         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12059         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
12060         init_ref = (uintptr_t)init_var.inner;
12061         if (init_var.is_owned) {
12062                 init_ref |= 1;
12063         }
12064         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12065         CHECK(obj != NULL);
12066         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
12067         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12068                 (*env)->ExceptionDescribe(env);
12069                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler from rust threw an exception.");
12070         }
12071         if (get_jenv_res == JNI_EDETACHED) {
12072                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12073         }
12074 }
12075 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
12076         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12077         JNIEnv *env;
12078         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12079         if (get_jenv_res == JNI_EDETACHED) {
12080                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12081         } else {
12082                 DO_ASSERT(get_jenv_res == JNI_OK);
12083         }
12084         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12085         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12086         LDKReplyChannelRange msg_var = msg;
12087         int64_t msg_ref = 0;
12088         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12089         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12090         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12091         msg_ref = (uintptr_t)msg_var.inner;
12092         if (msg_var.is_owned) {
12093                 msg_ref |= 1;
12094         }
12095         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12096         CHECK(obj != NULL);
12097         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
12098         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12099                 (*env)->ExceptionDescribe(env);
12100                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
12101         }
12102         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12103         CHECK_ACCESS(ret_ptr);
12104         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12105         FREE((void*)ret);
12106         if (get_jenv_res == JNI_EDETACHED) {
12107                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12108         }
12109         return ret_conv;
12110 }
12111 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
12112         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12113         JNIEnv *env;
12114         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12115         if (get_jenv_res == JNI_EDETACHED) {
12116                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12117         } else {
12118                 DO_ASSERT(get_jenv_res == JNI_OK);
12119         }
12120         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12121         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12122         LDKReplyShortChannelIdsEnd msg_var = msg;
12123         int64_t msg_ref = 0;
12124         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12125         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12126         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12127         msg_ref = (uintptr_t)msg_var.inner;
12128         if (msg_var.is_owned) {
12129                 msg_ref |= 1;
12130         }
12131         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12132         CHECK(obj != NULL);
12133         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
12134         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12135                 (*env)->ExceptionDescribe(env);
12136                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
12137         }
12138         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12139         CHECK_ACCESS(ret_ptr);
12140         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12141         FREE((void*)ret);
12142         if (get_jenv_res == JNI_EDETACHED) {
12143                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12144         }
12145         return ret_conv;
12146 }
12147 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
12148         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12149         JNIEnv *env;
12150         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12151         if (get_jenv_res == JNI_EDETACHED) {
12152                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12153         } else {
12154                 DO_ASSERT(get_jenv_res == JNI_OK);
12155         }
12156         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12157         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12158         LDKQueryChannelRange msg_var = msg;
12159         int64_t msg_ref = 0;
12160         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12161         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12162         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12163         msg_ref = (uintptr_t)msg_var.inner;
12164         if (msg_var.is_owned) {
12165                 msg_ref |= 1;
12166         }
12167         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12168         CHECK(obj != NULL);
12169         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
12170         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12171                 (*env)->ExceptionDescribe(env);
12172                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
12173         }
12174         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12175         CHECK_ACCESS(ret_ptr);
12176         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12177         FREE((void*)ret);
12178         if (get_jenv_res == JNI_EDETACHED) {
12179                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12180         }
12181         return ret_conv;
12182 }
12183 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
12184         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12185         JNIEnv *env;
12186         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12187         if (get_jenv_res == JNI_EDETACHED) {
12188                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12189         } else {
12190                 DO_ASSERT(get_jenv_res == JNI_OK);
12191         }
12192         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12193         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12194         LDKQueryShortChannelIds msg_var = msg;
12195         int64_t msg_ref = 0;
12196         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12197         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12198         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12199         msg_ref = (uintptr_t)msg_var.inner;
12200         if (msg_var.is_owned) {
12201                 msg_ref |= 1;
12202         }
12203         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12204         CHECK(obj != NULL);
12205         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
12206         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12207                 (*env)->ExceptionDescribe(env);
12208                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
12209         }
12210         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12211         CHECK_ACCESS(ret_ptr);
12212         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12213         FREE((void*)ret);
12214         if (get_jenv_res == JNI_EDETACHED) {
12215                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12216         }
12217         return ret_conv;
12218 }
12219 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
12220         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
12221         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12222         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
12223 }
12224 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12225         jclass c = (*env)->GetObjectClass(env, o);
12226         CHECK(c != NULL);
12227         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
12228         atomic_init(&calls->refcnt, 1);
12229         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12230         calls->o = (*env)->NewWeakGlobalRef(env, o);
12231         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
12232         CHECK(calls->handle_node_announcement_meth != NULL);
12233         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
12234         CHECK(calls->handle_channel_announcement_meth != NULL);
12235         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
12236         CHECK(calls->handle_channel_update_meth != NULL);
12237         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
12238         CHECK(calls->get_next_channel_announcements_meth != NULL);
12239         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
12240         CHECK(calls->get_next_node_announcements_meth != NULL);
12241         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
12242         CHECK(calls->peer_connected_meth != NULL);
12243         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
12244         CHECK(calls->handle_reply_channel_range_meth != NULL);
12245         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
12246         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
12247         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
12248         CHECK(calls->handle_query_channel_range_meth != NULL);
12249         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
12250         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
12251
12252         LDKRoutingMessageHandler ret = {
12253                 .this_arg = (void*) calls,
12254                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
12255                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
12256                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
12257                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
12258                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
12259                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
12260                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
12261                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
12262                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
12263                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
12264                 .free = LDKRoutingMessageHandler_JCalls_free,
12265                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
12266         };
12267         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
12268         return ret;
12269 }
12270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12271         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
12272         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
12273         return (uint64_t)res_ptr;
12274 }
12275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
12276         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
12277         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
12278         DO_ASSERT((res_ptr & 1) == 0);
12279         return (int64_t)(res_ptr | 1);
12280 }
12281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
12282         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12283         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12284         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12285         LDKNodeAnnouncement msg_conv;
12286         msg_conv.inner = (void*)(msg & (~1));
12287         msg_conv.is_owned = false;
12288         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12289         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
12290         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
12291         return (int64_t)ret_conv;
12292 }
12293
12294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
12295         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12296         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12297         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12298         LDKChannelAnnouncement msg_conv;
12299         msg_conv.inner = (void*)(msg & (~1));
12300         msg_conv.is_owned = false;
12301         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12302         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
12303         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
12304         return (int64_t)ret_conv;
12305 }
12306
12307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
12308         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12309         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12310         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12311         LDKChannelUpdate msg_conv;
12312         msg_conv.inner = (void*)(msg & (~1));
12313         msg_conv.is_owned = false;
12314         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12315         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
12316         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
12317         return (int64_t)ret_conv;
12318 }
12319
12320 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) {
12321         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12322         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12323         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12324         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
12325         int64_tArray ret_arr = NULL;
12326         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12327         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12328         for (size_t h = 0; h < ret_var.datalen; h++) {
12329                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
12330                 *ret_conv_59_conv = ret_var.data[h];
12331                 ret_arr_ptr[h] = ((int64_t)ret_conv_59_conv);
12332         }
12333         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12334         FREE(ret_var.data);
12335         return ret_arr;
12336 }
12337
12338 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) {
12339         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12340         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12341         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12342         LDKPublicKey starting_point_ref;
12343         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
12344         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
12345         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
12346         int64_tArray ret_arr = NULL;
12347         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12348         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12349         for (size_t s = 0; s < ret_var.datalen; s++) {
12350                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
12351                 int64_t ret_conv_18_ref = 0;
12352                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12353                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12354                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
12355                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
12356                 if (ret_conv_18_var.is_owned) {
12357                         ret_conv_18_ref |= 1;
12358                 }
12359                 ret_arr_ptr[s] = ret_conv_18_ref;
12360         }
12361         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12362         FREE(ret_var.data);
12363         return ret_arr;
12364 }
12365
12366 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) {
12367         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12368         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12369         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12370         LDKPublicKey their_node_id_ref;
12371         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12372         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12373         LDKInit init_conv;
12374         init_conv.inner = (void*)(init & (~1));
12375         init_conv.is_owned = false;
12376         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
12377         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
12378 }
12379
12380 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) {
12381         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12382         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12383         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)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         LDKReplyChannelRange msg_conv;
12388         msg_conv.inner = (void*)(msg & (~1));
12389         msg_conv.is_owned = (msg & 1) || (msg == 0);
12390         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12391         msg_conv = ReplyChannelRange_clone(&msg_conv);
12392         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12393         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12394         return (int64_t)ret_conv;
12395 }
12396
12397 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) {
12398         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12399         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12400         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12401         LDKPublicKey their_node_id_ref;
12402         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12403         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12404         LDKReplyShortChannelIdsEnd msg_conv;
12405         msg_conv.inner = (void*)(msg & (~1));
12406         msg_conv.is_owned = (msg & 1) || (msg == 0);
12407         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12408         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
12409         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12410         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12411         return (int64_t)ret_conv;
12412 }
12413
12414 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) {
12415         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12416         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12417         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12418         LDKPublicKey their_node_id_ref;
12419         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12420         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12421         LDKQueryChannelRange msg_conv;
12422         msg_conv.inner = (void*)(msg & (~1));
12423         msg_conv.is_owned = (msg & 1) || (msg == 0);
12424         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12425         msg_conv = QueryChannelRange_clone(&msg_conv);
12426         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12427         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12428         return (int64_t)ret_conv;
12429 }
12430
12431 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) {
12432         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12433         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12434         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12435         LDKPublicKey their_node_id_ref;
12436         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12437         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12438         LDKQueryShortChannelIds msg_conv;
12439         msg_conv.inner = (void*)(msg & (~1));
12440         msg_conv.is_owned = (msg & 1) || (msg == 0);
12441         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12442         msg_conv = QueryShortChannelIds_clone(&msg_conv);
12443         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12444         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12445         return (int64_t)ret_conv;
12446 }
12447
12448 typedef struct LDKCustomMessageReader_JCalls {
12449         atomic_size_t refcnt;
12450         JavaVM *vm;
12451         jweak o;
12452         jmethodID read_meth;
12453 } LDKCustomMessageReader_JCalls;
12454 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
12455         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
12456         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12457                 JNIEnv *env;
12458                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12459                 if (get_jenv_res == JNI_EDETACHED) {
12460                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12461                 } else {
12462                         DO_ASSERT(get_jenv_res == JNI_OK);
12463                 }
12464                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12465                 if (get_jenv_res == JNI_EDETACHED) {
12466                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12467                 }
12468                 FREE(j_calls);
12469         }
12470 }
12471 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
12472         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
12473         JNIEnv *env;
12474         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12475         if (get_jenv_res == JNI_EDETACHED) {
12476                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12477         } else {
12478                 DO_ASSERT(get_jenv_res == JNI_OK);
12479         }
12480         LDKu8slice buffer_var = buffer;
12481         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
12482         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
12483         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12484         CHECK(obj != NULL);
12485         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type, buffer_arr);
12486         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12487                 (*env)->ExceptionDescribe(env);
12488                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
12489         }
12490         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12491         CHECK_ACCESS(ret_ptr);
12492         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
12493         FREE((void*)ret);
12494         if (get_jenv_res == JNI_EDETACHED) {
12495                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12496         }
12497         return ret_conv;
12498 }
12499 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
12500         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
12501         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12502 }
12503 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
12504         jclass c = (*env)->GetObjectClass(env, o);
12505         CHECK(c != NULL);
12506         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
12507         atomic_init(&calls->refcnt, 1);
12508         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12509         calls->o = (*env)->NewWeakGlobalRef(env, o);
12510         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
12511         CHECK(calls->read_meth != NULL);
12512
12513         LDKCustomMessageReader ret = {
12514                 .this_arg = (void*) calls,
12515                 .read = read_LDKCustomMessageReader_jcall,
12516                 .free = LDKCustomMessageReader_JCalls_free,
12517         };
12518         return ret;
12519 }
12520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
12521         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
12522         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
12523         return (uint64_t)res_ptr;
12524 }
12525 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) {
12526         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12527         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12528         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
12529         LDKu8slice buffer_ref;
12530         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
12531         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
12532         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12533         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
12534         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
12535         return (int64_t)ret_conv;
12536 }
12537
12538 typedef struct LDKCustomMessageHandler_JCalls {
12539         atomic_size_t refcnt;
12540         JavaVM *vm;
12541         jweak o;
12542         LDKCustomMessageReader_JCalls* CustomMessageReader;
12543         jmethodID handle_custom_message_meth;
12544         jmethodID get_and_clear_pending_msg_meth;
12545 } LDKCustomMessageHandler_JCalls;
12546 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
12547         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12548         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12549                 JNIEnv *env;
12550                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12551                 if (get_jenv_res == JNI_EDETACHED) {
12552                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12553                 } else {
12554                         DO_ASSERT(get_jenv_res == JNI_OK);
12555                 }
12556                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12557                 if (get_jenv_res == JNI_EDETACHED) {
12558                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12559                 }
12560                 FREE(j_calls);
12561         }
12562 }
12563 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
12564         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12565         JNIEnv *env;
12566         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12567         if (get_jenv_res == JNI_EDETACHED) {
12568                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12569         } else {
12570                 DO_ASSERT(get_jenv_res == JNI_OK);
12571         }
12572         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
12573         *msg_ret = msg;
12574         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
12575         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
12576         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12577         CHECK(obj != NULL);
12578         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (int64_t)msg_ret, sender_node_id_arr);
12579         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12580                 (*env)->ExceptionDescribe(env);
12581                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
12582         }
12583         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12584         CHECK_ACCESS(ret_ptr);
12585         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12586         FREE((void*)ret);
12587         if (get_jenv_res == JNI_EDETACHED) {
12588                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12589         }
12590         return ret_conv;
12591 }
12592 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
12593         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12594         JNIEnv *env;
12595         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12596         if (get_jenv_res == JNI_EDETACHED) {
12597                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12598         } else {
12599                 DO_ASSERT(get_jenv_res == JNI_OK);
12600         }
12601         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12602         CHECK(obj != NULL);
12603         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
12604         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12605                 (*env)->ExceptionDescribe(env);
12606                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
12607         }
12608         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
12609         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12610         if (ret_constr.datalen > 0)
12611                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
12612         else
12613                 ret_constr.data = NULL;
12614         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12615         for (size_t z = 0; z < ret_constr.datalen; z++) {
12616                 int64_t ret_conv_25 = ret_vals[z];
12617                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
12618                 CHECK_ACCESS(ret_conv_25_ptr);
12619                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
12620                 FREE((void*)ret_conv_25);
12621                 ret_constr.data[z] = ret_conv_25_conv;
12622         }
12623         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12624         if (get_jenv_res == JNI_EDETACHED) {
12625                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12626         }
12627         return ret_constr;
12628 }
12629 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
12630         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
12631         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12632         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
12633 }
12634 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
12635         jclass c = (*env)->GetObjectClass(env, o);
12636         CHECK(c != NULL);
12637         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
12638         atomic_init(&calls->refcnt, 1);
12639         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12640         calls->o = (*env)->NewWeakGlobalRef(env, o);
12641         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
12642         CHECK(calls->handle_custom_message_meth != NULL);
12643         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
12644         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
12645
12646         LDKCustomMessageHandler ret = {
12647                 .this_arg = (void*) calls,
12648                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
12649                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
12650                 .free = LDKCustomMessageHandler_JCalls_free,
12651                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
12652         };
12653         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
12654         return ret;
12655 }
12656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
12657         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
12658         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
12659         return (uint64_t)res_ptr;
12660 }
12661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
12662         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
12663         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
12664         DO_ASSERT((res_ptr & 1) == 0);
12665         return (int64_t)(res_ptr | 1);
12666 }
12667 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) {
12668         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12669         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12670         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
12671         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
12672         CHECK_ACCESS(msg_ptr);
12673         LDKType msg_conv = *(LDKType*)(msg_ptr);
12674         if (msg_conv.free == LDKType_JCalls_free) {
12675                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12676                 LDKType_JCalls_cloned(&msg_conv);
12677         }
12678         LDKPublicKey sender_node_id_ref;
12679         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
12680         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
12681         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12682         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
12683         return (int64_t)ret_conv;
12684 }
12685
12686 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
12687         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12688         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12689         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
12690         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
12691         int64_tArray ret_arr = NULL;
12692         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12693         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12694         for (size_t z = 0; z < ret_var.datalen; z++) {
12695                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
12696                 *ret_conv_25_conv = ret_var.data[z];
12697                 ret_arr_ptr[z] = ((int64_t)ret_conv_25_conv);
12698         }
12699         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12700         FREE(ret_var.data);
12701         return ret_arr;
12702 }
12703
12704 typedef struct LDKSocketDescriptor_JCalls {
12705         atomic_size_t refcnt;
12706         JavaVM *vm;
12707         jweak o;
12708         jmethodID send_data_meth;
12709         jmethodID disconnect_socket_meth;
12710         jmethodID eq_meth;
12711         jmethodID hash_meth;
12712 } LDKSocketDescriptor_JCalls;
12713 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
12714         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12715         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12716                 JNIEnv *env;
12717                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12718                 if (get_jenv_res == JNI_EDETACHED) {
12719                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12720                 } else {
12721                         DO_ASSERT(get_jenv_res == JNI_OK);
12722                 }
12723                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12724                 if (get_jenv_res == JNI_EDETACHED) {
12725                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12726                 }
12727                 FREE(j_calls);
12728         }
12729 }
12730 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
12731         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12732         JNIEnv *env;
12733         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12734         if (get_jenv_res == JNI_EDETACHED) {
12735                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12736         } else {
12737                 DO_ASSERT(get_jenv_res == JNI_OK);
12738         }
12739         LDKu8slice data_var = data;
12740         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
12741         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
12742         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12743         CHECK(obj != NULL);
12744         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
12745         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12746                 (*env)->ExceptionDescribe(env);
12747                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
12748         }
12749         if (get_jenv_res == JNI_EDETACHED) {
12750                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12751         }
12752         return ret;
12753 }
12754 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
12755         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12756         JNIEnv *env;
12757         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12758         if (get_jenv_res == JNI_EDETACHED) {
12759                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12760         } else {
12761                 DO_ASSERT(get_jenv_res == JNI_OK);
12762         }
12763         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12764         CHECK(obj != NULL);
12765         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
12766         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12767                 (*env)->ExceptionDescribe(env);
12768                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
12769         }
12770         if (get_jenv_res == JNI_EDETACHED) {
12771                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12772         }
12773 }
12774 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
12775         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12776         JNIEnv *env;
12777         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12778         if (get_jenv_res == JNI_EDETACHED) {
12779                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12780         } else {
12781                 DO_ASSERT(get_jenv_res == JNI_OK);
12782         }
12783         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
12784         *other_arg_clone = SocketDescriptor_clone(other_arg);
12785         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12786         CHECK(obj != NULL);
12787         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (int64_t)other_arg_clone);
12788         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12789                 (*env)->ExceptionDescribe(env);
12790                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
12791         }
12792         if (get_jenv_res == JNI_EDETACHED) {
12793                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12794         }
12795         return ret;
12796 }
12797 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
12798         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12799         JNIEnv *env;
12800         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12801         if (get_jenv_res == JNI_EDETACHED) {
12802                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12803         } else {
12804                 DO_ASSERT(get_jenv_res == JNI_OK);
12805         }
12806         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12807         CHECK(obj != NULL);
12808         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
12809         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12810                 (*env)->ExceptionDescribe(env);
12811                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
12812         }
12813         if (get_jenv_res == JNI_EDETACHED) {
12814                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12815         }
12816         return ret;
12817 }
12818 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
12819         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
12820         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12821 }
12822 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
12823         jclass c = (*env)->GetObjectClass(env, o);
12824         CHECK(c != NULL);
12825         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
12826         atomic_init(&calls->refcnt, 1);
12827         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12828         calls->o = (*env)->NewWeakGlobalRef(env, o);
12829         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
12830         CHECK(calls->send_data_meth != NULL);
12831         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
12832         CHECK(calls->disconnect_socket_meth != NULL);
12833         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
12834         CHECK(calls->eq_meth != NULL);
12835         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
12836         CHECK(calls->hash_meth != NULL);
12837
12838         LDKSocketDescriptor ret = {
12839                 .this_arg = (void*) calls,
12840                 .send_data = send_data_LDKSocketDescriptor_jcall,
12841                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
12842                 .eq = eq_LDKSocketDescriptor_jcall,
12843                 .hash = hash_LDKSocketDescriptor_jcall,
12844                 .cloned = LDKSocketDescriptor_JCalls_cloned,
12845                 .free = LDKSocketDescriptor_JCalls_free,
12846         };
12847         return ret;
12848 }
12849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
12850         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
12851         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
12852         return (uint64_t)res_ptr;
12853 }
12854 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) {
12855         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12856         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12857         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12858         LDKu8slice data_ref;
12859         data_ref.datalen = (*env)->GetArrayLength(env, data);
12860         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
12861         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
12862         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
12863         return ret_val;
12864 }
12865
12866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
12867         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12868         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12869         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12870         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
12871 }
12872
12873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
12874         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12875         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12876         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12877         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
12878         return ret_val;
12879 }
12880
12881 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
12882 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
12883 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
12884 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
12885 static jclass LDKEffectiveCapacity_Total_class = NULL;
12886 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
12887 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
12888 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
12889 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
12890 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
12891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
12892         LDKEffectiveCapacity_ExactLiquidity_class =
12893                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
12894         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
12895         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
12896         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
12897         LDKEffectiveCapacity_MaximumHTLC_class =
12898                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
12899         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
12900         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
12901         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
12902         LDKEffectiveCapacity_Total_class =
12903                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
12904         CHECK(LDKEffectiveCapacity_Total_class != NULL);
12905         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(J)V");
12906         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
12907         LDKEffectiveCapacity_Infinite_class =
12908                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
12909         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
12910         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
12911         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
12912         LDKEffectiveCapacity_Unknown_class =
12913                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
12914         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
12915         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
12916         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
12917 }
12918 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
12919         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
12920         switch(obj->tag) {
12921                 case LDKEffectiveCapacity_ExactLiquidity: {
12922                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, obj->exact_liquidity.liquidity_msat);
12923                 }
12924                 case LDKEffectiveCapacity_MaximumHTLC: {
12925                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, obj->maximum_htlc.amount_msat);
12926                 }
12927                 case LDKEffectiveCapacity_Total: {
12928                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, obj->total.capacity_msat);
12929                 }
12930                 case LDKEffectiveCapacity_Infinite: {
12931                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
12932                 }
12933                 case LDKEffectiveCapacity_Unknown: {
12934                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
12935                 }
12936                 default: abort();
12937         }
12938 }
12939 typedef struct LDKScore_JCalls {
12940         atomic_size_t refcnt;
12941         JavaVM *vm;
12942         jweak o;
12943         jmethodID channel_penalty_msat_meth;
12944         jmethodID payment_path_failed_meth;
12945         jmethodID payment_path_successful_meth;
12946         jmethodID write_meth;
12947 } LDKScore_JCalls;
12948 static void LDKScore_JCalls_free(void* this_arg) {
12949         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
12950         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12951                 JNIEnv *env;
12952                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12953                 if (get_jenv_res == JNI_EDETACHED) {
12954                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12955                 } else {
12956                         DO_ASSERT(get_jenv_res == JNI_OK);
12957                 }
12958                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12959                 if (get_jenv_res == JNI_EDETACHED) {
12960                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12961                 }
12962                 FREE(j_calls);
12963         }
12964 }
12965 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, uint64_t send_amt_msat, uint64_t capacity_msat, const LDKNodeId * source, const LDKNodeId * target) {
12966         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
12967         JNIEnv *env;
12968         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12969         if (get_jenv_res == JNI_EDETACHED) {
12970                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12971         } else {
12972                 DO_ASSERT(get_jenv_res == JNI_OK);
12973         }
12974         LDKNodeId source_var = *source;
12975         int64_t source_ref = 0;
12976         source_var = NodeId_clone(&source_var);
12977         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12978         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12979         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
12980         source_ref = (uintptr_t)source_var.inner;
12981         if (source_var.is_owned) {
12982                 source_ref |= 1;
12983         }
12984         LDKNodeId target_var = *target;
12985         int64_t target_ref = 0;
12986         target_var = NodeId_clone(&target_var);
12987         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12988         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12989         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
12990         target_ref = (uintptr_t)target_var.inner;
12991         if (target_var.is_owned) {
12992                 target_ref |= 1;
12993         }
12994         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12995         CHECK(obj != NULL);
12996         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id, send_amt_msat, capacity_msat, source_ref, target_ref);
12997         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12998                 (*env)->ExceptionDescribe(env);
12999                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
13000         }
13001         if (get_jenv_res == JNI_EDETACHED) {
13002                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13003         }
13004         return ret;
13005 }
13006 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
13007         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
13008         JNIEnv *env;
13009         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13010         if (get_jenv_res == JNI_EDETACHED) {
13011                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13012         } else {
13013                 DO_ASSERT(get_jenv_res == JNI_OK);
13014         }
13015         LDKCVec_RouteHopZ path_var = path;
13016         int64_tArray path_arr = NULL;
13017         path_arr = (*env)->NewLongArray(env, path_var.datalen);
13018         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
13019         for (size_t k = 0; k < path_var.datalen; k++) {
13020                 LDKRouteHop path_conv_10_var = path_var.data[k];
13021                 int64_t path_conv_10_ref = 0;
13022                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13023                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13024                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
13025                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
13026                 if (path_conv_10_var.is_owned) {
13027                         path_conv_10_ref |= 1;
13028                 }
13029                 path_arr_ptr[k] = path_conv_10_ref;
13030         }
13031         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
13032         FREE(path_var.data);
13033         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13034         CHECK(obj != NULL);
13035         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id);
13036         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13037                 (*env)->ExceptionDescribe(env);
13038                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
13039         }
13040         if (get_jenv_res == JNI_EDETACHED) {
13041                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13042         }
13043 }
13044 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
13045         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
13046         JNIEnv *env;
13047         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13048         if (get_jenv_res == JNI_EDETACHED) {
13049                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13050         } else {
13051                 DO_ASSERT(get_jenv_res == JNI_OK);
13052         }
13053         LDKCVec_RouteHopZ path_var = path;
13054         int64_tArray path_arr = NULL;
13055         path_arr = (*env)->NewLongArray(env, path_var.datalen);
13056         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
13057         for (size_t k = 0; k < path_var.datalen; k++) {
13058                 LDKRouteHop path_conv_10_var = path_var.data[k];
13059                 int64_t path_conv_10_ref = 0;
13060                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13061                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13062                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
13063                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
13064                 if (path_conv_10_var.is_owned) {
13065                         path_conv_10_ref |= 1;
13066                 }
13067                 path_arr_ptr[k] = path_conv_10_ref;
13068         }
13069         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
13070         FREE(path_var.data);
13071         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13072         CHECK(obj != NULL);
13073         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
13074         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13075                 (*env)->ExceptionDescribe(env);
13076                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
13077         }
13078         if (get_jenv_res == JNI_EDETACHED) {
13079                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13080         }
13081 }
13082 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
13083         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
13084         JNIEnv *env;
13085         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13086         if (get_jenv_res == JNI_EDETACHED) {
13087                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13088         } else {
13089                 DO_ASSERT(get_jenv_res == JNI_OK);
13090         }
13091         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13092         CHECK(obj != NULL);
13093         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
13094         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13095                 (*env)->ExceptionDescribe(env);
13096                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
13097         }
13098         LDKCVec_u8Z ret_ref;
13099         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
13100         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
13101         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
13102         if (get_jenv_res == JNI_EDETACHED) {
13103                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13104         }
13105         return ret_ref;
13106 }
13107 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
13108         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
13109         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13110 }
13111 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
13112         jclass c = (*env)->GetObjectClass(env, o);
13113         CHECK(c != NULL);
13114         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
13115         atomic_init(&calls->refcnt, 1);
13116         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13117         calls->o = (*env)->NewWeakGlobalRef(env, o);
13118         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJJ)J");
13119         CHECK(calls->channel_penalty_msat_meth != NULL);
13120         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
13121         CHECK(calls->payment_path_failed_meth != NULL);
13122         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
13123         CHECK(calls->payment_path_successful_meth != NULL);
13124         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
13125         CHECK(calls->write_meth != NULL);
13126
13127         LDKScore ret = {
13128                 .this_arg = (void*) calls,
13129                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
13130                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
13131                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
13132                 .write = write_LDKScore_jcall,
13133                 .free = LDKScore_JCalls_free,
13134         };
13135         return ret;
13136 }
13137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
13138         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
13139         *res_ptr = LDKScore_init(env, clz, o);
13140         return (uint64_t)res_ptr;
13141 }
13142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t send_amt_msat, int64_t capacity_msat, int64_t source, int64_t target) {
13143         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13144         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13145         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
13146         LDKNodeId source_conv;
13147         source_conv.inner = (void*)(source & (~1));
13148         source_conv.is_owned = false;
13149         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
13150         LDKNodeId target_conv;
13151         target_conv.inner = (void*)(target & (~1));
13152         target_conv.is_owned = false;
13153         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
13154         int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, send_amt_msat, capacity_msat, &source_conv, &target_conv);
13155         return ret_val;
13156 }
13157
13158 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) {
13159         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13160         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13161         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
13162         LDKCVec_RouteHopZ path_constr;
13163         path_constr.datalen = (*env)->GetArrayLength(env, path);
13164         if (path_constr.datalen > 0)
13165                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
13166         else
13167                 path_constr.data = NULL;
13168         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
13169         for (size_t k = 0; k < path_constr.datalen; k++) {
13170                 int64_t path_conv_10 = path_vals[k];
13171                 LDKRouteHop path_conv_10_conv;
13172                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
13173                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
13174                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
13175                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
13176                 path_constr.data[k] = path_conv_10_conv;
13177         }
13178         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
13179         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
13180 }
13181
13182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
13183         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13184         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13185         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
13186         LDKCVec_RouteHopZ path_constr;
13187         path_constr.datalen = (*env)->GetArrayLength(env, path);
13188         if (path_constr.datalen > 0)
13189                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
13190         else
13191                 path_constr.data = NULL;
13192         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
13193         for (size_t k = 0; k < path_constr.datalen; k++) {
13194                 int64_t path_conv_10 = path_vals[k];
13195                 LDKRouteHop path_conv_10_conv;
13196                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
13197                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
13198                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
13199                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
13200                 path_constr.data[k] = path_conv_10_conv;
13201         }
13202         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
13203         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
13204 }
13205
13206 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
13207         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13208         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13209         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
13210         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
13211         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13212         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13213         CVec_u8Z_free(ret_var);
13214         return ret_arr;
13215 }
13216
13217 typedef struct LDKLockableScore_JCalls {
13218         atomic_size_t refcnt;
13219         JavaVM *vm;
13220         jweak o;
13221         jmethodID lock_meth;
13222 } LDKLockableScore_JCalls;
13223 static void LDKLockableScore_JCalls_free(void* this_arg) {
13224         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
13225         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13226                 JNIEnv *env;
13227                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13228                 if (get_jenv_res == JNI_EDETACHED) {
13229                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13230                 } else {
13231                         DO_ASSERT(get_jenv_res == JNI_OK);
13232                 }
13233                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13234                 if (get_jenv_res == JNI_EDETACHED) {
13235                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13236                 }
13237                 FREE(j_calls);
13238         }
13239 }
13240 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
13241         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
13242         JNIEnv *env;
13243         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13244         if (get_jenv_res == JNI_EDETACHED) {
13245                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13246         } else {
13247                 DO_ASSERT(get_jenv_res == JNI_OK);
13248         }
13249         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13250         CHECK(obj != NULL);
13251         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
13252         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13253                 (*env)->ExceptionDescribe(env);
13254                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
13255         }
13256         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13257         CHECK_ACCESS(ret_ptr);
13258         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
13259         if (ret_conv.free == LDKScore_JCalls_free) {
13260                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13261                 LDKScore_JCalls_cloned(&ret_conv);
13262         }// WARNING: we may need a move here but no clone is available for LDKScore
13263         
13264         if (get_jenv_res == JNI_EDETACHED) {
13265                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13266         }
13267         return ret_conv;
13268 }
13269 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
13270         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
13271         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13272 }
13273 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
13274         jclass c = (*env)->GetObjectClass(env, o);
13275         CHECK(c != NULL);
13276         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
13277         atomic_init(&calls->refcnt, 1);
13278         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13279         calls->o = (*env)->NewWeakGlobalRef(env, o);
13280         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
13281         CHECK(calls->lock_meth != NULL);
13282
13283         LDKLockableScore ret = {
13284                 .this_arg = (void*) calls,
13285                 .lock = lock_LDKLockableScore_jcall,
13286                 .free = LDKLockableScore_JCalls_free,
13287         };
13288         return ret;
13289 }
13290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
13291         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
13292         *res_ptr = LDKLockableScore_init(env, clz, o);
13293         return (uint64_t)res_ptr;
13294 }
13295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
13296         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13297         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13298         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
13299         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
13300         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
13301         return (int64_t)ret_ret;
13302 }
13303
13304 typedef struct LDKPersister_JCalls {
13305         atomic_size_t refcnt;
13306         JavaVM *vm;
13307         jweak o;
13308         jmethodID persist_manager_meth;
13309         jmethodID persist_graph_meth;
13310 } LDKPersister_JCalls;
13311 static void LDKPersister_JCalls_free(void* this_arg) {
13312         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
13313         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13314                 JNIEnv *env;
13315                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13316                 if (get_jenv_res == JNI_EDETACHED) {
13317                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13318                 } else {
13319                         DO_ASSERT(get_jenv_res == JNI_OK);
13320                 }
13321                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13322                 if (get_jenv_res == JNI_EDETACHED) {
13323                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13324                 }
13325                 FREE(j_calls);
13326         }
13327 }
13328 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
13329         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
13330         JNIEnv *env;
13331         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13332         if (get_jenv_res == JNI_EDETACHED) {
13333                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13334         } else {
13335                 DO_ASSERT(get_jenv_res == JNI_OK);
13336         }
13337         LDKChannelManager channel_manager_var = *channel_manager;
13338         int64_t channel_manager_ref = 0;
13339         // WARNING: we may need a move here but no clone is available for LDKChannelManager
13340         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13341         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13342         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
13343         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
13344         if (channel_manager_var.is_owned) {
13345                 channel_manager_ref |= 1;
13346         }
13347         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13348         CHECK(obj != NULL);
13349         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
13350         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13351                 (*env)->ExceptionDescribe(env);
13352                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
13353         }
13354         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13355         CHECK_ACCESS(ret_ptr);
13356         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
13357         FREE((void*)ret);
13358         if (get_jenv_res == JNI_EDETACHED) {
13359                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13360         }
13361         return ret_conv;
13362 }
13363 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
13364         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
13365         JNIEnv *env;
13366         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13367         if (get_jenv_res == JNI_EDETACHED) {
13368                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13369         } else {
13370                 DO_ASSERT(get_jenv_res == JNI_OK);
13371         }
13372         LDKNetworkGraph network_graph_var = *network_graph;
13373         int64_t network_graph_ref = 0;
13374         network_graph_var = NetworkGraph_clone(&network_graph_var);
13375         CHECK((((uintptr_t)network_graph_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13376         CHECK((((uintptr_t)&network_graph_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13377         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
13378         network_graph_ref = (uintptr_t)network_graph_var.inner;
13379         if (network_graph_var.is_owned) {
13380                 network_graph_ref |= 1;
13381         }
13382         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13383         CHECK(obj != NULL);
13384         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
13385         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13386                 (*env)->ExceptionDescribe(env);
13387                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
13388         }
13389         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13390         CHECK_ACCESS(ret_ptr);
13391         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
13392         FREE((void*)ret);
13393         if (get_jenv_res == JNI_EDETACHED) {
13394                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13395         }
13396         return ret_conv;
13397 }
13398 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
13399         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
13400         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13401 }
13402 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
13403         jclass c = (*env)->GetObjectClass(env, o);
13404         CHECK(c != NULL);
13405         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
13406         atomic_init(&calls->refcnt, 1);
13407         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13408         calls->o = (*env)->NewWeakGlobalRef(env, o);
13409         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
13410         CHECK(calls->persist_manager_meth != NULL);
13411         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
13412         CHECK(calls->persist_graph_meth != NULL);
13413
13414         LDKPersister ret = {
13415                 .this_arg = (void*) calls,
13416                 .persist_manager = persist_manager_LDKPersister_jcall,
13417                 .persist_graph = persist_graph_LDKPersister_jcall,
13418                 .free = LDKPersister_JCalls_free,
13419         };
13420         return ret;
13421 }
13422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
13423         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
13424         *res_ptr = LDKPersister_init(env, clz, o);
13425         return (uint64_t)res_ptr;
13426 }
13427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
13428         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13429         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13430         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
13431         LDKChannelManager channel_manager_conv;
13432         channel_manager_conv.inner = (void*)(channel_manager & (~1));
13433         channel_manager_conv.is_owned = false;
13434         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
13435         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
13436         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
13437         return (int64_t)ret_conv;
13438 }
13439
13440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
13441         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13442         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13443         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
13444         LDKNetworkGraph network_graph_conv;
13445         network_graph_conv.inner = (void*)(network_graph & (~1));
13446         network_graph_conv.is_owned = false;
13447         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
13448         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
13449         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
13450         return (int64_t)ret_conv;
13451 }
13452
13453 static jclass LDKFallback_SegWitProgram_class = NULL;
13454 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
13455 static jclass LDKFallback_PubKeyHash_class = NULL;
13456 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
13457 static jclass LDKFallback_ScriptHash_class = NULL;
13458 static jmethodID LDKFallback_ScriptHash_meth = NULL;
13459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
13460         LDKFallback_SegWitProgram_class =
13461                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
13462         CHECK(LDKFallback_SegWitProgram_class != NULL);
13463         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
13464         CHECK(LDKFallback_SegWitProgram_meth != NULL);
13465         LDKFallback_PubKeyHash_class =
13466                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
13467         CHECK(LDKFallback_PubKeyHash_class != NULL);
13468         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
13469         CHECK(LDKFallback_PubKeyHash_meth != NULL);
13470         LDKFallback_ScriptHash_class =
13471                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
13472         CHECK(LDKFallback_ScriptHash_class != NULL);
13473         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
13474         CHECK(LDKFallback_ScriptHash_meth != NULL);
13475 }
13476 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
13477         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
13478         switch(obj->tag) {
13479                 case LDKFallback_SegWitProgram: {
13480                         uint8_t version_val = obj->seg_wit_program.version._0;
13481                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
13482                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
13483                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
13484                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
13485                 }
13486                 case LDKFallback_PubKeyHash: {
13487                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
13488                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
13489                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
13490                 }
13491                 case LDKFallback_ScriptHash: {
13492                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
13493                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
13494                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
13495                 }
13496                 default: abort();
13497         }
13498 }
13499 typedef struct LDKPayer_JCalls {
13500         atomic_size_t refcnt;
13501         JavaVM *vm;
13502         jweak o;
13503         jmethodID node_id_meth;
13504         jmethodID first_hops_meth;
13505         jmethodID send_payment_meth;
13506         jmethodID send_spontaneous_payment_meth;
13507         jmethodID retry_payment_meth;
13508         jmethodID abandon_payment_meth;
13509 } LDKPayer_JCalls;
13510 static void LDKPayer_JCalls_free(void* this_arg) {
13511         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13512         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13513                 JNIEnv *env;
13514                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13515                 if (get_jenv_res == JNI_EDETACHED) {
13516                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13517                 } else {
13518                         DO_ASSERT(get_jenv_res == JNI_OK);
13519                 }
13520                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13521                 if (get_jenv_res == JNI_EDETACHED) {
13522                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13523                 }
13524                 FREE(j_calls);
13525         }
13526 }
13527 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
13528         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13529         JNIEnv *env;
13530         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13531         if (get_jenv_res == JNI_EDETACHED) {
13532                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13533         } else {
13534                 DO_ASSERT(get_jenv_res == JNI_OK);
13535         }
13536         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13537         CHECK(obj != NULL);
13538         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
13539         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13540                 (*env)->ExceptionDescribe(env);
13541                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
13542         }
13543         LDKPublicKey ret_ref;
13544         CHECK((*env)->GetArrayLength(env, ret) == 33);
13545         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
13546         if (get_jenv_res == JNI_EDETACHED) {
13547                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13548         }
13549         return ret_ref;
13550 }
13551 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
13552         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13553         JNIEnv *env;
13554         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13555         if (get_jenv_res == JNI_EDETACHED) {
13556                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13557         } else {
13558                 DO_ASSERT(get_jenv_res == JNI_OK);
13559         }
13560         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13561         CHECK(obj != NULL);
13562         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
13563         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13564                 (*env)->ExceptionDescribe(env);
13565                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
13566         }
13567         LDKCVec_ChannelDetailsZ ret_constr;
13568         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13569         if (ret_constr.datalen > 0)
13570                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
13571         else
13572                 ret_constr.data = NULL;
13573         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13574         for (size_t q = 0; q < ret_constr.datalen; q++) {
13575                 int64_t ret_conv_16 = ret_vals[q];
13576                 LDKChannelDetails ret_conv_16_conv;
13577                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
13578                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
13579                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
13580                 ret_constr.data[q] = ret_conv_16_conv;
13581         }
13582         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13583         if (get_jenv_res == JNI_EDETACHED) {
13584                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13585         }
13586         return ret_constr;
13587 }
13588 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
13589         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13590         JNIEnv *env;
13591         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13592         if (get_jenv_res == JNI_EDETACHED) {
13593                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13594         } else {
13595                 DO_ASSERT(get_jenv_res == JNI_OK);
13596         }
13597         LDKRoute route_var = *route;
13598         int64_t route_ref = 0;
13599         route_var = Route_clone(&route_var);
13600         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13601         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13602         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13603         route_ref = (uintptr_t)route_var.inner;
13604         if (route_var.is_owned) {
13605                 route_ref |= 1;
13606         }
13607         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
13608         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
13609         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
13610         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
13611         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13612         CHECK(obj != NULL);
13613         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
13614         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13615                 (*env)->ExceptionDescribe(env);
13616                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
13617         }
13618         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13619         CHECK_ACCESS(ret_ptr);
13620         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
13621         FREE((void*)ret);
13622         if (get_jenv_res == JNI_EDETACHED) {
13623                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13624         }
13625         return ret_conv;
13626 }
13627 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
13628         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13629         JNIEnv *env;
13630         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13631         if (get_jenv_res == JNI_EDETACHED) {
13632                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13633         } else {
13634                 DO_ASSERT(get_jenv_res == JNI_OK);
13635         }
13636         LDKRoute route_var = *route;
13637         int64_t route_ref = 0;
13638         route_var = Route_clone(&route_var);
13639         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13640         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13641         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13642         route_ref = (uintptr_t)route_var.inner;
13643         if (route_var.is_owned) {
13644                 route_ref |= 1;
13645         }
13646         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
13647         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
13648         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13649         CHECK(obj != NULL);
13650         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
13651         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13652                 (*env)->ExceptionDescribe(env);
13653                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
13654         }
13655         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13656         CHECK_ACCESS(ret_ptr);
13657         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
13658         FREE((void*)ret);
13659         if (get_jenv_res == JNI_EDETACHED) {
13660                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13661         }
13662         return ret_conv;
13663 }
13664 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
13665         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13666         JNIEnv *env;
13667         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13668         if (get_jenv_res == JNI_EDETACHED) {
13669                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13670         } else {
13671                 DO_ASSERT(get_jenv_res == JNI_OK);
13672         }
13673         LDKRoute route_var = *route;
13674         int64_t route_ref = 0;
13675         route_var = Route_clone(&route_var);
13676         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13677         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13678         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13679         route_ref = (uintptr_t)route_var.inner;
13680         if (route_var.is_owned) {
13681                 route_ref |= 1;
13682         }
13683         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
13684         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
13685         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13686         CHECK(obj != NULL);
13687         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
13688         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13689                 (*env)->ExceptionDescribe(env);
13690                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
13691         }
13692         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13693         CHECK_ACCESS(ret_ptr);
13694         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
13695         FREE((void*)ret);
13696         if (get_jenv_res == JNI_EDETACHED) {
13697                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13698         }
13699         return ret_conv;
13700 }
13701 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
13702         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13703         JNIEnv *env;
13704         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13705         if (get_jenv_res == JNI_EDETACHED) {
13706                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13707         } else {
13708                 DO_ASSERT(get_jenv_res == JNI_OK);
13709         }
13710         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
13711         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
13712         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13713         CHECK(obj != NULL);
13714         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
13715         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13716                 (*env)->ExceptionDescribe(env);
13717                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
13718         }
13719         if (get_jenv_res == JNI_EDETACHED) {
13720                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13721         }
13722 }
13723 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
13724         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
13725         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13726 }
13727 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
13728         jclass c = (*env)->GetObjectClass(env, o);
13729         CHECK(c != NULL);
13730         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
13731         atomic_init(&calls->refcnt, 1);
13732         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13733         calls->o = (*env)->NewWeakGlobalRef(env, o);
13734         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
13735         CHECK(calls->node_id_meth != NULL);
13736         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
13737         CHECK(calls->first_hops_meth != NULL);
13738         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
13739         CHECK(calls->send_payment_meth != NULL);
13740         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
13741         CHECK(calls->send_spontaneous_payment_meth != NULL);
13742         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
13743         CHECK(calls->retry_payment_meth != NULL);
13744         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
13745         CHECK(calls->abandon_payment_meth != NULL);
13746
13747         LDKPayer ret = {
13748                 .this_arg = (void*) calls,
13749                 .node_id = node_id_LDKPayer_jcall,
13750                 .first_hops = first_hops_LDKPayer_jcall,
13751                 .send_payment = send_payment_LDKPayer_jcall,
13752                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
13753                 .retry_payment = retry_payment_LDKPayer_jcall,
13754                 .abandon_payment = abandon_payment_LDKPayer_jcall,
13755                 .free = LDKPayer_JCalls_free,
13756         };
13757         return ret;
13758 }
13759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
13760         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
13761         *res_ptr = LDKPayer_init(env, clz, o);
13762         return (uint64_t)res_ptr;
13763 }
13764 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
13765         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13766         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13767         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13768         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13769         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
13770         return ret_arr;
13771 }
13772
13773 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
13774         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13775         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13776         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13777         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
13778         int64_tArray ret_arr = NULL;
13779         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13780         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13781         for (size_t q = 0; q < ret_var.datalen; q++) {
13782                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13783                 int64_t ret_conv_16_ref = 0;
13784                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13785                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13786                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
13787                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
13788                 if (ret_conv_16_var.is_owned) {
13789                         ret_conv_16_ref |= 1;
13790                 }
13791                 ret_arr_ptr[q] = ret_conv_16_ref;
13792         }
13793         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13794         FREE(ret_var.data);
13795         return ret_arr;
13796 }
13797
13798 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) {
13799         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13800         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13801         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13802         LDKRoute route_conv;
13803         route_conv.inner = (void*)(route & (~1));
13804         route_conv.is_owned = false;
13805         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13806         LDKThirtyTwoBytes payment_hash_ref;
13807         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13808         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
13809         LDKThirtyTwoBytes payment_secret_ref;
13810         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
13811         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
13812         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13813         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
13814         return (int64_t)ret_conv;
13815 }
13816
13817 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) {
13818         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13819         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13820         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13821         LDKRoute route_conv;
13822         route_conv.inner = (void*)(route & (~1));
13823         route_conv.is_owned = false;
13824         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13825         LDKThirtyTwoBytes payment_preimage_ref;
13826         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
13827         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
13828         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13829         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
13830         return (int64_t)ret_conv;
13831 }
13832
13833 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) {
13834         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13835         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13836         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13837         LDKRoute route_conv;
13838         route_conv.inner = (void*)(route & (~1));
13839         route_conv.is_owned = false;
13840         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13841         LDKThirtyTwoBytes payment_id_ref;
13842         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
13843         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
13844         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13845         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
13846         return (int64_t)ret_conv;
13847 }
13848
13849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
13850         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13851         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13852         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13853         LDKThirtyTwoBytes payment_id_ref;
13854         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
13855         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
13856         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
13857 }
13858
13859 typedef struct LDKRouter_JCalls {
13860         atomic_size_t refcnt;
13861         JavaVM *vm;
13862         jweak o;
13863         jmethodID find_route_meth;
13864 } LDKRouter_JCalls;
13865 static void LDKRouter_JCalls_free(void* this_arg) {
13866         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
13867         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13868                 JNIEnv *env;
13869                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13870                 if (get_jenv_res == JNI_EDETACHED) {
13871                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13872                 } else {
13873                         DO_ASSERT(get_jenv_res == JNI_OK);
13874                 }
13875                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13876                 if (get_jenv_res == JNI_EDETACHED) {
13877                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13878                 }
13879                 FREE(j_calls);
13880         }
13881 }
13882 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) {
13883         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
13884         JNIEnv *env;
13885         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13886         if (get_jenv_res == JNI_EDETACHED) {
13887                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13888         } else {
13889                 DO_ASSERT(get_jenv_res == JNI_OK);
13890         }
13891         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
13892         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
13893         LDKRouteParameters route_params_var = *route_params;
13894         int64_t route_params_ref = 0;
13895         route_params_var = RouteParameters_clone(&route_params_var);
13896         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13897         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13898         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
13899         route_params_ref = (uintptr_t)route_params_var.inner;
13900         if (route_params_var.is_owned) {
13901                 route_params_ref |= 1;
13902         }
13903         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
13904         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, *payment_hash);
13905         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
13906         int64_tArray first_hops_arr = NULL;
13907         if (first_hops != NULL) {
13908                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
13909                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
13910                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
13911                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
13912                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
13913                         int64_t first_hops_conv_16_ref = 0;
13914                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13915                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13916                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
13917                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
13918                         if (first_hops_conv_16_var.is_owned) {
13919                                 first_hops_conv_16_ref |= 1;
13920                         }
13921                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
13922                 }
13923                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
13924         }
13925         // WARNING: This object doesn't live past this scope, needs clone!
13926         int64_t ret_scorer = ((uintptr_t)scorer) | 1;
13927         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13928         CHECK(obj != NULL);
13929         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);
13930         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13931                 (*env)->ExceptionDescribe(env);
13932                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
13933         }
13934         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13935         CHECK_ACCESS(ret_ptr);
13936         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
13937         FREE((void*)ret);
13938         if (get_jenv_res == JNI_EDETACHED) {
13939                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13940         }
13941         return ret_conv;
13942 }
13943 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
13944         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
13945         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13946 }
13947 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
13948         jclass c = (*env)->GetObjectClass(env, o);
13949         CHECK(c != NULL);
13950         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
13951         atomic_init(&calls->refcnt, 1);
13952         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13953         calls->o = (*env)->NewWeakGlobalRef(env, o);
13954         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[B[JJ)J");
13955         CHECK(calls->find_route_meth != NULL);
13956
13957         LDKRouter ret = {
13958                 .this_arg = (void*) calls,
13959                 .find_route = find_route_LDKRouter_jcall,
13960                 .free = LDKRouter_JCalls_free,
13961         };
13962         return ret;
13963 }
13964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
13965         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
13966         *res_ptr = LDKRouter_init(env, clz, o);
13967         return (uint64_t)res_ptr;
13968 }
13969 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) {
13970         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13971         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13972         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
13973         LDKPublicKey payer_ref;
13974         CHECK((*env)->GetArrayLength(env, payer) == 33);
13975         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
13976         LDKRouteParameters route_params_conv;
13977         route_params_conv.inner = (void*)(route_params & (~1));
13978         route_params_conv.is_owned = false;
13979         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
13980         unsigned char payment_hash_arr[32];
13981         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13982         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
13983         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
13984         LDKCVec_ChannelDetailsZ first_hops_constr;
13985         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
13986         if (first_hops != NULL) {
13987                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
13988                 if (first_hops_constr.datalen > 0)
13989                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
13990                 else
13991                         first_hops_constr.data = NULL;
13992                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
13993                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
13994                         int64_t first_hops_conv_16 = first_hops_vals[q];
13995                         LDKChannelDetails first_hops_conv_16_conv;
13996                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
13997                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
13998                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
13999                         first_hops_constr.data[q] = first_hops_conv_16_conv;
14000                 }
14001                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
14002                 first_hops_ptr = &first_hops_constr;
14003         }
14004         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
14005         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
14006         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
14007         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14008         *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);
14009         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
14010         return (int64_t)ret_conv;
14011 }
14012
14013 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14014         LDKStr ret_str = _ldk_get_compiled_version();
14015         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14016         Str_free(ret_str);
14017         return ret_conv;
14018 }
14019
14020 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14021         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
14022         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14023         Str_free(ret_str);
14024         return ret_conv;
14025 }
14026
14027 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
14028         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14029         *ret_copy = Bech32Error_clone(arg);
14030 int64_t ret_ref = (uintptr_t)ret_copy;
14031         return ret_ref;
14032 }
14033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14034         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
14035         int64_t ret_val = Bech32Error_clone_ptr(arg_conv);
14036         return ret_val;
14037 }
14038
14039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14040         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
14041         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14042         *ret_copy = Bech32Error_clone(orig_conv);
14043         int64_t ret_ref = (uintptr_t)ret_copy;
14044         return ret_ref;
14045 }
14046
14047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
14048         if ((o & 1) != 0) return;
14049         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14050         CHECK_ACCESS(o_ptr);
14051         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
14052         FREE((void*)o);
14053         Bech32Error_free(o_conv);
14054 }
14055
14056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
14057         LDKTransaction _res_ref;
14058         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
14059         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
14060         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
14061         _res_ref.data_is_owned = true;
14062         Transaction_free(_res_ref);
14063 }
14064
14065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
14066         LDKCVec_u8Z script_pubkey_ref;
14067         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
14068         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
14069         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
14070         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14071         *ret_ref = TxOut_new(script_pubkey_ref, value);
14072         return (int64_t)ret_ref;
14073 }
14074
14075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
14076         if ((_res & 1) != 0) return;
14077         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14078         CHECK_ACCESS(_res_ptr);
14079         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
14080         FREE((void*)_res);
14081         TxOut_free(_res_conv);
14082 }
14083
14084 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
14085         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14086         *ret_ref = TxOut_clone(arg);
14087         return (int64_t)ret_ref;
14088 }
14089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14090         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
14091         int64_t ret_val = TxOut_clone_ptr(arg_conv);
14092         return ret_val;
14093 }
14094
14095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14096         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
14097         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14098         *ret_ref = TxOut_clone(orig_conv);
14099         return (int64_t)ret_ref;
14100 }
14101
14102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
14103         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
14104         Str_free(dummy);
14105 }
14106
14107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
14108         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14109         *ret_conv = CResult_NoneNoneZ_ok();
14110         return (int64_t)ret_conv;
14111 }
14112
14113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
14114         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14115         *ret_conv = CResult_NoneNoneZ_err();
14116         return (int64_t)ret_conv;
14117 }
14118
14119 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14120         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
14121         jboolean ret_val = CResult_NoneNoneZ_is_ok(o_conv);
14122         return ret_val;
14123 }
14124
14125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14126         if ((_res & 1) != 0) return;
14127         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14128         CHECK_ACCESS(_res_ptr);
14129         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
14130         FREE((void*)_res);
14131         CResult_NoneNoneZ_free(_res_conv);
14132 }
14133
14134 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
14135         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14136         *ret_conv = CResult_NoneNoneZ_clone(arg);
14137         return (int64_t)ret_conv;
14138 }
14139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14140         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
14141         int64_t ret_val = CResult_NoneNoneZ_clone_ptr(arg_conv);
14142         return ret_val;
14143 }
14144
14145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14146         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
14147         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14148         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
14149         return (int64_t)ret_conv;
14150 }
14151
14152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14153         LDKCounterpartyCommitmentSecrets o_conv;
14154         o_conv.inner = (void*)(o & (~1));
14155         o_conv.is_owned = (o & 1) || (o == 0);
14156         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14157         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
14158         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14159         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
14160         return (int64_t)ret_conv;
14161 }
14162
14163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14164         LDKDecodeError e_conv;
14165         e_conv.inner = (void*)(e & (~1));
14166         e_conv.is_owned = (e & 1) || (e == 0);
14167         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14168         e_conv = DecodeError_clone(&e_conv);
14169         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14170         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
14171         return (int64_t)ret_conv;
14172 }
14173
14174 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14175         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
14176         jboolean ret_val = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
14177         return ret_val;
14178 }
14179
14180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14181         if ((_res & 1) != 0) return;
14182         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14183         CHECK_ACCESS(_res_ptr);
14184         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
14185         FREE((void*)_res);
14186         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
14187 }
14188
14189 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
14190         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14191         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
14192         return (int64_t)ret_conv;
14193 }
14194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14195         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
14196         int64_t ret_val = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
14197         return ret_val;
14198 }
14199
14200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14201         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
14202         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14203         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
14204         return (int64_t)ret_conv;
14205 }
14206
14207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14208         LDKSecretKey o_ref;
14209         CHECK((*env)->GetArrayLength(env, o) == 32);
14210         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
14211         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14212         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
14213         return (int64_t)ret_conv;
14214 }
14215
14216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14217         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14218         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14219         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
14220         return (int64_t)ret_conv;
14221 }
14222
14223 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14224         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
14225         jboolean ret_val = CResult_SecretKeyErrorZ_is_ok(o_conv);
14226         return ret_val;
14227 }
14228
14229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14230         if ((_res & 1) != 0) return;
14231         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14232         CHECK_ACCESS(_res_ptr);
14233         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
14234         FREE((void*)_res);
14235         CResult_SecretKeyErrorZ_free(_res_conv);
14236 }
14237
14238 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
14239         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14240         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
14241         return (int64_t)ret_conv;
14242 }
14243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14244         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
14245         int64_t ret_val = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
14246         return ret_val;
14247 }
14248
14249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14250         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
14251         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14252         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
14253         return (int64_t)ret_conv;
14254 }
14255
14256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14257         LDKPublicKey o_ref;
14258         CHECK((*env)->GetArrayLength(env, o) == 33);
14259         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
14260         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14261         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
14262         return (int64_t)ret_conv;
14263 }
14264
14265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14266         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14267         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14268         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
14269         return (int64_t)ret_conv;
14270 }
14271
14272 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14273         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
14274         jboolean ret_val = CResult_PublicKeyErrorZ_is_ok(o_conv);
14275         return ret_val;
14276 }
14277
14278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14279         if ((_res & 1) != 0) return;
14280         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14281         CHECK_ACCESS(_res_ptr);
14282         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
14283         FREE((void*)_res);
14284         CResult_PublicKeyErrorZ_free(_res_conv);
14285 }
14286
14287 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
14288         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14289         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
14290         return (int64_t)ret_conv;
14291 }
14292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14293         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
14294         int64_t ret_val = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
14295         return ret_val;
14296 }
14297
14298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14299         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
14300         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14301         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
14302         return (int64_t)ret_conv;
14303 }
14304
14305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14306         LDKTxCreationKeys o_conv;
14307         o_conv.inner = (void*)(o & (~1));
14308         o_conv.is_owned = (o & 1) || (o == 0);
14309         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14310         o_conv = TxCreationKeys_clone(&o_conv);
14311         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14312         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
14313         return (int64_t)ret_conv;
14314 }
14315
14316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14317         LDKDecodeError e_conv;
14318         e_conv.inner = (void*)(e & (~1));
14319         e_conv.is_owned = (e & 1) || (e == 0);
14320         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14321         e_conv = DecodeError_clone(&e_conv);
14322         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14323         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
14324         return (int64_t)ret_conv;
14325 }
14326
14327 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14328         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
14329         jboolean ret_val = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
14330         return ret_val;
14331 }
14332
14333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14334         if ((_res & 1) != 0) return;
14335         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14336         CHECK_ACCESS(_res_ptr);
14337         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
14338         FREE((void*)_res);
14339         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
14340 }
14341
14342 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
14343         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14344         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
14345         return (int64_t)ret_conv;
14346 }
14347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14348         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
14349         int64_t ret_val = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
14350         return ret_val;
14351 }
14352
14353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14354         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
14355         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14356         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
14357         return (int64_t)ret_conv;
14358 }
14359
14360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14361         LDKChannelPublicKeys o_conv;
14362         o_conv.inner = (void*)(o & (~1));
14363         o_conv.is_owned = (o & 1) || (o == 0);
14364         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14365         o_conv = ChannelPublicKeys_clone(&o_conv);
14366         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14367         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
14368         return (int64_t)ret_conv;
14369 }
14370
14371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14372         LDKDecodeError e_conv;
14373         e_conv.inner = (void*)(e & (~1));
14374         e_conv.is_owned = (e & 1) || (e == 0);
14375         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14376         e_conv = DecodeError_clone(&e_conv);
14377         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14378         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
14379         return (int64_t)ret_conv;
14380 }
14381
14382 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14383         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
14384         jboolean ret_val = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
14385         return ret_val;
14386 }
14387
14388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14389         if ((_res & 1) != 0) return;
14390         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14391         CHECK_ACCESS(_res_ptr);
14392         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
14393         FREE((void*)_res);
14394         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
14395 }
14396
14397 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
14398         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14399         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
14400         return (int64_t)ret_conv;
14401 }
14402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14403         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
14404         int64_t ret_val = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
14405         return ret_val;
14406 }
14407
14408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14409         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
14410         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14411         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
14412         return (int64_t)ret_conv;
14413 }
14414
14415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14416         LDKTxCreationKeys o_conv;
14417         o_conv.inner = (void*)(o & (~1));
14418         o_conv.is_owned = (o & 1) || (o == 0);
14419         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14420         o_conv = TxCreationKeys_clone(&o_conv);
14421         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14422         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
14423         return (int64_t)ret_conv;
14424 }
14425
14426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14427         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14428         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14429         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
14430         return (int64_t)ret_conv;
14431 }
14432
14433 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14434         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
14435         jboolean ret_val = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
14436         return ret_val;
14437 }
14438
14439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14440         if ((_res & 1) != 0) return;
14441         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14442         CHECK_ACCESS(_res_ptr);
14443         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
14444         FREE((void*)_res);
14445         CResult_TxCreationKeysErrorZ_free(_res_conv);
14446 }
14447
14448 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
14449         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14450         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
14451         return (int64_t)ret_conv;
14452 }
14453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14454         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
14455         int64_t ret_val = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
14456         return ret_val;
14457 }
14458
14459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14460         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
14461         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14462         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
14463         return (int64_t)ret_conv;
14464 }
14465
14466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
14467         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14468         *ret_copy = COption_u32Z_some(o);
14469         int64_t ret_ref = (uintptr_t)ret_copy;
14470         return ret_ref;
14471 }
14472
14473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
14474         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14475         *ret_copy = COption_u32Z_none();
14476         int64_t ret_ref = (uintptr_t)ret_copy;
14477         return ret_ref;
14478 }
14479
14480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
14481         if ((_res & 1) != 0) return;
14482         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14483         CHECK_ACCESS(_res_ptr);
14484         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
14485         FREE((void*)_res);
14486         COption_u32Z_free(_res_conv);
14487 }
14488
14489 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
14490         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14491         *ret_copy = COption_u32Z_clone(arg);
14492 int64_t ret_ref = (uintptr_t)ret_copy;
14493         return ret_ref;
14494 }
14495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14496         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
14497         int64_t ret_val = COption_u32Z_clone_ptr(arg_conv);
14498         return ret_val;
14499 }
14500
14501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14502         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
14503         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14504         *ret_copy = COption_u32Z_clone(orig_conv);
14505         int64_t ret_ref = (uintptr_t)ret_copy;
14506         return ret_ref;
14507 }
14508
14509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14510         LDKHTLCOutputInCommitment o_conv;
14511         o_conv.inner = (void*)(o & (~1));
14512         o_conv.is_owned = (o & 1) || (o == 0);
14513         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14514         o_conv = HTLCOutputInCommitment_clone(&o_conv);
14515         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14516         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
14517         return (int64_t)ret_conv;
14518 }
14519
14520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14521         LDKDecodeError e_conv;
14522         e_conv.inner = (void*)(e & (~1));
14523         e_conv.is_owned = (e & 1) || (e == 0);
14524         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14525         e_conv = DecodeError_clone(&e_conv);
14526         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14527         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
14528         return (int64_t)ret_conv;
14529 }
14530
14531 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14532         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
14533         jboolean ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
14534         return ret_val;
14535 }
14536
14537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14538         if ((_res & 1) != 0) return;
14539         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14540         CHECK_ACCESS(_res_ptr);
14541         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
14542         FREE((void*)_res);
14543         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
14544 }
14545
14546 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
14547         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14548         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
14549         return (int64_t)ret_conv;
14550 }
14551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14552         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
14553         int64_t ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
14554         return ret_val;
14555 }
14556
14557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14558         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
14559         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14560         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
14561         return (int64_t)ret_conv;
14562 }
14563
14564 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
14565         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
14566         return ret_conv;
14567 }
14568
14569 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
14570         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
14571         return ret_conv;
14572 }
14573
14574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
14575         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
14576         COption_NoneZ_free(_res_conv);
14577 }
14578
14579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14580         LDKCounterpartyChannelTransactionParameters o_conv;
14581         o_conv.inner = (void*)(o & (~1));
14582         o_conv.is_owned = (o & 1) || (o == 0);
14583         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14584         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
14585         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14586         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
14587         return (int64_t)ret_conv;
14588 }
14589
14590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14591         LDKDecodeError e_conv;
14592         e_conv.inner = (void*)(e & (~1));
14593         e_conv.is_owned = (e & 1) || (e == 0);
14594         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14595         e_conv = DecodeError_clone(&e_conv);
14596         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14597         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
14598         return (int64_t)ret_conv;
14599 }
14600
14601 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14602         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
14603         jboolean ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
14604         return ret_val;
14605 }
14606
14607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14608         if ((_res & 1) != 0) return;
14609         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14610         CHECK_ACCESS(_res_ptr);
14611         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
14612         FREE((void*)_res);
14613         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
14614 }
14615
14616 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
14617         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14618         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
14619         return (int64_t)ret_conv;
14620 }
14621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14622         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
14623         int64_t ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
14624         return ret_val;
14625 }
14626
14627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14628         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
14629         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14630         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
14631         return (int64_t)ret_conv;
14632 }
14633
14634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14635         LDKChannelTransactionParameters o_conv;
14636         o_conv.inner = (void*)(o & (~1));
14637         o_conv.is_owned = (o & 1) || (o == 0);
14638         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14639         o_conv = ChannelTransactionParameters_clone(&o_conv);
14640         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14641         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
14642         return (int64_t)ret_conv;
14643 }
14644
14645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14646         LDKDecodeError e_conv;
14647         e_conv.inner = (void*)(e & (~1));
14648         e_conv.is_owned = (e & 1) || (e == 0);
14649         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14650         e_conv = DecodeError_clone(&e_conv);
14651         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14652         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
14653         return (int64_t)ret_conv;
14654 }
14655
14656 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14657         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
14658         jboolean ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
14659         return ret_val;
14660 }
14661
14662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14663         if ((_res & 1) != 0) return;
14664         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14665         CHECK_ACCESS(_res_ptr);
14666         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
14667         FREE((void*)_res);
14668         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
14669 }
14670
14671 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
14672         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14673         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
14674         return (int64_t)ret_conv;
14675 }
14676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14677         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
14678         int64_t ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
14679         return ret_val;
14680 }
14681
14682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14683         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
14684         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14685         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
14686         return (int64_t)ret_conv;
14687 }
14688
14689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
14690         LDKCVec_SignatureZ _res_constr;
14691         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14692         if (_res_constr.datalen > 0)
14693                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14694         else
14695                 _res_constr.data = NULL;
14696         for (size_t i = 0; i < _res_constr.datalen; i++) {
14697                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
14698                 LDKSignature _res_conv_8_ref;
14699                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
14700                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
14701                 _res_constr.data[i] = _res_conv_8_ref;
14702         }
14703         CVec_SignatureZ_free(_res_constr);
14704 }
14705
14706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14707         LDKHolderCommitmentTransaction o_conv;
14708         o_conv.inner = (void*)(o & (~1));
14709         o_conv.is_owned = (o & 1) || (o == 0);
14710         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14711         o_conv = HolderCommitmentTransaction_clone(&o_conv);
14712         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14713         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
14714         return (int64_t)ret_conv;
14715 }
14716
14717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14718         LDKDecodeError e_conv;
14719         e_conv.inner = (void*)(e & (~1));
14720         e_conv.is_owned = (e & 1) || (e == 0);
14721         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14722         e_conv = DecodeError_clone(&e_conv);
14723         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14724         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
14725         return (int64_t)ret_conv;
14726 }
14727
14728 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14729         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
14730         jboolean ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14731         return ret_val;
14732 }
14733
14734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14735         if ((_res & 1) != 0) return;
14736         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14737         CHECK_ACCESS(_res_ptr);
14738         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
14739         FREE((void*)_res);
14740         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
14741 }
14742
14743 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14744         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14745         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
14746         return (int64_t)ret_conv;
14747 }
14748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14749         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
14750         int64_t ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14751         return ret_val;
14752 }
14753
14754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14755         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
14756         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14757         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
14758         return (int64_t)ret_conv;
14759 }
14760
14761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14762         LDKBuiltCommitmentTransaction o_conv;
14763         o_conv.inner = (void*)(o & (~1));
14764         o_conv.is_owned = (o & 1) || (o == 0);
14765         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14766         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
14767         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14768         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
14769         return (int64_t)ret_conv;
14770 }
14771
14772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14773         LDKDecodeError e_conv;
14774         e_conv.inner = (void*)(e & (~1));
14775         e_conv.is_owned = (e & 1) || (e == 0);
14776         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14777         e_conv = DecodeError_clone(&e_conv);
14778         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14779         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
14780         return (int64_t)ret_conv;
14781 }
14782
14783 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14784         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
14785         jboolean ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14786         return ret_val;
14787 }
14788
14789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14790         if ((_res & 1) != 0) return;
14791         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14792         CHECK_ACCESS(_res_ptr);
14793         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
14794         FREE((void*)_res);
14795         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
14796 }
14797
14798 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14799         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14800         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
14801         return (int64_t)ret_conv;
14802 }
14803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14804         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
14805         int64_t ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14806         return ret_val;
14807 }
14808
14809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14810         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
14811         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14812         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
14813         return (int64_t)ret_conv;
14814 }
14815
14816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14817         LDKTrustedClosingTransaction o_conv;
14818         o_conv.inner = (void*)(o & (~1));
14819         o_conv.is_owned = (o & 1) || (o == 0);
14820         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14821         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
14822         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
14823         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
14824         return (int64_t)ret_conv;
14825 }
14826
14827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
14828         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
14829         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
14830         return (int64_t)ret_conv;
14831 }
14832
14833 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14834         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
14835         jboolean ret_val = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
14836         return ret_val;
14837 }
14838
14839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14840         if ((_res & 1) != 0) return;
14841         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14842         CHECK_ACCESS(_res_ptr);
14843         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
14844         FREE((void*)_res);
14845         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
14846 }
14847
14848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14849         LDKCommitmentTransaction o_conv;
14850         o_conv.inner = (void*)(o & (~1));
14851         o_conv.is_owned = (o & 1) || (o == 0);
14852         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14853         o_conv = CommitmentTransaction_clone(&o_conv);
14854         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14855         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
14856         return (int64_t)ret_conv;
14857 }
14858
14859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14860         LDKDecodeError e_conv;
14861         e_conv.inner = (void*)(e & (~1));
14862         e_conv.is_owned = (e & 1) || (e == 0);
14863         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14864         e_conv = DecodeError_clone(&e_conv);
14865         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14866         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
14867         return (int64_t)ret_conv;
14868 }
14869
14870 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14871         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
14872         jboolean ret_val = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14873         return ret_val;
14874 }
14875
14876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14877         if ((_res & 1) != 0) return;
14878         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14879         CHECK_ACCESS(_res_ptr);
14880         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
14881         FREE((void*)_res);
14882         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
14883 }
14884
14885 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14886         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14887         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
14888         return (int64_t)ret_conv;
14889 }
14890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14891         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
14892         int64_t ret_val = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14893         return ret_val;
14894 }
14895
14896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14897         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
14898         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14899         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
14900         return (int64_t)ret_conv;
14901 }
14902
14903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14904         LDKTrustedCommitmentTransaction o_conv;
14905         o_conv.inner = (void*)(o & (~1));
14906         o_conv.is_owned = (o & 1) || (o == 0);
14907         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14908         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
14909         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
14910         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
14911         return (int64_t)ret_conv;
14912 }
14913
14914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
14915         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
14916         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
14917         return (int64_t)ret_conv;
14918 }
14919
14920 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14921         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
14922         jboolean ret_val = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
14923         return ret_val;
14924 }
14925
14926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14927         if ((_res & 1) != 0) return;
14928         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14929         CHECK_ACCESS(_res_ptr);
14930         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
14931         FREE((void*)_res);
14932         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
14933 }
14934
14935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
14936         LDKCVec_SignatureZ o_constr;
14937         o_constr.datalen = (*env)->GetArrayLength(env, o);
14938         if (o_constr.datalen > 0)
14939                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14940         else
14941                 o_constr.data = NULL;
14942         for (size_t i = 0; i < o_constr.datalen; i++) {
14943                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
14944                 LDKSignature o_conv_8_ref;
14945                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
14946                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
14947                 o_constr.data[i] = o_conv_8_ref;
14948         }
14949         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14950         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
14951         return (int64_t)ret_conv;
14952 }
14953
14954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
14955         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14956         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
14957         return (int64_t)ret_conv;
14958 }
14959
14960 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14961         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
14962         jboolean ret_val = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
14963         return ret_val;
14964 }
14965
14966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14967         if ((_res & 1) != 0) return;
14968         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14969         CHECK_ACCESS(_res_ptr);
14970         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
14971         FREE((void*)_res);
14972         CResult_CVec_SignatureZNoneZ_free(_res_conv);
14973 }
14974
14975 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
14976         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14977         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
14978         return (int64_t)ret_conv;
14979 }
14980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14981         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
14982         int64_t ret_val = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
14983         return ret_val;
14984 }
14985
14986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14987         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
14988         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14989         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
14990         return (int64_t)ret_conv;
14991 }
14992
14993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14994         LDKShutdownScript o_conv;
14995         o_conv.inner = (void*)(o & (~1));
14996         o_conv.is_owned = (o & 1) || (o == 0);
14997         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14998         o_conv = ShutdownScript_clone(&o_conv);
14999         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15000         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
15001         return (int64_t)ret_conv;
15002 }
15003
15004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15005         LDKDecodeError e_conv;
15006         e_conv.inner = (void*)(e & (~1));
15007         e_conv.is_owned = (e & 1) || (e == 0);
15008         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15009         e_conv = DecodeError_clone(&e_conv);
15010         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15011         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
15012         return (int64_t)ret_conv;
15013 }
15014
15015 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15016         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
15017         jboolean ret_val = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
15018         return ret_val;
15019 }
15020
15021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15022         if ((_res & 1) != 0) return;
15023         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15024         CHECK_ACCESS(_res_ptr);
15025         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
15026         FREE((void*)_res);
15027         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
15028 }
15029
15030 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
15031         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15032         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
15033         return (int64_t)ret_conv;
15034 }
15035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15036         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
15037         int64_t ret_val = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
15038         return ret_val;
15039 }
15040
15041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15042         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
15043         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15044         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
15045         return (int64_t)ret_conv;
15046 }
15047
15048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15049         LDKShutdownScript o_conv;
15050         o_conv.inner = (void*)(o & (~1));
15051         o_conv.is_owned = (o & 1) || (o == 0);
15052         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15053         o_conv = ShutdownScript_clone(&o_conv);
15054         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15055         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
15056         return (int64_t)ret_conv;
15057 }
15058
15059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15060         LDKInvalidShutdownScript e_conv;
15061         e_conv.inner = (void*)(e & (~1));
15062         e_conv.is_owned = (e & 1) || (e == 0);
15063         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15064         e_conv = InvalidShutdownScript_clone(&e_conv);
15065         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15066         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
15067         return (int64_t)ret_conv;
15068 }
15069
15070 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15071         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
15072         jboolean ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
15073         return ret_val;
15074 }
15075
15076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15077         if ((_res & 1) != 0) return;
15078         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15079         CHECK_ACCESS(_res_ptr);
15080         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
15081         FREE((void*)_res);
15082         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
15083 }
15084
15085 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
15086         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15087         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
15088         return (int64_t)ret_conv;
15089 }
15090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15091         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
15092         int64_t ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
15093         return ret_val;
15094 }
15095
15096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15097         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
15098         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15099         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
15100         return (int64_t)ret_conv;
15101 }
15102
15103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
15104         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15105         *ret_conv = CResult_NoneErrorZ_ok();
15106         return (int64_t)ret_conv;
15107 }
15108
15109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15110         LDKIOError e_conv = LDKIOError_from_java(env, e);
15111         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15112         *ret_conv = CResult_NoneErrorZ_err(e_conv);
15113         return (int64_t)ret_conv;
15114 }
15115
15116 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15117         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
15118         jboolean ret_val = CResult_NoneErrorZ_is_ok(o_conv);
15119         return ret_val;
15120 }
15121
15122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15123         if ((_res & 1) != 0) return;
15124         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15125         CHECK_ACCESS(_res_ptr);
15126         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
15127         FREE((void*)_res);
15128         CResult_NoneErrorZ_free(_res_conv);
15129 }
15130
15131 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
15132         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15133         *ret_conv = CResult_NoneErrorZ_clone(arg);
15134         return (int64_t)ret_conv;
15135 }
15136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15137         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
15138         int64_t ret_val = CResult_NoneErrorZ_clone_ptr(arg_conv);
15139         return ret_val;
15140 }
15141
15142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15143         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
15144         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15145         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
15146         return (int64_t)ret_conv;
15147 }
15148
15149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15150         LDKRouteHop o_conv;
15151         o_conv.inner = (void*)(o & (~1));
15152         o_conv.is_owned = (o & 1) || (o == 0);
15153         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15154         o_conv = RouteHop_clone(&o_conv);
15155         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15156         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
15157         return (int64_t)ret_conv;
15158 }
15159
15160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15161         LDKDecodeError e_conv;
15162         e_conv.inner = (void*)(e & (~1));
15163         e_conv.is_owned = (e & 1) || (e == 0);
15164         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15165         e_conv = DecodeError_clone(&e_conv);
15166         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15167         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
15168         return (int64_t)ret_conv;
15169 }
15170
15171 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15172         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
15173         jboolean ret_val = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
15174         return ret_val;
15175 }
15176
15177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15178         if ((_res & 1) != 0) return;
15179         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15180         CHECK_ACCESS(_res_ptr);
15181         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
15182         FREE((void*)_res);
15183         CResult_RouteHopDecodeErrorZ_free(_res_conv);
15184 }
15185
15186 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
15187         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15188         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
15189         return (int64_t)ret_conv;
15190 }
15191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15192         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
15193         int64_t ret_val = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
15194         return ret_val;
15195 }
15196
15197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15198         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
15199         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15200         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
15201         return (int64_t)ret_conv;
15202 }
15203
15204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15205         LDKCVec_RouteHopZ _res_constr;
15206         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15207         if (_res_constr.datalen > 0)
15208                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15209         else
15210                 _res_constr.data = NULL;
15211         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15212         for (size_t k = 0; k < _res_constr.datalen; k++) {
15213                 int64_t _res_conv_10 = _res_vals[k];
15214                 LDKRouteHop _res_conv_10_conv;
15215                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
15216                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
15217                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
15218                 _res_constr.data[k] = _res_conv_10_conv;
15219         }
15220         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15221         CVec_RouteHopZ_free(_res_constr);
15222 }
15223
15224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15225         LDKCVec_CVec_RouteHopZZ _res_constr;
15226         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15227         if (_res_constr.datalen > 0)
15228                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
15229         else
15230                 _res_constr.data = NULL;
15231         for (size_t m = 0; m < _res_constr.datalen; m++) {
15232                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
15233                 LDKCVec_RouteHopZ _res_conv_12_constr;
15234                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
15235                 if (_res_conv_12_constr.datalen > 0)
15236                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15237                 else
15238                         _res_conv_12_constr.data = NULL;
15239                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
15240                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
15241                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
15242                         LDKRouteHop _res_conv_12_conv_10_conv;
15243                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
15244                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
15245                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
15246                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
15247                 }
15248                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
15249                 _res_constr.data[m] = _res_conv_12_constr;
15250         }
15251         CVec_CVec_RouteHopZZ_free(_res_constr);
15252 }
15253
15254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15255         LDKRoute o_conv;
15256         o_conv.inner = (void*)(o & (~1));
15257         o_conv.is_owned = (o & 1) || (o == 0);
15258         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15259         o_conv = Route_clone(&o_conv);
15260         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15261         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
15262         return (int64_t)ret_conv;
15263 }
15264
15265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15266         LDKDecodeError e_conv;
15267         e_conv.inner = (void*)(e & (~1));
15268         e_conv.is_owned = (e & 1) || (e == 0);
15269         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15270         e_conv = DecodeError_clone(&e_conv);
15271         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15272         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
15273         return (int64_t)ret_conv;
15274 }
15275
15276 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15277         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
15278         jboolean ret_val = CResult_RouteDecodeErrorZ_is_ok(o_conv);
15279         return ret_val;
15280 }
15281
15282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15283         if ((_res & 1) != 0) return;
15284         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15285         CHECK_ACCESS(_res_ptr);
15286         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
15287         FREE((void*)_res);
15288         CResult_RouteDecodeErrorZ_free(_res_conv);
15289 }
15290
15291 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
15292         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15293         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
15294         return (int64_t)ret_conv;
15295 }
15296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15297         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
15298         int64_t ret_val = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
15299         return ret_val;
15300 }
15301
15302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15303         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
15304         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15305         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
15306         return (int64_t)ret_conv;
15307 }
15308
15309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15310         LDKRouteParameters o_conv;
15311         o_conv.inner = (void*)(o & (~1));
15312         o_conv.is_owned = (o & 1) || (o == 0);
15313         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15314         o_conv = RouteParameters_clone(&o_conv);
15315         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15316         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
15317         return (int64_t)ret_conv;
15318 }
15319
15320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15321         LDKDecodeError e_conv;
15322         e_conv.inner = (void*)(e & (~1));
15323         e_conv.is_owned = (e & 1) || (e == 0);
15324         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15325         e_conv = DecodeError_clone(&e_conv);
15326         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15327         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
15328         return (int64_t)ret_conv;
15329 }
15330
15331 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15332         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
15333         jboolean ret_val = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
15334         return ret_val;
15335 }
15336
15337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15338         if ((_res & 1) != 0) return;
15339         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15340         CHECK_ACCESS(_res_ptr);
15341         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
15342         FREE((void*)_res);
15343         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
15344 }
15345
15346 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
15347         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15348         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
15349         return (int64_t)ret_conv;
15350 }
15351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15352         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
15353         int64_t ret_val = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
15354         return ret_val;
15355 }
15356
15357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15358         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
15359         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15360         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
15361         return (int64_t)ret_conv;
15362 }
15363
15364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15365         LDKCVec_RouteHintZ _res_constr;
15366         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15367         if (_res_constr.datalen > 0)
15368                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
15369         else
15370                 _res_constr.data = NULL;
15371         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15372         for (size_t l = 0; l < _res_constr.datalen; l++) {
15373                 int64_t _res_conv_11 = _res_vals[l];
15374                 LDKRouteHint _res_conv_11_conv;
15375                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
15376                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
15377                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
15378                 _res_constr.data[l] = _res_conv_11_conv;
15379         }
15380         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15381         CVec_RouteHintZ_free(_res_constr);
15382 }
15383
15384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
15385         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15386         *ret_copy = COption_u64Z_some(o);
15387         int64_t ret_ref = (uintptr_t)ret_copy;
15388         return ret_ref;
15389 }
15390
15391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
15392         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15393         *ret_copy = COption_u64Z_none();
15394         int64_t ret_ref = (uintptr_t)ret_copy;
15395         return ret_ref;
15396 }
15397
15398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
15399         if ((_res & 1) != 0) return;
15400         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15401         CHECK_ACCESS(_res_ptr);
15402         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
15403         FREE((void*)_res);
15404         COption_u64Z_free(_res_conv);
15405 }
15406
15407 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
15408         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15409         *ret_copy = COption_u64Z_clone(arg);
15410 int64_t ret_ref = (uintptr_t)ret_copy;
15411         return ret_ref;
15412 }
15413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15414         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
15415         int64_t ret_val = COption_u64Z_clone_ptr(arg_conv);
15416         return ret_val;
15417 }
15418
15419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15420         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
15421         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15422         *ret_copy = COption_u64Z_clone(orig_conv);
15423         int64_t ret_ref = (uintptr_t)ret_copy;
15424         return ret_ref;
15425 }
15426
15427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15428         LDKPaymentParameters o_conv;
15429         o_conv.inner = (void*)(o & (~1));
15430         o_conv.is_owned = (o & 1) || (o == 0);
15431         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15432         o_conv = PaymentParameters_clone(&o_conv);
15433         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15434         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
15435         return (int64_t)ret_conv;
15436 }
15437
15438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15439         LDKDecodeError e_conv;
15440         e_conv.inner = (void*)(e & (~1));
15441         e_conv.is_owned = (e & 1) || (e == 0);
15442         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15443         e_conv = DecodeError_clone(&e_conv);
15444         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15445         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
15446         return (int64_t)ret_conv;
15447 }
15448
15449 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15450         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
15451         jboolean ret_val = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
15452         return ret_val;
15453 }
15454
15455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15456         if ((_res & 1) != 0) return;
15457         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15458         CHECK_ACCESS(_res_ptr);
15459         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
15460         FREE((void*)_res);
15461         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
15462 }
15463
15464 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
15465         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15466         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
15467         return (int64_t)ret_conv;
15468 }
15469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15470         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
15471         int64_t ret_val = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
15472         return ret_val;
15473 }
15474
15475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15476         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
15477         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15478         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
15479         return (int64_t)ret_conv;
15480 }
15481
15482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15483         LDKCVec_RouteHintHopZ _res_constr;
15484         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15485         if (_res_constr.datalen > 0)
15486                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
15487         else
15488                 _res_constr.data = NULL;
15489         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15490         for (size_t o = 0; o < _res_constr.datalen; o++) {
15491                 int64_t _res_conv_14 = _res_vals[o];
15492                 LDKRouteHintHop _res_conv_14_conv;
15493                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15494                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15495                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15496                 _res_constr.data[o] = _res_conv_14_conv;
15497         }
15498         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15499         CVec_RouteHintHopZ_free(_res_constr);
15500 }
15501
15502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15503         LDKRouteHint o_conv;
15504         o_conv.inner = (void*)(o & (~1));
15505         o_conv.is_owned = (o & 1) || (o == 0);
15506         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15507         o_conv = RouteHint_clone(&o_conv);
15508         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15509         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
15510         return (int64_t)ret_conv;
15511 }
15512
15513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15514         LDKDecodeError e_conv;
15515         e_conv.inner = (void*)(e & (~1));
15516         e_conv.is_owned = (e & 1) || (e == 0);
15517         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15518         e_conv = DecodeError_clone(&e_conv);
15519         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15520         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
15521         return (int64_t)ret_conv;
15522 }
15523
15524 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15525         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
15526         jboolean ret_val = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
15527         return ret_val;
15528 }
15529
15530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15531         if ((_res & 1) != 0) return;
15532         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15533         CHECK_ACCESS(_res_ptr);
15534         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
15535         FREE((void*)_res);
15536         CResult_RouteHintDecodeErrorZ_free(_res_conv);
15537 }
15538
15539 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
15540         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15541         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
15542         return (int64_t)ret_conv;
15543 }
15544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15545         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
15546         int64_t ret_val = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
15547         return ret_val;
15548 }
15549
15550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15551         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
15552         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15553         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
15554         return (int64_t)ret_conv;
15555 }
15556
15557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15558         LDKRouteHintHop o_conv;
15559         o_conv.inner = (void*)(o & (~1));
15560         o_conv.is_owned = (o & 1) || (o == 0);
15561         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15562         o_conv = RouteHintHop_clone(&o_conv);
15563         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15564         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
15565         return (int64_t)ret_conv;
15566 }
15567
15568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15569         LDKDecodeError e_conv;
15570         e_conv.inner = (void*)(e & (~1));
15571         e_conv.is_owned = (e & 1) || (e == 0);
15572         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15573         e_conv = DecodeError_clone(&e_conv);
15574         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15575         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
15576         return (int64_t)ret_conv;
15577 }
15578
15579 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15580         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
15581         jboolean ret_val = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
15582         return ret_val;
15583 }
15584
15585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15586         if ((_res & 1) != 0) return;
15587         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15588         CHECK_ACCESS(_res_ptr);
15589         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
15590         FREE((void*)_res);
15591         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
15592 }
15593
15594 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
15595         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15596         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
15597         return (int64_t)ret_conv;
15598 }
15599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15600         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
15601         int64_t ret_val = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
15602         return ret_val;
15603 }
15604
15605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15606         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
15607         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15608         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
15609         return (int64_t)ret_conv;
15610 }
15611
15612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15613         LDKCVec_ChannelDetailsZ _res_constr;
15614         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15615         if (_res_constr.datalen > 0)
15616                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
15617         else
15618                 _res_constr.data = NULL;
15619         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15620         for (size_t q = 0; q < _res_constr.datalen; q++) {
15621                 int64_t _res_conv_16 = _res_vals[q];
15622                 LDKChannelDetails _res_conv_16_conv;
15623                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
15624                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
15625                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
15626                 _res_constr.data[q] = _res_conv_16_conv;
15627         }
15628         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15629         CVec_ChannelDetailsZ_free(_res_constr);
15630 }
15631
15632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15633         LDKRoute o_conv;
15634         o_conv.inner = (void*)(o & (~1));
15635         o_conv.is_owned = (o & 1) || (o == 0);
15636         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15637         o_conv = Route_clone(&o_conv);
15638         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15639         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
15640         return (int64_t)ret_conv;
15641 }
15642
15643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15644         LDKLightningError e_conv;
15645         e_conv.inner = (void*)(e & (~1));
15646         e_conv.is_owned = (e & 1) || (e == 0);
15647         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15648         e_conv = LightningError_clone(&e_conv);
15649         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15650         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
15651         return (int64_t)ret_conv;
15652 }
15653
15654 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15655         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
15656         jboolean ret_val = CResult_RouteLightningErrorZ_is_ok(o_conv);
15657         return ret_val;
15658 }
15659
15660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15661         if ((_res & 1) != 0) return;
15662         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15663         CHECK_ACCESS(_res_ptr);
15664         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
15665         FREE((void*)_res);
15666         CResult_RouteLightningErrorZ_free(_res_conv);
15667 }
15668
15669 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
15670         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15671         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
15672         return (int64_t)ret_conv;
15673 }
15674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15675         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
15676         int64_t ret_val = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
15677         return ret_val;
15678 }
15679
15680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15681         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
15682         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15683         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
15684         return (int64_t)ret_conv;
15685 }
15686
15687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15688         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15689         CHECK_ACCESS(o_ptr);
15690         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
15691         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
15692         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15693         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
15694         return (int64_t)ret_conv;
15695 }
15696
15697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15698         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
15699         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15700         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
15701         return (int64_t)ret_conv;
15702 }
15703
15704 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15705         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
15706         jboolean ret_val = CResult_TxOutAccessErrorZ_is_ok(o_conv);
15707         return ret_val;
15708 }
15709
15710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15711         if ((_res & 1) != 0) return;
15712         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15713         CHECK_ACCESS(_res_ptr);
15714         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
15715         FREE((void*)_res);
15716         CResult_TxOutAccessErrorZ_free(_res_conv);
15717 }
15718
15719 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
15720         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15721         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
15722         return (int64_t)ret_conv;
15723 }
15724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15725         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
15726         int64_t ret_val = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
15727         return ret_val;
15728 }
15729
15730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15731         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
15732         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15733         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
15734         return (int64_t)ret_conv;
15735 }
15736
15737 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
15738         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15739         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
15740         return ((int64_t)ret_conv);
15741 }
15742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15743         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
15744         int64_t ret_val = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
15745         return ret_val;
15746 }
15747
15748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15749         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
15750         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15751         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
15752         return ((int64_t)ret_conv);
15753 }
15754
15755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
15756         LDKTransaction b_ref;
15757         b_ref.datalen = (*env)->GetArrayLength(env, b);
15758         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
15759         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
15760         b_ref.data_is_owned = true;
15761         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15762         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
15763         return ((int64_t)ret_conv);
15764 }
15765
15766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15767         if ((_res & 1) != 0) return;
15768         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15769         CHECK_ACCESS(_res_ptr);
15770         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
15771         FREE((void*)_res);
15772         C2Tuple_usizeTransactionZ_free(_res_conv);
15773 }
15774
15775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15776         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
15777         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15778         if (_res_constr.datalen > 0)
15779                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
15780         else
15781                 _res_constr.data = NULL;
15782         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15783         for (size_t c = 0; c < _res_constr.datalen; c++) {
15784                 int64_t _res_conv_28 = _res_vals[c];
15785                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
15786                 CHECK_ACCESS(_res_conv_28_ptr);
15787                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
15788                 FREE((void*)_res_conv_28);
15789                 _res_constr.data[c] = _res_conv_28_conv;
15790         }
15791         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15792         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
15793 }
15794
15795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15796         LDKCVec_TxidZ _res_constr;
15797         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15798         if (_res_constr.datalen > 0)
15799                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
15800         else
15801                 _res_constr.data = NULL;
15802         for (size_t i = 0; i < _res_constr.datalen; i++) {
15803                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15804                 LDKThirtyTwoBytes _res_conv_8_ref;
15805                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
15806                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
15807                 _res_constr.data[i] = _res_conv_8_ref;
15808         }
15809         CVec_TxidZ_free(_res_constr);
15810 }
15811
15812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
15813         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15814         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
15815         return (int64_t)ret_conv;
15816 }
15817
15818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
15819         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
15820         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15821         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
15822         return (int64_t)ret_conv;
15823 }
15824
15825 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15826         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
15827         jboolean ret_val = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
15828         return ret_val;
15829 }
15830
15831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15832         if ((_res & 1) != 0) return;
15833         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15834         CHECK_ACCESS(_res_ptr);
15835         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
15836         FREE((void*)_res);
15837         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
15838 }
15839
15840 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
15841         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15842         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
15843         return (int64_t)ret_conv;
15844 }
15845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15846         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
15847         int64_t ret_val = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
15848         return ret_val;
15849 }
15850
15851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15852         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
15853         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15854         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
15855         return (int64_t)ret_conv;
15856 }
15857
15858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15859         LDKCVec_MonitorEventZ _res_constr;
15860         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15861         if (_res_constr.datalen > 0)
15862                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
15863         else
15864                 _res_constr.data = NULL;
15865         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15866         for (size_t o = 0; o < _res_constr.datalen; o++) {
15867                 int64_t _res_conv_14 = _res_vals[o];
15868                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
15869                 CHECK_ACCESS(_res_conv_14_ptr);
15870                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
15871                 FREE((void*)_res_conv_14);
15872                 _res_constr.data[o] = _res_conv_14_conv;
15873         }
15874         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15875         CVec_MonitorEventZ_free(_res_constr);
15876 }
15877
15878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15879         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15880         CHECK_ACCESS(o_ptr);
15881         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
15882         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
15883         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15884         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
15885         int64_t ret_ref = (uintptr_t)ret_copy;
15886         return ret_ref;
15887 }
15888
15889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
15890         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15891         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
15892         int64_t ret_ref = (uintptr_t)ret_copy;
15893         return ret_ref;
15894 }
15895
15896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15897         if ((_res & 1) != 0) return;
15898         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15899         CHECK_ACCESS(_res_ptr);
15900         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
15901         FREE((void*)_res);
15902         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
15903 }
15904
15905 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
15906         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15907         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
15908 int64_t ret_ref = (uintptr_t)ret_copy;
15909         return ret_ref;
15910 }
15911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15912         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
15913         int64_t ret_val = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
15914         return ret_val;
15915 }
15916
15917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15918         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
15919         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15920         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
15921         int64_t ret_ref = (uintptr_t)ret_copy;
15922         return ret_ref;
15923 }
15924
15925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15926         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15927         CHECK_ACCESS(o_ptr);
15928         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
15929         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
15930         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15931         *ret_copy = COption_ClosureReasonZ_some(o_conv);
15932         int64_t ret_ref = (uintptr_t)ret_copy;
15933         return ret_ref;
15934 }
15935
15936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
15937         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15938         *ret_copy = COption_ClosureReasonZ_none();
15939         int64_t ret_ref = (uintptr_t)ret_copy;
15940         return ret_ref;
15941 }
15942
15943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15944         if ((_res & 1) != 0) return;
15945         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15946         CHECK_ACCESS(_res_ptr);
15947         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
15948         FREE((void*)_res);
15949         COption_ClosureReasonZ_free(_res_conv);
15950 }
15951
15952 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
15953         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15954         *ret_copy = COption_ClosureReasonZ_clone(arg);
15955 int64_t ret_ref = (uintptr_t)ret_copy;
15956         return ret_ref;
15957 }
15958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15959         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
15960         int64_t ret_val = COption_ClosureReasonZ_clone_ptr(arg_conv);
15961         return ret_val;
15962 }
15963
15964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15965         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
15966         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15967         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
15968         int64_t ret_ref = (uintptr_t)ret_copy;
15969         return ret_ref;
15970 }
15971
15972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15973         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15974         CHECK_ACCESS(o_ptr);
15975         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
15976         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
15977         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
15978         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
15979         return (int64_t)ret_conv;
15980 }
15981
15982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15983         LDKDecodeError e_conv;
15984         e_conv.inner = (void*)(e & (~1));
15985         e_conv.is_owned = (e & 1) || (e == 0);
15986         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15987         e_conv = DecodeError_clone(&e_conv);
15988         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
15989         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
15990         return (int64_t)ret_conv;
15991 }
15992
15993 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15994         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
15995         jboolean ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
15996         return ret_val;
15997 }
15998
15999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16000         if ((_res & 1) != 0) return;
16001         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16002         CHECK_ACCESS(_res_ptr);
16003         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
16004         FREE((void*)_res);
16005         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
16006 }
16007
16008 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
16009         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16010         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
16011         return (int64_t)ret_conv;
16012 }
16013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16014         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
16015         int64_t ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
16016         return ret_val;
16017 }
16018
16019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16020         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
16021         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16022         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
16023         return (int64_t)ret_conv;
16024 }
16025
16026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16027         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16028         CHECK_ACCESS(o_ptr);
16029         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
16030         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
16031         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16032         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
16033         int64_t ret_ref = (uintptr_t)ret_copy;
16034         return ret_ref;
16035 }
16036
16037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
16038         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16039         *ret_copy = COption_NetworkUpdateZ_none();
16040         int64_t ret_ref = (uintptr_t)ret_copy;
16041         return ret_ref;
16042 }
16043
16044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16045         if ((_res & 1) != 0) return;
16046         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16047         CHECK_ACCESS(_res_ptr);
16048         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
16049         FREE((void*)_res);
16050         COption_NetworkUpdateZ_free(_res_conv);
16051 }
16052
16053 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
16054         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16055         *ret_copy = COption_NetworkUpdateZ_clone(arg);
16056 int64_t ret_ref = (uintptr_t)ret_copy;
16057         return ret_ref;
16058 }
16059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16060         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
16061         int64_t ret_val = COption_NetworkUpdateZ_clone_ptr(arg_conv);
16062         return ret_val;
16063 }
16064
16065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16066         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
16067         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16068         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
16069         int64_t ret_ref = (uintptr_t)ret_copy;
16070         return ret_ref;
16071 }
16072
16073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16074         LDKCVec_SpendableOutputDescriptorZ _res_constr;
16075         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16076         if (_res_constr.datalen > 0)
16077                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16078         else
16079                 _res_constr.data = NULL;
16080         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16081         for (size_t b = 0; b < _res_constr.datalen; b++) {
16082                 int64_t _res_conv_27 = _res_vals[b];
16083                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
16084                 CHECK_ACCESS(_res_conv_27_ptr);
16085                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
16086                 FREE((void*)_res_conv_27);
16087                 _res_constr.data[b] = _res_conv_27_conv;
16088         }
16089         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16090         CVec_SpendableOutputDescriptorZ_free(_res_constr);
16091 }
16092
16093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16094         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16095         CHECK_ACCESS(o_ptr);
16096         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
16097         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
16098         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16099         *ret_copy = COption_EventZ_some(o_conv);
16100         int64_t ret_ref = (uintptr_t)ret_copy;
16101         return ret_ref;
16102 }
16103
16104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
16105         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16106         *ret_copy = COption_EventZ_none();
16107         int64_t ret_ref = (uintptr_t)ret_copy;
16108         return ret_ref;
16109 }
16110
16111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16112         if ((_res & 1) != 0) return;
16113         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16114         CHECK_ACCESS(_res_ptr);
16115         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
16116         FREE((void*)_res);
16117         COption_EventZ_free(_res_conv);
16118 }
16119
16120 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
16121         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16122         *ret_copy = COption_EventZ_clone(arg);
16123 int64_t ret_ref = (uintptr_t)ret_copy;
16124         return ret_ref;
16125 }
16126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16127         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
16128         int64_t ret_val = COption_EventZ_clone_ptr(arg_conv);
16129         return ret_val;
16130 }
16131
16132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16133         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
16134         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16135         *ret_copy = COption_EventZ_clone(orig_conv);
16136         int64_t ret_ref = (uintptr_t)ret_copy;
16137         return ret_ref;
16138 }
16139
16140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16141         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16142         CHECK_ACCESS(o_ptr);
16143         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
16144         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
16145         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16146         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
16147         return (int64_t)ret_conv;
16148 }
16149
16150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16151         LDKDecodeError e_conv;
16152         e_conv.inner = (void*)(e & (~1));
16153         e_conv.is_owned = (e & 1) || (e == 0);
16154         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16155         e_conv = DecodeError_clone(&e_conv);
16156         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16157         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
16158         return (int64_t)ret_conv;
16159 }
16160
16161 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16162         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
16163         jboolean ret_val = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
16164         return ret_val;
16165 }
16166
16167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16168         if ((_res & 1) != 0) return;
16169         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16170         CHECK_ACCESS(_res_ptr);
16171         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
16172         FREE((void*)_res);
16173         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
16174 }
16175
16176 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
16177         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16178         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
16179         return (int64_t)ret_conv;
16180 }
16181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16182         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
16183         int64_t ret_val = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
16184         return ret_val;
16185 }
16186
16187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16188         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
16189         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16190         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
16191         return (int64_t)ret_conv;
16192 }
16193
16194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16195         LDKCVec_MessageSendEventZ _res_constr;
16196         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16197         if (_res_constr.datalen > 0)
16198                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
16199         else
16200                 _res_constr.data = NULL;
16201         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16202         for (size_t s = 0; s < _res_constr.datalen; s++) {
16203                 int64_t _res_conv_18 = _res_vals[s];
16204                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
16205                 CHECK_ACCESS(_res_conv_18_ptr);
16206                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
16207                 FREE((void*)_res_conv_18);
16208                 _res_constr.data[s] = _res_conv_18_conv;
16209         }
16210         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16211         CVec_MessageSendEventZ_free(_res_constr);
16212 }
16213
16214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16215         LDKFixedPenaltyScorer o_conv;
16216         o_conv.inner = (void*)(o & (~1));
16217         o_conv.is_owned = (o & 1) || (o == 0);
16218         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16219         o_conv = FixedPenaltyScorer_clone(&o_conv);
16220         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16221         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
16222         return (int64_t)ret_conv;
16223 }
16224
16225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16226         LDKDecodeError e_conv;
16227         e_conv.inner = (void*)(e & (~1));
16228         e_conv.is_owned = (e & 1) || (e == 0);
16229         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16230         e_conv = DecodeError_clone(&e_conv);
16231         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16232         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
16233         return (int64_t)ret_conv;
16234 }
16235
16236 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16237         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
16238         jboolean ret_val = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
16239         return ret_val;
16240 }
16241
16242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16243         if ((_res & 1) != 0) return;
16244         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16245         CHECK_ACCESS(_res_ptr);
16246         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
16247         FREE((void*)_res);
16248         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
16249 }
16250
16251 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
16252         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16253         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
16254         return (int64_t)ret_conv;
16255 }
16256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16257         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
16258         int64_t ret_val = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
16259         return ret_val;
16260 }
16261
16262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16263         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
16264         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16265         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
16266         return (int64_t)ret_conv;
16267 }
16268
16269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16270         LDKScoringParameters o_conv;
16271         o_conv.inner = (void*)(o & (~1));
16272         o_conv.is_owned = (o & 1) || (o == 0);
16273         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16274         o_conv = ScoringParameters_clone(&o_conv);
16275         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
16276         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
16277         return (int64_t)ret_conv;
16278 }
16279
16280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_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_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
16287         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
16288         return (int64_t)ret_conv;
16289 }
16290
16291 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16292         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
16293         jboolean ret_val = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
16294         return ret_val;
16295 }
16296
16297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_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_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
16302         FREE((void*)_res);
16303         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
16304 }
16305
16306 static inline uintptr_t CResult_ScoringParametersDecodeErrorZ_clone_ptr(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR arg) {
16307         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
16308         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(arg);
16309         return (int64_t)ret_conv;
16310 }
16311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16312         LDKCResult_ScoringParametersDecodeErrorZ* arg_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
16313         int64_t ret_val = CResult_ScoringParametersDecodeErrorZ_clone_ptr(arg_conv);
16314         return ret_val;
16315 }
16316
16317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16318         LDKCResult_ScoringParametersDecodeErrorZ* orig_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(orig & ~1);
16319         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
16320         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(orig_conv);
16321         return (int64_t)ret_conv;
16322 }
16323
16324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16325         LDKScorer o_conv;
16326         o_conv.inner = (void*)(o & (~1));
16327         o_conv.is_owned = (o & 1) || (o == 0);
16328         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16329         // WARNING: we need a move here but no clone is available for LDKScorer
16330         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
16331         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
16332         return (int64_t)ret_conv;
16333 }
16334
16335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16336         LDKDecodeError e_conv;
16337         e_conv.inner = (void*)(e & (~1));
16338         e_conv.is_owned = (e & 1) || (e == 0);
16339         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16340         e_conv = DecodeError_clone(&e_conv);
16341         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
16342         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
16343         return (int64_t)ret_conv;
16344 }
16345
16346 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16347         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
16348         jboolean ret_val = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
16349         return ret_val;
16350 }
16351
16352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16353         if ((_res & 1) != 0) return;
16354         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16355         CHECK_ACCESS(_res_ptr);
16356         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
16357         FREE((void*)_res);
16358         CResult_ScorerDecodeErrorZ_free(_res_conv);
16359 }
16360
16361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16362         LDKProbabilisticScorer o_conv;
16363         o_conv.inner = (void*)(o & (~1));
16364         o_conv.is_owned = (o & 1) || (o == 0);
16365         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16366         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
16367         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
16368         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
16369         return (int64_t)ret_conv;
16370 }
16371
16372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16373         LDKDecodeError e_conv;
16374         e_conv.inner = (void*)(e & (~1));
16375         e_conv.is_owned = (e & 1) || (e == 0);
16376         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16377         e_conv = DecodeError_clone(&e_conv);
16378         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
16379         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
16380         return (int64_t)ret_conv;
16381 }
16382
16383 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16384         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
16385         jboolean ret_val = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
16386         return ret_val;
16387 }
16388
16389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16390         if ((_res & 1) != 0) return;
16391         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16392         CHECK_ACCESS(_res_ptr);
16393         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
16394         FREE((void*)_res);
16395         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
16396 }
16397
16398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16399         LDKInitFeatures o_conv;
16400         o_conv.inner = (void*)(o & (~1));
16401         o_conv.is_owned = (o & 1) || (o == 0);
16402         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16403         o_conv = InitFeatures_clone(&o_conv);
16404         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
16405         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
16406         return (int64_t)ret_conv;
16407 }
16408
16409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16410         LDKDecodeError e_conv;
16411         e_conv.inner = (void*)(e & (~1));
16412         e_conv.is_owned = (e & 1) || (e == 0);
16413         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16414         e_conv = DecodeError_clone(&e_conv);
16415         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
16416         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
16417         return (int64_t)ret_conv;
16418 }
16419
16420 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16421         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
16422         jboolean ret_val = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
16423         return ret_val;
16424 }
16425
16426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16427         if ((_res & 1) != 0) return;
16428         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16429         CHECK_ACCESS(_res_ptr);
16430         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
16431         FREE((void*)_res);
16432         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
16433 }
16434
16435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16436         LDKChannelFeatures o_conv;
16437         o_conv.inner = (void*)(o & (~1));
16438         o_conv.is_owned = (o & 1) || (o == 0);
16439         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16440         o_conv = ChannelFeatures_clone(&o_conv);
16441         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16442         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
16443         return (int64_t)ret_conv;
16444 }
16445
16446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16447         LDKDecodeError e_conv;
16448         e_conv.inner = (void*)(e & (~1));
16449         e_conv.is_owned = (e & 1) || (e == 0);
16450         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16451         e_conv = DecodeError_clone(&e_conv);
16452         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16453         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
16454         return (int64_t)ret_conv;
16455 }
16456
16457 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16458         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
16459         jboolean ret_val = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
16460         return ret_val;
16461 }
16462
16463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16464         if ((_res & 1) != 0) return;
16465         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16466         CHECK_ACCESS(_res_ptr);
16467         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
16468         FREE((void*)_res);
16469         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
16470 }
16471
16472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16473         LDKNodeFeatures o_conv;
16474         o_conv.inner = (void*)(o & (~1));
16475         o_conv.is_owned = (o & 1) || (o == 0);
16476         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16477         o_conv = NodeFeatures_clone(&o_conv);
16478         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16479         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
16480         return (int64_t)ret_conv;
16481 }
16482
16483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16484         LDKDecodeError e_conv;
16485         e_conv.inner = (void*)(e & (~1));
16486         e_conv.is_owned = (e & 1) || (e == 0);
16487         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16488         e_conv = DecodeError_clone(&e_conv);
16489         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16490         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
16491         return (int64_t)ret_conv;
16492 }
16493
16494 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16495         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
16496         jboolean ret_val = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
16497         return ret_val;
16498 }
16499
16500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16501         if ((_res & 1) != 0) return;
16502         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16503         CHECK_ACCESS(_res_ptr);
16504         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
16505         FREE((void*)_res);
16506         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
16507 }
16508
16509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16510         LDKInvoiceFeatures o_conv;
16511         o_conv.inner = (void*)(o & (~1));
16512         o_conv.is_owned = (o & 1) || (o == 0);
16513         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16514         o_conv = InvoiceFeatures_clone(&o_conv);
16515         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
16516         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
16517         return (int64_t)ret_conv;
16518 }
16519
16520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16521         LDKDecodeError e_conv;
16522         e_conv.inner = (void*)(e & (~1));
16523         e_conv.is_owned = (e & 1) || (e == 0);
16524         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16525         e_conv = DecodeError_clone(&e_conv);
16526         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
16527         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
16528         return (int64_t)ret_conv;
16529 }
16530
16531 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16532         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
16533         jboolean ret_val = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
16534         return ret_val;
16535 }
16536
16537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16538         if ((_res & 1) != 0) return;
16539         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16540         CHECK_ACCESS(_res_ptr);
16541         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
16542         FREE((void*)_res);
16543         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
16544 }
16545
16546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16547         LDKChannelTypeFeatures o_conv;
16548         o_conv.inner = (void*)(o & (~1));
16549         o_conv.is_owned = (o & 1) || (o == 0);
16550         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16551         o_conv = ChannelTypeFeatures_clone(&o_conv);
16552         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
16553         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
16554         return (int64_t)ret_conv;
16555 }
16556
16557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16558         LDKDecodeError e_conv;
16559         e_conv.inner = (void*)(e & (~1));
16560         e_conv.is_owned = (e & 1) || (e == 0);
16561         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16562         e_conv = DecodeError_clone(&e_conv);
16563         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
16564         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
16565         return (int64_t)ret_conv;
16566 }
16567
16568 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16569         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
16570         jboolean ret_val = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
16571         return ret_val;
16572 }
16573
16574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16575         if ((_res & 1) != 0) return;
16576         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16577         CHECK_ACCESS(_res_ptr);
16578         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
16579         FREE((void*)_res);
16580         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
16581 }
16582
16583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16584         LDKDelayedPaymentOutputDescriptor o_conv;
16585         o_conv.inner = (void*)(o & (~1));
16586         o_conv.is_owned = (o & 1) || (o == 0);
16587         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16588         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
16589         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16590         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
16591         return (int64_t)ret_conv;
16592 }
16593
16594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16595         LDKDecodeError e_conv;
16596         e_conv.inner = (void*)(e & (~1));
16597         e_conv.is_owned = (e & 1) || (e == 0);
16598         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16599         e_conv = DecodeError_clone(&e_conv);
16600         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16601         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
16602         return (int64_t)ret_conv;
16603 }
16604
16605 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16606         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
16607         jboolean ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16608         return ret_val;
16609 }
16610
16611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16612         if ((_res & 1) != 0) return;
16613         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16614         CHECK_ACCESS(_res_ptr);
16615         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
16616         FREE((void*)_res);
16617         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
16618 }
16619
16620 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16621         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16622         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
16623         return (int64_t)ret_conv;
16624 }
16625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16626         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
16627         int64_t ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16628         return ret_val;
16629 }
16630
16631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16632         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
16633         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16634         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
16635         return (int64_t)ret_conv;
16636 }
16637
16638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16639         LDKStaticPaymentOutputDescriptor o_conv;
16640         o_conv.inner = (void*)(o & (~1));
16641         o_conv.is_owned = (o & 1) || (o == 0);
16642         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16643         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
16644         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16645         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
16646         return (int64_t)ret_conv;
16647 }
16648
16649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16650         LDKDecodeError e_conv;
16651         e_conv.inner = (void*)(e & (~1));
16652         e_conv.is_owned = (e & 1) || (e == 0);
16653         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16654         e_conv = DecodeError_clone(&e_conv);
16655         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16656         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
16657         return (int64_t)ret_conv;
16658 }
16659
16660 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16661         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
16662         jboolean ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16663         return ret_val;
16664 }
16665
16666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16667         if ((_res & 1) != 0) return;
16668         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16669         CHECK_ACCESS(_res_ptr);
16670         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
16671         FREE((void*)_res);
16672         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
16673 }
16674
16675 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16676         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16677         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
16678         return (int64_t)ret_conv;
16679 }
16680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16681         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
16682         int64_t ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16683         return ret_val;
16684 }
16685
16686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16687         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
16688         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16689         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
16690         return (int64_t)ret_conv;
16691 }
16692
16693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16694         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16695         CHECK_ACCESS(o_ptr);
16696         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
16697         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
16698         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16699         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
16700         return (int64_t)ret_conv;
16701 }
16702
16703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16704         LDKDecodeError e_conv;
16705         e_conv.inner = (void*)(e & (~1));
16706         e_conv.is_owned = (e & 1) || (e == 0);
16707         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16708         e_conv = DecodeError_clone(&e_conv);
16709         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16710         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
16711         return (int64_t)ret_conv;
16712 }
16713
16714 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16715         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
16716         jboolean ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16717         return ret_val;
16718 }
16719
16720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16721         if ((_res & 1) != 0) return;
16722         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16723         CHECK_ACCESS(_res_ptr);
16724         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
16725         FREE((void*)_res);
16726         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
16727 }
16728
16729 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16730         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16731         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
16732         return (int64_t)ret_conv;
16733 }
16734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16735         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
16736         int64_t ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16737         return ret_val;
16738 }
16739
16740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16741         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
16742         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16743         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
16744         return (int64_t)ret_conv;
16745 }
16746
16747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16748         LDKCVec_PaymentPreimageZ _res_constr;
16749         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16750         if (_res_constr.datalen > 0)
16751                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
16752         else
16753                 _res_constr.data = NULL;
16754         for (size_t i = 0; i < _res_constr.datalen; i++) {
16755                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16756                 LDKThirtyTwoBytes _res_conv_8_ref;
16757                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
16758                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
16759                 _res_constr.data[i] = _res_conv_8_ref;
16760         }
16761         CVec_PaymentPreimageZ_free(_res_constr);
16762 }
16763
16764 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
16765         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
16766         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
16767         return ((int64_t)ret_conv);
16768 }
16769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16770         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
16771         int64_t ret_val = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
16772         return ret_val;
16773 }
16774
16775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16776         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
16777         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
16778         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
16779         return ((int64_t)ret_conv);
16780 }
16781
16782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
16783         LDKSignature a_ref;
16784         CHECK((*env)->GetArrayLength(env, a) == 64);
16785         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
16786         LDKCVec_SignatureZ b_constr;
16787         b_constr.datalen = (*env)->GetArrayLength(env, b);
16788         if (b_constr.datalen > 0)
16789                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16790         else
16791                 b_constr.data = NULL;
16792         for (size_t i = 0; i < b_constr.datalen; i++) {
16793                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
16794                 LDKSignature b_conv_8_ref;
16795                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
16796                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
16797                 b_constr.data[i] = b_conv_8_ref;
16798         }
16799         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
16800         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
16801         return ((int64_t)ret_conv);
16802 }
16803
16804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16805         if ((_res & 1) != 0) return;
16806         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16807         CHECK_ACCESS(_res_ptr);
16808         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
16809         FREE((void*)_res);
16810         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
16811 }
16812
16813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16814         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16815         CHECK_ACCESS(o_ptr);
16816         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
16817         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
16818         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16819         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
16820         return (int64_t)ret_conv;
16821 }
16822
16823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
16824         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16825         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
16826         return (int64_t)ret_conv;
16827 }
16828
16829 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16830         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
16831         jboolean ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
16832         return ret_val;
16833 }
16834
16835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16836         if ((_res & 1) != 0) return;
16837         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16838         CHECK_ACCESS(_res_ptr);
16839         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
16840         FREE((void*)_res);
16841         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
16842 }
16843
16844 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
16845         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16846         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
16847         return (int64_t)ret_conv;
16848 }
16849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16850         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
16851         int64_t ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
16852         return ret_val;
16853 }
16854
16855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16856         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
16857         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16858         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
16859         return (int64_t)ret_conv;
16860 }
16861
16862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16863         LDKSignature o_ref;
16864         CHECK((*env)->GetArrayLength(env, o) == 64);
16865         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
16866         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16867         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
16868         return (int64_t)ret_conv;
16869 }
16870
16871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
16872         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16873         *ret_conv = CResult_SignatureNoneZ_err();
16874         return (int64_t)ret_conv;
16875 }
16876
16877 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16878         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
16879         jboolean ret_val = CResult_SignatureNoneZ_is_ok(o_conv);
16880         return ret_val;
16881 }
16882
16883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16884         if ((_res & 1) != 0) return;
16885         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16886         CHECK_ACCESS(_res_ptr);
16887         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
16888         FREE((void*)_res);
16889         CResult_SignatureNoneZ_free(_res_conv);
16890 }
16891
16892 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
16893         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16894         *ret_conv = CResult_SignatureNoneZ_clone(arg);
16895         return (int64_t)ret_conv;
16896 }
16897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16898         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
16899         int64_t ret_val = CResult_SignatureNoneZ_clone_ptr(arg_conv);
16900         return ret_val;
16901 }
16902
16903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16904         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
16905         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16906         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
16907         return (int64_t)ret_conv;
16908 }
16909
16910 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
16911         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
16912         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
16913         return ((int64_t)ret_conv);
16914 }
16915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16916         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
16917         int64_t ret_val = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
16918         return ret_val;
16919 }
16920
16921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16922         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
16923         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
16924         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
16925         return ((int64_t)ret_conv);
16926 }
16927
16928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
16929         LDKSignature a_ref;
16930         CHECK((*env)->GetArrayLength(env, a) == 64);
16931         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
16932         LDKSignature b_ref;
16933         CHECK((*env)->GetArrayLength(env, b) == 64);
16934         (*env)->GetByteArrayRegion(env, b, 0, 64, b_ref.compact_form);
16935         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
16936         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
16937         return ((int64_t)ret_conv);
16938 }
16939
16940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16941         if ((_res & 1) != 0) return;
16942         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16943         CHECK_ACCESS(_res_ptr);
16944         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
16945         FREE((void*)_res);
16946         C2Tuple_SignatureSignatureZ_free(_res_conv);
16947 }
16948
16949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16950         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16951         CHECK_ACCESS(o_ptr);
16952         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
16953         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
16954         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
16955         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
16956         return (int64_t)ret_conv;
16957 }
16958
16959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
16960         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
16961         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
16962         return (int64_t)ret_conv;
16963 }
16964
16965 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16966         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
16967         jboolean ret_val = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
16968         return ret_val;
16969 }
16970
16971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16972         if ((_res & 1) != 0) return;
16973         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16974         CHECK_ACCESS(_res_ptr);
16975         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
16976         FREE((void*)_res);
16977         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
16978 }
16979
16980 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
16981         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
16982         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
16983         return (int64_t)ret_conv;
16984 }
16985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16986         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
16987         int64_t ret_val = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
16988         return ret_val;
16989 }
16990
16991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16992         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
16993         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
16994         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
16995         return (int64_t)ret_conv;
16996 }
16997
16998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16999         LDKSecretKey o_ref;
17000         CHECK((*env)->GetArrayLength(env, o) == 32);
17001         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
17002         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
17003         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
17004         return (int64_t)ret_conv;
17005 }
17006
17007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1err(JNIEnv *env, jclass clz) {
17008         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
17009         *ret_conv = CResult_SecretKeyNoneZ_err();
17010         return (int64_t)ret_conv;
17011 }
17012
17013 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17014         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
17015         jboolean ret_val = CResult_SecretKeyNoneZ_is_ok(o_conv);
17016         return ret_val;
17017 }
17018
17019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17020         if ((_res & 1) != 0) return;
17021         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17022         CHECK_ACCESS(_res_ptr);
17023         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
17024         FREE((void*)_res);
17025         CResult_SecretKeyNoneZ_free(_res_conv);
17026 }
17027
17028 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
17029         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
17030         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
17031         return (int64_t)ret_conv;
17032 }
17033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17034         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
17035         int64_t ret_val = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
17036         return ret_val;
17037 }
17038
17039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17040         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
17041         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
17042         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
17043         return (int64_t)ret_conv;
17044 }
17045
17046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17047         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17048         CHECK_ACCESS(o_ptr);
17049         LDKSign o_conv = *(LDKSign*)(o_ptr);
17050         if (o_conv.free == LDKSign_JCalls_free) {
17051                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17052                 LDKSign_JCalls_cloned(&o_conv);
17053         }
17054         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
17055         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
17056         return (int64_t)ret_conv;
17057 }
17058
17059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17060         LDKDecodeError e_conv;
17061         e_conv.inner = (void*)(e & (~1));
17062         e_conv.is_owned = (e & 1) || (e == 0);
17063         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17064         e_conv = DecodeError_clone(&e_conv);
17065         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
17066         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
17067         return (int64_t)ret_conv;
17068 }
17069
17070 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17071         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
17072         jboolean ret_val = CResult_SignDecodeErrorZ_is_ok(o_conv);
17073         return ret_val;
17074 }
17075
17076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17077         if ((_res & 1) != 0) return;
17078         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17079         CHECK_ACCESS(_res_ptr);
17080         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
17081         FREE((void*)_res);
17082         CResult_SignDecodeErrorZ_free(_res_conv);
17083 }
17084
17085 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
17086         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
17087         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
17088         return (int64_t)ret_conv;
17089 }
17090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17091         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
17092         int64_t ret_val = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
17093         return ret_val;
17094 }
17095
17096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17097         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
17098         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
17099         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
17100         return (int64_t)ret_conv;
17101 }
17102
17103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17104         LDKCVec_u5Z _res_constr;
17105         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17106         if (_res_constr.datalen > 0)
17107                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
17108         else
17109                 _res_constr.data = NULL;
17110         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
17111         for (size_t h = 0; h < _res_constr.datalen; h++) {
17112                 int8_t _res_conv_7 = _res_vals[h];
17113                 
17114                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
17115         }
17116         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
17117         CVec_u5Z_free(_res_constr);
17118 }
17119
17120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17121         LDKRecoverableSignature o_ref;
17122         CHECK((*env)->GetArrayLength(env, o) == 68);
17123         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
17124         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17125         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
17126         return (int64_t)ret_conv;
17127 }
17128
17129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
17130         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17131         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
17132         return (int64_t)ret_conv;
17133 }
17134
17135 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17136         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
17137         jboolean ret_val = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
17138         return ret_val;
17139 }
17140
17141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17142         if ((_res & 1) != 0) return;
17143         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17144         CHECK_ACCESS(_res_ptr);
17145         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
17146         FREE((void*)_res);
17147         CResult_RecoverableSignatureNoneZ_free(_res_conv);
17148 }
17149
17150 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
17151         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17152         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
17153         return (int64_t)ret_conv;
17154 }
17155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17156         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
17157         int64_t ret_val = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
17158         return ret_val;
17159 }
17160
17161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17162         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
17163         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17164         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
17165         return (int64_t)ret_conv;
17166 }
17167
17168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
17169         LDKCVec_u8Z _res_ref;
17170         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
17171         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
17172         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
17173         CVec_u8Z_free(_res_ref);
17174 }
17175
17176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17177         LDKCVec_CVec_u8ZZ _res_constr;
17178         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17179         if (_res_constr.datalen > 0)
17180                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
17181         else
17182                 _res_constr.data = NULL;
17183         for (size_t i = 0; i < _res_constr.datalen; i++) {
17184                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
17185                 LDKCVec_u8Z _res_conv_8_ref;
17186                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
17187                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
17188                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
17189                 _res_constr.data[i] = _res_conv_8_ref;
17190         }
17191         CVec_CVec_u8ZZ_free(_res_constr);
17192 }
17193
17194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
17195         LDKCVec_CVec_u8ZZ o_constr;
17196         o_constr.datalen = (*env)->GetArrayLength(env, o);
17197         if (o_constr.datalen > 0)
17198                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
17199         else
17200                 o_constr.data = NULL;
17201         for (size_t i = 0; i < o_constr.datalen; i++) {
17202                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
17203                 LDKCVec_u8Z o_conv_8_ref;
17204                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
17205                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
17206                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
17207                 o_constr.data[i] = o_conv_8_ref;
17208         }
17209         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17210         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
17211         return (int64_t)ret_conv;
17212 }
17213
17214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
17215         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17216         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
17217         return (int64_t)ret_conv;
17218 }
17219
17220 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17221         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
17222         jboolean ret_val = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
17223         return ret_val;
17224 }
17225
17226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17227         if ((_res & 1) != 0) return;
17228         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17229         CHECK_ACCESS(_res_ptr);
17230         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
17231         FREE((void*)_res);
17232         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
17233 }
17234
17235 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
17236         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17237         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
17238         return (int64_t)ret_conv;
17239 }
17240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17241         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
17242         int64_t ret_val = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
17243         return ret_val;
17244 }
17245
17246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17247         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
17248         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17249         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
17250         return (int64_t)ret_conv;
17251 }
17252
17253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17254         LDKInMemorySigner o_conv;
17255         o_conv.inner = (void*)(o & (~1));
17256         o_conv.is_owned = (o & 1) || (o == 0);
17257         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17258         o_conv = InMemorySigner_clone(&o_conv);
17259         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17260         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
17261         return (int64_t)ret_conv;
17262 }
17263
17264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17265         LDKDecodeError e_conv;
17266         e_conv.inner = (void*)(e & (~1));
17267         e_conv.is_owned = (e & 1) || (e == 0);
17268         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17269         e_conv = DecodeError_clone(&e_conv);
17270         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17271         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
17272         return (int64_t)ret_conv;
17273 }
17274
17275 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17276         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
17277         jboolean ret_val = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
17278         return ret_val;
17279 }
17280
17281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17282         if ((_res & 1) != 0) return;
17283         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17284         CHECK_ACCESS(_res_ptr);
17285         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
17286         FREE((void*)_res);
17287         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
17288 }
17289
17290 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
17291         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17292         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
17293         return (int64_t)ret_conv;
17294 }
17295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17296         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
17297         int64_t ret_val = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
17298         return ret_val;
17299 }
17300
17301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17302         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
17303         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17304         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
17305         return (int64_t)ret_conv;
17306 }
17307
17308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17309         LDKCVec_TxOutZ _res_constr;
17310         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17311         if (_res_constr.datalen > 0)
17312                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
17313         else
17314                 _res_constr.data = NULL;
17315         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17316         for (size_t h = 0; h < _res_constr.datalen; h++) {
17317                 int64_t _res_conv_7 = _res_vals[h];
17318                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
17319                 CHECK_ACCESS(_res_conv_7_ptr);
17320                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
17321                 FREE((void*)_res_conv_7);
17322                 _res_constr.data[h] = _res_conv_7_conv;
17323         }
17324         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17325         CVec_TxOutZ_free(_res_constr);
17326 }
17327
17328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17329         LDKTransaction o_ref;
17330         o_ref.datalen = (*env)->GetArrayLength(env, o);
17331         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
17332         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
17333         o_ref.data_is_owned = true;
17334         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17335         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
17336         return (int64_t)ret_conv;
17337 }
17338
17339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
17340         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17341         *ret_conv = CResult_TransactionNoneZ_err();
17342         return (int64_t)ret_conv;
17343 }
17344
17345 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17346         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
17347         jboolean ret_val = CResult_TransactionNoneZ_is_ok(o_conv);
17348         return ret_val;
17349 }
17350
17351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17352         if ((_res & 1) != 0) return;
17353         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17354         CHECK_ACCESS(_res_ptr);
17355         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
17356         FREE((void*)_res);
17357         CResult_TransactionNoneZ_free(_res_conv);
17358 }
17359
17360 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
17361         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17362         *ret_conv = CResult_TransactionNoneZ_clone(arg);
17363         return (int64_t)ret_conv;
17364 }
17365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17366         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
17367         int64_t ret_val = CResult_TransactionNoneZ_clone_ptr(arg_conv);
17368         return ret_val;
17369 }
17370
17371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17372         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
17373         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17374         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
17375         return (int64_t)ret_conv;
17376 }
17377
17378 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
17379         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17380         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
17381         return ((int64_t)ret_conv);
17382 }
17383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17384         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
17385         int64_t ret_val = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
17386         return ret_val;
17387 }
17388
17389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17390         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
17391         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17392         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
17393         return ((int64_t)ret_conv);
17394 }
17395
17396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
17397         LDKThirtyTwoBytes a_ref;
17398         CHECK((*env)->GetArrayLength(env, a) == 32);
17399         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
17400         LDKChannelMonitor b_conv;
17401         b_conv.inner = (void*)(b & (~1));
17402         b_conv.is_owned = (b & 1) || (b == 0);
17403         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
17404         b_conv = ChannelMonitor_clone(&b_conv);
17405         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17406         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
17407         return ((int64_t)ret_conv);
17408 }
17409
17410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17411         if ((_res & 1) != 0) return;
17412         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17413         CHECK_ACCESS(_res_ptr);
17414         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
17415         FREE((void*)_res);
17416         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
17417 }
17418
17419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17420         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
17421         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17422         if (_res_constr.datalen > 0)
17423                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
17424         else
17425                 _res_constr.data = NULL;
17426         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17427         for (size_t j = 0; j < _res_constr.datalen; j++) {
17428                 int64_t _res_conv_35 = _res_vals[j];
17429                 void* _res_conv_35_ptr = (void*)(((uintptr_t)_res_conv_35) & ~1);
17430                 CHECK_ACCESS(_res_conv_35_ptr);
17431                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
17432                 FREE((void*)_res_conv_35);
17433                 _res_constr.data[j] = _res_conv_35_conv;
17434         }
17435         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17436         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
17437 }
17438
17439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
17440         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
17441         o_constr.datalen = (*env)->GetArrayLength(env, o);
17442         if (o_constr.datalen > 0)
17443                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
17444         else
17445                 o_constr.data = NULL;
17446         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
17447         for (size_t j = 0; j < o_constr.datalen; j++) {
17448                 int64_t o_conv_35 = o_vals[j];
17449                 void* o_conv_35_ptr = (void*)(((uintptr_t)o_conv_35) & ~1);
17450                 CHECK_ACCESS(o_conv_35_ptr);
17451                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
17452                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o_conv_35) & ~1));
17453                 o_constr.data[j] = o_conv_35_conv;
17454         }
17455         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
17456         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17457         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
17458         return (int64_t)ret_conv;
17459 }
17460
17461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17462         LDKIOError e_conv = LDKIOError_from_java(env, e);
17463         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17464         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
17465         return (int64_t)ret_conv;
17466 }
17467
17468 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17469         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(o & ~1);
17470         jboolean ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
17471         return ret_val;
17472 }
17473
17474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17475         if ((_res & 1) != 0) return;
17476         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17477         CHECK_ACCESS(_res_ptr);
17478         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
17479         FREE((void*)_res);
17480         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
17481 }
17482
17483 static inline uintptr_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
17484         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17485         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
17486         return (int64_t)ret_conv;
17487 }
17488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17489         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
17490         int64_t ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
17491         return ret_val;
17492 }
17493
17494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17495         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
17496         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17497         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
17498         return (int64_t)ret_conv;
17499 }
17500
17501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
17502         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17503         *ret_copy = COption_u16Z_some(o);
17504         int64_t ret_ref = (uintptr_t)ret_copy;
17505         return ret_ref;
17506 }
17507
17508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
17509         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17510         *ret_copy = COption_u16Z_none();
17511         int64_t ret_ref = (uintptr_t)ret_copy;
17512         return ret_ref;
17513 }
17514
17515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
17516         if ((_res & 1) != 0) return;
17517         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17518         CHECK_ACCESS(_res_ptr);
17519         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
17520         FREE((void*)_res);
17521         COption_u16Z_free(_res_conv);
17522 }
17523
17524 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
17525         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17526         *ret_copy = COption_u16Z_clone(arg);
17527 int64_t ret_ref = (uintptr_t)ret_copy;
17528         return ret_ref;
17529 }
17530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17531         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
17532         int64_t ret_val = COption_u16Z_clone_ptr(arg_conv);
17533         return ret_val;
17534 }
17535
17536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17537         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
17538         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17539         *ret_copy = COption_u16Z_clone(orig_conv);
17540         int64_t ret_ref = (uintptr_t)ret_copy;
17541         return ret_ref;
17542 }
17543
17544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
17545         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17546         *ret_conv = CResult_NoneAPIErrorZ_ok();
17547         return (int64_t)ret_conv;
17548 }
17549
17550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17551         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17552         CHECK_ACCESS(e_ptr);
17553         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
17554         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
17555         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17556         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
17557         return (int64_t)ret_conv;
17558 }
17559
17560 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17561         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
17562         jboolean ret_val = CResult_NoneAPIErrorZ_is_ok(o_conv);
17563         return ret_val;
17564 }
17565
17566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17567         if ((_res & 1) != 0) return;
17568         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17569         CHECK_ACCESS(_res_ptr);
17570         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
17571         FREE((void*)_res);
17572         CResult_NoneAPIErrorZ_free(_res_conv);
17573 }
17574
17575 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
17576         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17577         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
17578         return (int64_t)ret_conv;
17579 }
17580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17581         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
17582         int64_t ret_val = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
17583         return ret_val;
17584 }
17585
17586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17587         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
17588         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17589         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
17590         return (int64_t)ret_conv;
17591 }
17592
17593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17594         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
17595         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17596         if (_res_constr.datalen > 0)
17597                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
17598         else
17599                 _res_constr.data = NULL;
17600         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17601         for (size_t w = 0; w < _res_constr.datalen; w++) {
17602                 int64_t _res_conv_22 = _res_vals[w];
17603                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
17604                 CHECK_ACCESS(_res_conv_22_ptr);
17605                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
17606                 FREE((void*)_res_conv_22);
17607                 _res_constr.data[w] = _res_conv_22_conv;
17608         }
17609         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17610         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
17611 }
17612
17613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17614         LDKCVec_APIErrorZ _res_constr;
17615         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17616         if (_res_constr.datalen > 0)
17617                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
17618         else
17619                 _res_constr.data = NULL;
17620         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17621         for (size_t k = 0; k < _res_constr.datalen; k++) {
17622                 int64_t _res_conv_10 = _res_vals[k];
17623                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
17624                 CHECK_ACCESS(_res_conv_10_ptr);
17625                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
17626                 FREE((void*)_res_conv_10);
17627                 _res_constr.data[k] = _res_conv_10_conv;
17628         }
17629         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17630         CVec_APIErrorZ_free(_res_constr);
17631 }
17632
17633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17634         LDKThirtyTwoBytes o_ref;
17635         CHECK((*env)->GetArrayLength(env, o) == 32);
17636         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
17637         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17638         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
17639         return (int64_t)ret_conv;
17640 }
17641
17642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17643         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17644         CHECK_ACCESS(e_ptr);
17645         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
17646         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
17647         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17648         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
17649         return (int64_t)ret_conv;
17650 }
17651
17652 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17653         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
17654         jboolean ret_val = CResult__u832APIErrorZ_is_ok(o_conv);
17655         return ret_val;
17656 }
17657
17658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17659         if ((_res & 1) != 0) return;
17660         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17661         CHECK_ACCESS(_res_ptr);
17662         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
17663         FREE((void*)_res);
17664         CResult__u832APIErrorZ_free(_res_conv);
17665 }
17666
17667 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
17668         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17669         *ret_conv = CResult__u832APIErrorZ_clone(arg);
17670         return (int64_t)ret_conv;
17671 }
17672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17673         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
17674         int64_t ret_val = CResult__u832APIErrorZ_clone_ptr(arg_conv);
17675         return ret_val;
17676 }
17677
17678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17679         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
17680         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17681         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
17682         return (int64_t)ret_conv;
17683 }
17684
17685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17686         LDKThirtyTwoBytes o_ref;
17687         CHECK((*env)->GetArrayLength(env, o) == 32);
17688         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
17689         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17690         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
17691         return (int64_t)ret_conv;
17692 }
17693
17694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17695         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17696         CHECK_ACCESS(e_ptr);
17697         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
17698         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
17699         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17700         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
17701         return (int64_t)ret_conv;
17702 }
17703
17704 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17705         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
17706         jboolean ret_val = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
17707         return ret_val;
17708 }
17709
17710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17711         if ((_res & 1) != 0) return;
17712         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17713         CHECK_ACCESS(_res_ptr);
17714         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
17715         FREE((void*)_res);
17716         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
17717 }
17718
17719 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
17720         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17721         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
17722         return (int64_t)ret_conv;
17723 }
17724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17725         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
17726         int64_t ret_val = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
17727         return ret_val;
17728 }
17729
17730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17731         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
17732         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17733         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
17734         return (int64_t)ret_conv;
17735 }
17736
17737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
17738         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17739         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
17740         return (int64_t)ret_conv;
17741 }
17742
17743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17744         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17745         CHECK_ACCESS(e_ptr);
17746         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
17747         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
17748         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17749         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
17750         return (int64_t)ret_conv;
17751 }
17752
17753 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17754         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
17755         jboolean ret_val = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
17756         return ret_val;
17757 }
17758
17759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17760         if ((_res & 1) != 0) return;
17761         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17762         CHECK_ACCESS(_res_ptr);
17763         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
17764         FREE((void*)_res);
17765         CResult_NonePaymentSendFailureZ_free(_res_conv);
17766 }
17767
17768 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
17769         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17770         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
17771         return (int64_t)ret_conv;
17772 }
17773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17774         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
17775         int64_t ret_val = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
17776         return ret_val;
17777 }
17778
17779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17780         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
17781         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17782         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
17783         return (int64_t)ret_conv;
17784 }
17785
17786 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
17787         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
17788         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
17789         return ((int64_t)ret_conv);
17790 }
17791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17792         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
17793         int64_t ret_val = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
17794         return ret_val;
17795 }
17796
17797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17798         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
17799         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
17800         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
17801         return ((int64_t)ret_conv);
17802 }
17803
17804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
17805         LDKThirtyTwoBytes a_ref;
17806         CHECK((*env)->GetArrayLength(env, a) == 32);
17807         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
17808         LDKThirtyTwoBytes b_ref;
17809         CHECK((*env)->GetArrayLength(env, b) == 32);
17810         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
17811         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
17812         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
17813         return ((int64_t)ret_conv);
17814 }
17815
17816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17817         if ((_res & 1) != 0) return;
17818         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17819         CHECK_ACCESS(_res_ptr);
17820         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
17821         FREE((void*)_res);
17822         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
17823 }
17824
17825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17826         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17827         CHECK_ACCESS(o_ptr);
17828         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
17829         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
17830         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17831         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
17832         return (int64_t)ret_conv;
17833 }
17834
17835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17836         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17837         CHECK_ACCESS(e_ptr);
17838         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
17839         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
17840         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17841         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
17842         return (int64_t)ret_conv;
17843 }
17844
17845 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17846         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
17847         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
17848         return ret_val;
17849 }
17850
17851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17852         if ((_res & 1) != 0) return;
17853         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17854         CHECK_ACCESS(_res_ptr);
17855         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
17856         FREE((void*)_res);
17857         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
17858 }
17859
17860 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
17861         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17862         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
17863         return (int64_t)ret_conv;
17864 }
17865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17866         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
17867         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
17868         return ret_val;
17869 }
17870
17871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17872         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
17873         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17874         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
17875         return (int64_t)ret_conv;
17876 }
17877
17878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17879         LDKCVec_NetAddressZ _res_constr;
17880         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17881         if (_res_constr.datalen > 0)
17882                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17883         else
17884                 _res_constr.data = NULL;
17885         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17886         for (size_t m = 0; m < _res_constr.datalen; m++) {
17887                 int64_t _res_conv_12 = _res_vals[m];
17888                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
17889                 CHECK_ACCESS(_res_conv_12_ptr);
17890                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
17891                 FREE((void*)_res_conv_12);
17892                 _res_constr.data[m] = _res_conv_12_conv;
17893         }
17894         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17895         CVec_NetAddressZ_free(_res_constr);
17896 }
17897
17898 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
17899         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17900         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
17901         return ((int64_t)ret_conv);
17902 }
17903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17904         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
17905         int64_t ret_val = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
17906         return ret_val;
17907 }
17908
17909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17910         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
17911         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17912         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
17913         return ((int64_t)ret_conv);
17914 }
17915
17916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
17917         LDKThirtyTwoBytes a_ref;
17918         CHECK((*env)->GetArrayLength(env, a) == 32);
17919         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
17920         LDKThirtyTwoBytes b_ref;
17921         CHECK((*env)->GetArrayLength(env, b) == 32);
17922         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
17923         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17924         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
17925         return ((int64_t)ret_conv);
17926 }
17927
17928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17929         if ((_res & 1) != 0) return;
17930         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17931         CHECK_ACCESS(_res_ptr);
17932         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
17933         FREE((void*)_res);
17934         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
17935 }
17936
17937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17938         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17939         CHECK_ACCESS(o_ptr);
17940         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
17941         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
17942         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
17943         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
17944         return (int64_t)ret_conv;
17945 }
17946
17947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
17948         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
17949         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
17950         return (int64_t)ret_conv;
17951 }
17952
17953 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17954         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
17955         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
17956         return ret_val;
17957 }
17958
17959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17960         if ((_res & 1) != 0) return;
17961         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17962         CHECK_ACCESS(_res_ptr);
17963         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
17964         FREE((void*)_res);
17965         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
17966 }
17967
17968 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
17969         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
17970         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
17971         return (int64_t)ret_conv;
17972 }
17973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17974         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
17975         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
17976         return ret_val;
17977 }
17978
17979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17980         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
17981         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
17982         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
17983         return (int64_t)ret_conv;
17984 }
17985
17986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17987         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17988         CHECK_ACCESS(o_ptr);
17989         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
17990         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
17991         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
17992         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
17993         return (int64_t)ret_conv;
17994 }
17995
17996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17997         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17998         CHECK_ACCESS(e_ptr);
17999         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
18000         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
18001         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
18002         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
18003         return (int64_t)ret_conv;
18004 }
18005
18006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18007         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
18008         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
18009         return ret_val;
18010 }
18011
18012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_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_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
18017         FREE((void*)_res);
18018         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
18019 }
18020
18021 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
18022         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
18023         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
18024         return (int64_t)ret_conv;
18025 }
18026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18027         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
18028         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
18029         return ret_val;
18030 }
18031
18032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18033         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
18034         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
18035         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
18036         return (int64_t)ret_conv;
18037 }
18038
18039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18040         LDKThirtyTwoBytes o_ref;
18041         CHECK((*env)->GetArrayLength(env, o) == 32);
18042         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18043         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
18044         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
18045         return (int64_t)ret_conv;
18046 }
18047
18048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
18049         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
18050         *ret_conv = CResult_PaymentSecretNoneZ_err();
18051         return (int64_t)ret_conv;
18052 }
18053
18054 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18055         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
18056         jboolean ret_val = CResult_PaymentSecretNoneZ_is_ok(o_conv);
18057         return ret_val;
18058 }
18059
18060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18061         if ((_res & 1) != 0) return;
18062         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18063         CHECK_ACCESS(_res_ptr);
18064         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
18065         FREE((void*)_res);
18066         CResult_PaymentSecretNoneZ_free(_res_conv);
18067 }
18068
18069 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
18070         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
18071         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
18072         return (int64_t)ret_conv;
18073 }
18074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18075         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
18076         int64_t ret_val = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
18077         return ret_val;
18078 }
18079
18080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18081         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
18082         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
18083         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
18084         return (int64_t)ret_conv;
18085 }
18086
18087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18088         LDKThirtyTwoBytes o_ref;
18089         CHECK((*env)->GetArrayLength(env, o) == 32);
18090         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18091         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
18092         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
18093         return (int64_t)ret_conv;
18094 }
18095
18096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18097         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18098         CHECK_ACCESS(e_ptr);
18099         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
18100         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
18101         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
18102         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
18103         return (int64_t)ret_conv;
18104 }
18105
18106 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18107         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
18108         jboolean ret_val = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
18109         return ret_val;
18110 }
18111
18112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18113         if ((_res & 1) != 0) return;
18114         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18115         CHECK_ACCESS(_res_ptr);
18116         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
18117         FREE((void*)_res);
18118         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
18119 }
18120
18121 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
18122         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
18123         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
18124         return (int64_t)ret_conv;
18125 }
18126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18127         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
18128         int64_t ret_val = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
18129         return ret_val;
18130 }
18131
18132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18133         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
18134         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
18135         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
18136         return (int64_t)ret_conv;
18137 }
18138
18139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18140         LDKThirtyTwoBytes o_ref;
18141         CHECK((*env)->GetArrayLength(env, o) == 32);
18142         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18143         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
18144         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
18145         return (int64_t)ret_conv;
18146 }
18147
18148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18149         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18150         CHECK_ACCESS(e_ptr);
18151         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
18152         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
18153         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
18154         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
18155         return (int64_t)ret_conv;
18156 }
18157
18158 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18159         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
18160         jboolean ret_val = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
18161         return ret_val;
18162 }
18163
18164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18165         if ((_res & 1) != 0) return;
18166         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18167         CHECK_ACCESS(_res_ptr);
18168         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
18169         FREE((void*)_res);
18170         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
18171 }
18172
18173 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
18174         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
18175         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
18176         return (int64_t)ret_conv;
18177 }
18178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18179         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
18180         int64_t ret_val = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
18181         return ret_val;
18182 }
18183
18184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18185         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
18186         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
18187         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
18188         return (int64_t)ret_conv;
18189 }
18190
18191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18192         LDKCounterpartyForwardingInfo o_conv;
18193         o_conv.inner = (void*)(o & (~1));
18194         o_conv.is_owned = (o & 1) || (o == 0);
18195         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18196         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
18197         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
18198         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
18199         return (int64_t)ret_conv;
18200 }
18201
18202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18203         LDKDecodeError e_conv;
18204         e_conv.inner = (void*)(e & (~1));
18205         e_conv.is_owned = (e & 1) || (e == 0);
18206         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18207         e_conv = DecodeError_clone(&e_conv);
18208         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
18209         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
18210         return (int64_t)ret_conv;
18211 }
18212
18213 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18214         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
18215         jboolean ret_val = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
18216         return ret_val;
18217 }
18218
18219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18220         if ((_res & 1) != 0) return;
18221         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18222         CHECK_ACCESS(_res_ptr);
18223         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
18224         FREE((void*)_res);
18225         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
18226 }
18227
18228 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
18229         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
18230         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
18231         return (int64_t)ret_conv;
18232 }
18233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18234         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
18235         int64_t ret_val = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
18236         return ret_val;
18237 }
18238
18239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18240         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
18241         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
18242         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
18243         return (int64_t)ret_conv;
18244 }
18245
18246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18247         LDKChannelCounterparty o_conv;
18248         o_conv.inner = (void*)(o & (~1));
18249         o_conv.is_owned = (o & 1) || (o == 0);
18250         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18251         o_conv = ChannelCounterparty_clone(&o_conv);
18252         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18253         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
18254         return (int64_t)ret_conv;
18255 }
18256
18257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18258         LDKDecodeError e_conv;
18259         e_conv.inner = (void*)(e & (~1));
18260         e_conv.is_owned = (e & 1) || (e == 0);
18261         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18262         e_conv = DecodeError_clone(&e_conv);
18263         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18264         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
18265         return (int64_t)ret_conv;
18266 }
18267
18268 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18269         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
18270         jboolean ret_val = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
18271         return ret_val;
18272 }
18273
18274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18275         if ((_res & 1) != 0) return;
18276         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18277         CHECK_ACCESS(_res_ptr);
18278         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
18279         FREE((void*)_res);
18280         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
18281 }
18282
18283 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
18284         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18285         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
18286         return (int64_t)ret_conv;
18287 }
18288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18289         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
18290         int64_t ret_val = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
18291         return ret_val;
18292 }
18293
18294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18295         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
18296         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18297         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
18298         return (int64_t)ret_conv;
18299 }
18300
18301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18302         LDKChannelDetails o_conv;
18303         o_conv.inner = (void*)(o & (~1));
18304         o_conv.is_owned = (o & 1) || (o == 0);
18305         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18306         o_conv = ChannelDetails_clone(&o_conv);
18307         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18308         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
18309         return (int64_t)ret_conv;
18310 }
18311
18312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18313         LDKDecodeError e_conv;
18314         e_conv.inner = (void*)(e & (~1));
18315         e_conv.is_owned = (e & 1) || (e == 0);
18316         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18317         e_conv = DecodeError_clone(&e_conv);
18318         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18319         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
18320         return (int64_t)ret_conv;
18321 }
18322
18323 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18324         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
18325         jboolean ret_val = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
18326         return ret_val;
18327 }
18328
18329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18330         if ((_res & 1) != 0) return;
18331         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18332         CHECK_ACCESS(_res_ptr);
18333         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
18334         FREE((void*)_res);
18335         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
18336 }
18337
18338 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
18339         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18340         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
18341         return (int64_t)ret_conv;
18342 }
18343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18344         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
18345         int64_t ret_val = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
18346         return ret_val;
18347 }
18348
18349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18350         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
18351         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18352         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
18353         return (int64_t)ret_conv;
18354 }
18355
18356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18357         LDKPhantomRouteHints o_conv;
18358         o_conv.inner = (void*)(o & (~1));
18359         o_conv.is_owned = (o & 1) || (o == 0);
18360         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18361         o_conv = PhantomRouteHints_clone(&o_conv);
18362         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
18363         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
18364         return (int64_t)ret_conv;
18365 }
18366
18367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18368         LDKDecodeError e_conv;
18369         e_conv.inner = (void*)(e & (~1));
18370         e_conv.is_owned = (e & 1) || (e == 0);
18371         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18372         e_conv = DecodeError_clone(&e_conv);
18373         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
18374         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
18375         return (int64_t)ret_conv;
18376 }
18377
18378 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18379         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
18380         jboolean ret_val = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
18381         return ret_val;
18382 }
18383
18384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18385         if ((_res & 1) != 0) return;
18386         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18387         CHECK_ACCESS(_res_ptr);
18388         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
18389         FREE((void*)_res);
18390         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
18391 }
18392
18393 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
18394         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
18395         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
18396         return (int64_t)ret_conv;
18397 }
18398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18399         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
18400         int64_t ret_val = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
18401         return ret_val;
18402 }
18403
18404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18405         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
18406         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
18407         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
18408         return (int64_t)ret_conv;
18409 }
18410
18411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18412         LDKCVec_ChannelMonitorZ _res_constr;
18413         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18414         if (_res_constr.datalen > 0)
18415                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
18416         else
18417                 _res_constr.data = NULL;
18418         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18419         for (size_t q = 0; q < _res_constr.datalen; q++) {
18420                 int64_t _res_conv_16 = _res_vals[q];
18421                 LDKChannelMonitor _res_conv_16_conv;
18422                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
18423                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
18424                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
18425                 _res_constr.data[q] = _res_conv_16_conv;
18426         }
18427         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18428         CVec_ChannelMonitorZ_free(_res_constr);
18429 }
18430
18431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
18432         LDKThirtyTwoBytes a_ref;
18433         CHECK((*env)->GetArrayLength(env, a) == 32);
18434         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18435         LDKChannelManager b_conv;
18436         b_conv.inner = (void*)(b & (~1));
18437         b_conv.is_owned = (b & 1) || (b == 0);
18438         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18439         // WARNING: we need a move here but no clone is available for LDKChannelManager
18440         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
18441         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
18442         return ((int64_t)ret_conv);
18443 }
18444
18445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18446         if ((_res & 1) != 0) return;
18447         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18448         CHECK_ACCESS(_res_ptr);
18449         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
18450         FREE((void*)_res);
18451         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
18452 }
18453
18454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18455         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18456         CHECK_ACCESS(o_ptr);
18457         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
18458         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
18459         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
18460         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
18461         return (int64_t)ret_conv;
18462 }
18463
18464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18465         LDKDecodeError e_conv;
18466         e_conv.inner = (void*)(e & (~1));
18467         e_conv.is_owned = (e & 1) || (e == 0);
18468         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18469         e_conv = DecodeError_clone(&e_conv);
18470         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
18471         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
18472         return (int64_t)ret_conv;
18473 }
18474
18475 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18476         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
18477         jboolean ret_val = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
18478         return ret_val;
18479 }
18480
18481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18482         if ((_res & 1) != 0) return;
18483         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18484         CHECK_ACCESS(_res_ptr);
18485         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
18486         FREE((void*)_res);
18487         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
18488 }
18489
18490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18491         LDKChannelConfig o_conv;
18492         o_conv.inner = (void*)(o & (~1));
18493         o_conv.is_owned = (o & 1) || (o == 0);
18494         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18495         o_conv = ChannelConfig_clone(&o_conv);
18496         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18497         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
18498         return (int64_t)ret_conv;
18499 }
18500
18501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18502         LDKDecodeError e_conv;
18503         e_conv.inner = (void*)(e & (~1));
18504         e_conv.is_owned = (e & 1) || (e == 0);
18505         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18506         e_conv = DecodeError_clone(&e_conv);
18507         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18508         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
18509         return (int64_t)ret_conv;
18510 }
18511
18512 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18513         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
18514         jboolean ret_val = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
18515         return ret_val;
18516 }
18517
18518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18519         if ((_res & 1) != 0) return;
18520         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18521         CHECK_ACCESS(_res_ptr);
18522         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
18523         FREE((void*)_res);
18524         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
18525 }
18526
18527 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
18528         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18529         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
18530         return (int64_t)ret_conv;
18531 }
18532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18533         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
18534         int64_t ret_val = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
18535         return ret_val;
18536 }
18537
18538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18539         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
18540         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18541         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
18542         return (int64_t)ret_conv;
18543 }
18544
18545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18546         LDKOutPoint o_conv;
18547         o_conv.inner = (void*)(o & (~1));
18548         o_conv.is_owned = (o & 1) || (o == 0);
18549         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18550         o_conv = OutPoint_clone(&o_conv);
18551         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18552         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
18553         return (int64_t)ret_conv;
18554 }
18555
18556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_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_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18563         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
18564         return (int64_t)ret_conv;
18565 }
18566
18567 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18568         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
18569         jboolean ret_val = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
18570         return ret_val;
18571 }
18572
18573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_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_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
18578         FREE((void*)_res);
18579         CResult_OutPointDecodeErrorZ_free(_res_conv);
18580 }
18581
18582 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
18583         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18584         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
18585         return (int64_t)ret_conv;
18586 }
18587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18588         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
18589         int64_t ret_val = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
18590         return ret_val;
18591 }
18592
18593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18594         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
18595         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18596         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
18597         return (int64_t)ret_conv;
18598 }
18599
18600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18601         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18602         CHECK_ACCESS(o_ptr);
18603         LDKType o_conv = *(LDKType*)(o_ptr);
18604         if (o_conv.free == LDKType_JCalls_free) {
18605                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18606                 LDKType_JCalls_cloned(&o_conv);
18607         }
18608         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18609         *ret_copy = COption_TypeZ_some(o_conv);
18610         int64_t ret_ref = (uintptr_t)ret_copy;
18611         return ret_ref;
18612 }
18613
18614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
18615         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18616         *ret_copy = COption_TypeZ_none();
18617         int64_t ret_ref = (uintptr_t)ret_copy;
18618         return ret_ref;
18619 }
18620
18621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18622         if ((_res & 1) != 0) return;
18623         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18624         CHECK_ACCESS(_res_ptr);
18625         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
18626         FREE((void*)_res);
18627         COption_TypeZ_free(_res_conv);
18628 }
18629
18630 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
18631         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18632         *ret_copy = COption_TypeZ_clone(arg);
18633 int64_t ret_ref = (uintptr_t)ret_copy;
18634         return ret_ref;
18635 }
18636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18637         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
18638         int64_t ret_val = COption_TypeZ_clone_ptr(arg_conv);
18639         return ret_val;
18640 }
18641
18642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18643         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
18644         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18645         *ret_copy = COption_TypeZ_clone(orig_conv);
18646         int64_t ret_ref = (uintptr_t)ret_copy;
18647         return ret_ref;
18648 }
18649
18650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18651         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18652         CHECK_ACCESS(o_ptr);
18653         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
18654         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
18655         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18656         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
18657         return (int64_t)ret_conv;
18658 }
18659
18660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18661         LDKDecodeError e_conv;
18662         e_conv.inner = (void*)(e & (~1));
18663         e_conv.is_owned = (e & 1) || (e == 0);
18664         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18665         e_conv = DecodeError_clone(&e_conv);
18666         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18667         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
18668         return (int64_t)ret_conv;
18669 }
18670
18671 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18672         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
18673         jboolean ret_val = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
18674         return ret_val;
18675 }
18676
18677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18678         if ((_res & 1) != 0) return;
18679         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18680         CHECK_ACCESS(_res_ptr);
18681         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
18682         FREE((void*)_res);
18683         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
18684 }
18685
18686 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
18687         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18688         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
18689         return (int64_t)ret_conv;
18690 }
18691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18692         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
18693         int64_t ret_val = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
18694         return ret_val;
18695 }
18696
18697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18698         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
18699         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18700         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
18701         return (int64_t)ret_conv;
18702 }
18703
18704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18705         LDKThirtyTwoBytes o_ref;
18706         CHECK((*env)->GetArrayLength(env, o) == 32);
18707         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18708         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18709         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
18710         return (int64_t)ret_conv;
18711 }
18712
18713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18714         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18715         CHECK_ACCESS(e_ptr);
18716         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
18717         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
18718         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18719         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
18720         return (int64_t)ret_conv;
18721 }
18722
18723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18724         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
18725         jboolean ret_val = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
18726         return ret_val;
18727 }
18728
18729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18730         if ((_res & 1) != 0) return;
18731         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18732         CHECK_ACCESS(_res_ptr);
18733         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
18734         FREE((void*)_res);
18735         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
18736 }
18737
18738 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
18739         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18740         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
18741         return (int64_t)ret_conv;
18742 }
18743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18744         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
18745         int64_t ret_val = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
18746         return ret_val;
18747 }
18748
18749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18750         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
18751         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18752         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
18753         return (int64_t)ret_conv;
18754 }
18755
18756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
18757         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
18758         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
18759         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
18760         return (int64_t)ret_conv;
18761 }
18762
18763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18764         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18765         CHECK_ACCESS(e_ptr);
18766         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
18767         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
18768         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
18769         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
18770         return (int64_t)ret_conv;
18771 }
18772
18773 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18774         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
18775         jboolean ret_val = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
18776         return ret_val;
18777 }
18778
18779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18780         if ((_res & 1) != 0) return;
18781         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18782         CHECK_ACCESS(_res_ptr);
18783         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
18784         FREE((void*)_res);
18785         CResult_SiPrefixParseErrorZ_free(_res_conv);
18786 }
18787
18788 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
18789         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
18790         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
18791         return (int64_t)ret_conv;
18792 }
18793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18794         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
18795         int64_t ret_val = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
18796         return ret_val;
18797 }
18798
18799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18800         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
18801         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
18802         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
18803         return (int64_t)ret_conv;
18804 }
18805
18806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18807         LDKInvoice o_conv;
18808         o_conv.inner = (void*)(o & (~1));
18809         o_conv.is_owned = (o & 1) || (o == 0);
18810         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18811         o_conv = Invoice_clone(&o_conv);
18812         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
18813         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
18814         return (int64_t)ret_conv;
18815 }
18816
18817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18818         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18819         CHECK_ACCESS(e_ptr);
18820         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
18821         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
18822         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
18823         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
18824         return (int64_t)ret_conv;
18825 }
18826
18827 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18828         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
18829         jboolean ret_val = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
18830         return ret_val;
18831 }
18832
18833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18834         if ((_res & 1) != 0) return;
18835         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18836         CHECK_ACCESS(_res_ptr);
18837         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
18838         FREE((void*)_res);
18839         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
18840 }
18841
18842 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
18843         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
18844         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
18845         return (int64_t)ret_conv;
18846 }
18847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18848         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
18849         int64_t ret_val = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
18850         return ret_val;
18851 }
18852
18853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18854         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
18855         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
18856         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
18857         return (int64_t)ret_conv;
18858 }
18859
18860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18861         LDKSignedRawInvoice o_conv;
18862         o_conv.inner = (void*)(o & (~1));
18863         o_conv.is_owned = (o & 1) || (o == 0);
18864         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18865         o_conv = SignedRawInvoice_clone(&o_conv);
18866         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
18867         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
18868         return (int64_t)ret_conv;
18869 }
18870
18871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18872         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18873         CHECK_ACCESS(e_ptr);
18874         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
18875         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
18876         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
18877         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
18878         return (int64_t)ret_conv;
18879 }
18880
18881 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18882         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
18883         jboolean ret_val = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
18884         return ret_val;
18885 }
18886
18887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18888         if ((_res & 1) != 0) return;
18889         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18890         CHECK_ACCESS(_res_ptr);
18891         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
18892         FREE((void*)_res);
18893         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
18894 }
18895
18896 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
18897         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
18898         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
18899         return (int64_t)ret_conv;
18900 }
18901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18902         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
18903         int64_t ret_val = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
18904         return ret_val;
18905 }
18906
18907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18908         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
18909         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
18910         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
18911         return (int64_t)ret_conv;
18912 }
18913
18914 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
18915         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
18916         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
18917         return ((int64_t)ret_conv);
18918 }
18919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18920         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
18921         int64_t ret_val = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
18922         return ret_val;
18923 }
18924
18925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18926         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
18927         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
18928         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
18929         return ((int64_t)ret_conv);
18930 }
18931
18932 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) {
18933         LDKRawInvoice a_conv;
18934         a_conv.inner = (void*)(a & (~1));
18935         a_conv.is_owned = (a & 1) || (a == 0);
18936         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18937         a_conv = RawInvoice_clone(&a_conv);
18938         LDKThirtyTwoBytes b_ref;
18939         CHECK((*env)->GetArrayLength(env, b) == 32);
18940         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
18941         LDKInvoiceSignature c_conv;
18942         c_conv.inner = (void*)(c & (~1));
18943         c_conv.is_owned = (c & 1) || (c == 0);
18944         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
18945         c_conv = InvoiceSignature_clone(&c_conv);
18946         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
18947         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
18948         return ((int64_t)ret_conv);
18949 }
18950
18951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18952         if ((_res & 1) != 0) return;
18953         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18954         CHECK_ACCESS(_res_ptr);
18955         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
18956         FREE((void*)_res);
18957         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
18958 }
18959
18960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18961         LDKPayeePubKey o_conv;
18962         o_conv.inner = (void*)(o & (~1));
18963         o_conv.is_owned = (o & 1) || (o == 0);
18964         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18965         o_conv = PayeePubKey_clone(&o_conv);
18966         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
18967         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
18968         return (int64_t)ret_conv;
18969 }
18970
18971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18972         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
18973         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
18974         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
18975         return (int64_t)ret_conv;
18976 }
18977
18978 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18979         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
18980         jboolean ret_val = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
18981         return ret_val;
18982 }
18983
18984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18985         if ((_res & 1) != 0) return;
18986         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18987         CHECK_ACCESS(_res_ptr);
18988         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
18989         FREE((void*)_res);
18990         CResult_PayeePubKeyErrorZ_free(_res_conv);
18991 }
18992
18993 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
18994         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
18995         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
18996         return (int64_t)ret_conv;
18997 }
18998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18999         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
19000         int64_t ret_val = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
19001         return ret_val;
19002 }
19003
19004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19005         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
19006         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
19007         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
19008         return (int64_t)ret_conv;
19009 }
19010
19011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19012         LDKCVec_PrivateRouteZ _res_constr;
19013         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19014         if (_res_constr.datalen > 0)
19015                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
19016         else
19017                 _res_constr.data = NULL;
19018         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19019         for (size_t o = 0; o < _res_constr.datalen; o++) {
19020                 int64_t _res_conv_14 = _res_vals[o];
19021                 LDKPrivateRoute _res_conv_14_conv;
19022                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
19023                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
19024                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
19025                 _res_constr.data[o] = _res_conv_14_conv;
19026         }
19027         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19028         CVec_PrivateRouteZ_free(_res_constr);
19029 }
19030
19031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19032         LDKPositiveTimestamp o_conv;
19033         o_conv.inner = (void*)(o & (~1));
19034         o_conv.is_owned = (o & 1) || (o == 0);
19035         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19036         o_conv = PositiveTimestamp_clone(&o_conv);
19037         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
19038         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
19039         return (int64_t)ret_conv;
19040 }
19041
19042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19043         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
19044         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
19045         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
19046         return (int64_t)ret_conv;
19047 }
19048
19049 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19050         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
19051         jboolean ret_val = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
19052         return ret_val;
19053 }
19054
19055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19056         if ((_res & 1) != 0) return;
19057         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19058         CHECK_ACCESS(_res_ptr);
19059         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
19060         FREE((void*)_res);
19061         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
19062 }
19063
19064 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
19065         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
19066         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
19067         return (int64_t)ret_conv;
19068 }
19069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19070         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
19071         int64_t ret_val = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
19072         return ret_val;
19073 }
19074
19075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19076         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
19077         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
19078         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
19079         return (int64_t)ret_conv;
19080 }
19081
19082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
19083         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
19084         *ret_conv = CResult_NoneSemanticErrorZ_ok();
19085         return (int64_t)ret_conv;
19086 }
19087
19088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19089         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
19090         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
19091         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
19092         return (int64_t)ret_conv;
19093 }
19094
19095 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19096         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
19097         jboolean ret_val = CResult_NoneSemanticErrorZ_is_ok(o_conv);
19098         return ret_val;
19099 }
19100
19101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19102         if ((_res & 1) != 0) return;
19103         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19104         CHECK_ACCESS(_res_ptr);
19105         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
19106         FREE((void*)_res);
19107         CResult_NoneSemanticErrorZ_free(_res_conv);
19108 }
19109
19110 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
19111         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
19112         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
19113         return (int64_t)ret_conv;
19114 }
19115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19116         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
19117         int64_t ret_val = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
19118         return ret_val;
19119 }
19120
19121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19122         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
19123         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
19124         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
19125         return (int64_t)ret_conv;
19126 }
19127
19128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19129         LDKInvoice o_conv;
19130         o_conv.inner = (void*)(o & (~1));
19131         o_conv.is_owned = (o & 1) || (o == 0);
19132         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19133         o_conv = Invoice_clone(&o_conv);
19134         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
19135         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
19136         return (int64_t)ret_conv;
19137 }
19138
19139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19140         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
19141         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
19142         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
19143         return (int64_t)ret_conv;
19144 }
19145
19146 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19147         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
19148         jboolean ret_val = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
19149         return ret_val;
19150 }
19151
19152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19153         if ((_res & 1) != 0) return;
19154         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19155         CHECK_ACCESS(_res_ptr);
19156         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
19157         FREE((void*)_res);
19158         CResult_InvoiceSemanticErrorZ_free(_res_conv);
19159 }
19160
19161 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
19162         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
19163         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
19164         return (int64_t)ret_conv;
19165 }
19166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19167         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
19168         int64_t ret_val = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
19169         return ret_val;
19170 }
19171
19172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19173         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
19174         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
19175         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
19176         return (int64_t)ret_conv;
19177 }
19178
19179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19180         LDKDescription o_conv;
19181         o_conv.inner = (void*)(o & (~1));
19182         o_conv.is_owned = (o & 1) || (o == 0);
19183         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19184         o_conv = Description_clone(&o_conv);
19185         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
19186         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
19187         return (int64_t)ret_conv;
19188 }
19189
19190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19191         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
19192         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
19193         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
19194         return (int64_t)ret_conv;
19195 }
19196
19197 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19198         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
19199         jboolean ret_val = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
19200         return ret_val;
19201 }
19202
19203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19204         if ((_res & 1) != 0) return;
19205         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19206         CHECK_ACCESS(_res_ptr);
19207         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
19208         FREE((void*)_res);
19209         CResult_DescriptionCreationErrorZ_free(_res_conv);
19210 }
19211
19212 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
19213         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
19214         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
19215         return (int64_t)ret_conv;
19216 }
19217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19218         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
19219         int64_t ret_val = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
19220         return ret_val;
19221 }
19222
19223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19224         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
19225         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
19226         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
19227         return (int64_t)ret_conv;
19228 }
19229
19230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19231         LDKPrivateRoute o_conv;
19232         o_conv.inner = (void*)(o & (~1));
19233         o_conv.is_owned = (o & 1) || (o == 0);
19234         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19235         o_conv = PrivateRoute_clone(&o_conv);
19236         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
19237         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
19238         return (int64_t)ret_conv;
19239 }
19240
19241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19242         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
19243         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
19244         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
19245         return (int64_t)ret_conv;
19246 }
19247
19248 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19249         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
19250         jboolean ret_val = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
19251         return ret_val;
19252 }
19253
19254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19255         if ((_res & 1) != 0) return;
19256         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19257         CHECK_ACCESS(_res_ptr);
19258         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
19259         FREE((void*)_res);
19260         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
19261 }
19262
19263 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
19264         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
19265         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
19266         return (int64_t)ret_conv;
19267 }
19268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19269         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
19270         int64_t ret_val = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
19271         return ret_val;
19272 }
19273
19274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19275         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
19276         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
19277         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
19278         return (int64_t)ret_conv;
19279 }
19280
19281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
19282         LDKStr o_conv = java_to_owned_str(env, o);
19283         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
19284         *ret_conv = CResult_StringErrorZ_ok(o_conv);
19285         return (int64_t)ret_conv;
19286 }
19287
19288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19289         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
19290         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
19291         *ret_conv = CResult_StringErrorZ_err(e_conv);
19292         return (int64_t)ret_conv;
19293 }
19294
19295 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19296         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
19297         jboolean ret_val = CResult_StringErrorZ_is_ok(o_conv);
19298         return ret_val;
19299 }
19300
19301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19302         if ((_res & 1) != 0) return;
19303         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19304         CHECK_ACCESS(_res_ptr);
19305         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
19306         FREE((void*)_res);
19307         CResult_StringErrorZ_free(_res_conv);
19308 }
19309
19310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19311         LDKChannelMonitorUpdate o_conv;
19312         o_conv.inner = (void*)(o & (~1));
19313         o_conv.is_owned = (o & 1) || (o == 0);
19314         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19315         o_conv = ChannelMonitorUpdate_clone(&o_conv);
19316         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19317         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
19318         return (int64_t)ret_conv;
19319 }
19320
19321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19322         LDKDecodeError e_conv;
19323         e_conv.inner = (void*)(e & (~1));
19324         e_conv.is_owned = (e & 1) || (e == 0);
19325         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19326         e_conv = DecodeError_clone(&e_conv);
19327         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19328         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
19329         return (int64_t)ret_conv;
19330 }
19331
19332 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19333         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
19334         jboolean ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
19335         return ret_val;
19336 }
19337
19338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19339         if ((_res & 1) != 0) return;
19340         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19341         CHECK_ACCESS(_res_ptr);
19342         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
19343         FREE((void*)_res);
19344         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
19345 }
19346
19347 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
19348         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19349         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
19350         return (int64_t)ret_conv;
19351 }
19352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19353         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
19354         int64_t ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
19355         return ret_val;
19356 }
19357
19358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19359         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
19360         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19361         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
19362         return (int64_t)ret_conv;
19363 }
19364
19365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19366         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19367         CHECK_ACCESS(o_ptr);
19368         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
19369         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
19370         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
19371         *ret_copy = COption_MonitorEventZ_some(o_conv);
19372         int64_t ret_ref = (uintptr_t)ret_copy;
19373         return ret_ref;
19374 }
19375
19376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
19377         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
19378         *ret_copy = COption_MonitorEventZ_none();
19379         int64_t ret_ref = (uintptr_t)ret_copy;
19380         return ret_ref;
19381 }
19382
19383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19384         if ((_res & 1) != 0) return;
19385         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19386         CHECK_ACCESS(_res_ptr);
19387         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
19388         FREE((void*)_res);
19389         COption_MonitorEventZ_free(_res_conv);
19390 }
19391
19392 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
19393         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
19394         *ret_copy = COption_MonitorEventZ_clone(arg);
19395 int64_t ret_ref = (uintptr_t)ret_copy;
19396         return ret_ref;
19397 }
19398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19399         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
19400         int64_t ret_val = COption_MonitorEventZ_clone_ptr(arg_conv);
19401         return ret_val;
19402 }
19403
19404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19405         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
19406         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
19407         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
19408         int64_t ret_ref = (uintptr_t)ret_copy;
19409         return ret_ref;
19410 }
19411
19412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19413         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19414         CHECK_ACCESS(o_ptr);
19415         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
19416         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
19417         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19418         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
19419         return (int64_t)ret_conv;
19420 }
19421
19422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19423         LDKDecodeError e_conv;
19424         e_conv.inner = (void*)(e & (~1));
19425         e_conv.is_owned = (e & 1) || (e == 0);
19426         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19427         e_conv = DecodeError_clone(&e_conv);
19428         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19429         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
19430         return (int64_t)ret_conv;
19431 }
19432
19433 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19434         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
19435         jboolean ret_val = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
19436         return ret_val;
19437 }
19438
19439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19440         if ((_res & 1) != 0) return;
19441         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19442         CHECK_ACCESS(_res_ptr);
19443         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
19444         FREE((void*)_res);
19445         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
19446 }
19447
19448 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
19449         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19450         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
19451         return (int64_t)ret_conv;
19452 }
19453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19454         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
19455         int64_t ret_val = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
19456         return ret_val;
19457 }
19458
19459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19460         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
19461         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19462         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
19463         return (int64_t)ret_conv;
19464 }
19465
19466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19467         LDKHTLCUpdate o_conv;
19468         o_conv.inner = (void*)(o & (~1));
19469         o_conv.is_owned = (o & 1) || (o == 0);
19470         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19471         o_conv = HTLCUpdate_clone(&o_conv);
19472         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19473         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
19474         return (int64_t)ret_conv;
19475 }
19476
19477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19478         LDKDecodeError e_conv;
19479         e_conv.inner = (void*)(e & (~1));
19480         e_conv.is_owned = (e & 1) || (e == 0);
19481         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19482         e_conv = DecodeError_clone(&e_conv);
19483         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19484         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
19485         return (int64_t)ret_conv;
19486 }
19487
19488 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19489         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
19490         jboolean ret_val = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
19491         return ret_val;
19492 }
19493
19494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19495         if ((_res & 1) != 0) return;
19496         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19497         CHECK_ACCESS(_res_ptr);
19498         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
19499         FREE((void*)_res);
19500         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
19501 }
19502
19503 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
19504         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19505         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
19506         return (int64_t)ret_conv;
19507 }
19508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19509         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
19510         int64_t ret_val = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
19511         return ret_val;
19512 }
19513
19514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19515         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
19516         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19517         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
19518         return (int64_t)ret_conv;
19519 }
19520
19521 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
19522         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19523         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
19524         return ((int64_t)ret_conv);
19525 }
19526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19527         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
19528         int64_t ret_val = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
19529         return ret_val;
19530 }
19531
19532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19533         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
19534         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19535         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
19536         return ((int64_t)ret_conv);
19537 }
19538
19539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
19540         LDKOutPoint a_conv;
19541         a_conv.inner = (void*)(a & (~1));
19542         a_conv.is_owned = (a & 1) || (a == 0);
19543         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19544         a_conv = OutPoint_clone(&a_conv);
19545         LDKCVec_u8Z b_ref;
19546         b_ref.datalen = (*env)->GetArrayLength(env, b);
19547         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
19548         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
19549         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19550         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
19551         return ((int64_t)ret_conv);
19552 }
19553
19554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_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         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
19559         FREE((void*)_res);
19560         C2Tuple_OutPointScriptZ_free(_res_conv);
19561 }
19562
19563 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
19564         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
19565         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
19566         return ((int64_t)ret_conv);
19567 }
19568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19569         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
19570         int64_t ret_val = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
19571         return ret_val;
19572 }
19573
19574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19575         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
19576         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
19577         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
19578         return ((int64_t)ret_conv);
19579 }
19580
19581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
19582         LDKCVec_u8Z b_ref;
19583         b_ref.datalen = (*env)->GetArrayLength(env, b);
19584         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
19585         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
19586         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
19587         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
19588         return ((int64_t)ret_conv);
19589 }
19590
19591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19592         if ((_res & 1) != 0) return;
19593         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19594         CHECK_ACCESS(_res_ptr);
19595         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
19596         FREE((void*)_res);
19597         C2Tuple_u32ScriptZ_free(_res_conv);
19598 }
19599
19600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19601         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
19602         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19603         if (_res_constr.datalen > 0)
19604                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
19605         else
19606                 _res_constr.data = NULL;
19607         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19608         for (size_t v = 0; v < _res_constr.datalen; v++) {
19609                 int64_t _res_conv_21 = _res_vals[v];
19610                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
19611                 CHECK_ACCESS(_res_conv_21_ptr);
19612                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
19613                 FREE((void*)_res_conv_21);
19614                 _res_constr.data[v] = _res_conv_21_conv;
19615         }
19616         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19617         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
19618 }
19619
19620 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
19621         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19622         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
19623         return ((int64_t)ret_conv);
19624 }
19625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19626         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
19627         int64_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
19628         return ret_val;
19629 }
19630
19631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19632         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
19633         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19634         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
19635         return ((int64_t)ret_conv);
19636 }
19637
19638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
19639         LDKThirtyTwoBytes a_ref;
19640         CHECK((*env)->GetArrayLength(env, a) == 32);
19641         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19642         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
19643         b_constr.datalen = (*env)->GetArrayLength(env, b);
19644         if (b_constr.datalen > 0)
19645                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
19646         else
19647                 b_constr.data = NULL;
19648         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
19649         for (size_t v = 0; v < b_constr.datalen; v++) {
19650                 int64_t b_conv_21 = b_vals[v];
19651                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
19652                 CHECK_ACCESS(b_conv_21_ptr);
19653                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
19654                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
19655                 b_constr.data[v] = b_conv_21_conv;
19656         }
19657         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
19658         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19659         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
19660         return ((int64_t)ret_conv);
19661 }
19662
19663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19664         if ((_res & 1) != 0) return;
19665         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19666         CHECK_ACCESS(_res_ptr);
19667         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
19668         FREE((void*)_res);
19669         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
19670 }
19671
19672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19673         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
19674         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19675         if (_res_constr.datalen > 0)
19676                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
19677         else
19678                 _res_constr.data = NULL;
19679         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19680         for (size_t o = 0; o < _res_constr.datalen; o++) {
19681                 int64_t _res_conv_40 = _res_vals[o];
19682                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
19683                 CHECK_ACCESS(_res_conv_40_ptr);
19684                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
19685                 FREE((void*)_res_conv_40);
19686                 _res_constr.data[o] = _res_conv_40_conv;
19687         }
19688         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19689         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
19690 }
19691
19692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19693         LDKCVec_EventZ _res_constr;
19694         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19695         if (_res_constr.datalen > 0)
19696                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
19697         else
19698                 _res_constr.data = NULL;
19699         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19700         for (size_t h = 0; h < _res_constr.datalen; h++) {
19701                 int64_t _res_conv_7 = _res_vals[h];
19702                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
19703                 CHECK_ACCESS(_res_conv_7_ptr);
19704                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
19705                 FREE((void*)_res_conv_7);
19706                 _res_constr.data[h] = _res_conv_7_conv;
19707         }
19708         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19709         CVec_EventZ_free(_res_constr);
19710 }
19711
19712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19713         LDKCVec_TransactionZ _res_constr;
19714         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19715         if (_res_constr.datalen > 0)
19716                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
19717         else
19718                 _res_constr.data = NULL;
19719         for (size_t i = 0; i < _res_constr.datalen; i++) {
19720                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19721                 LDKTransaction _res_conv_8_ref;
19722                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
19723                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
19724                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
19725                 _res_conv_8_ref.data_is_owned = true;
19726                 _res_constr.data[i] = _res_conv_8_ref;
19727         }
19728         CVec_TransactionZ_free(_res_constr);
19729 }
19730
19731 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
19732         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
19733         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
19734         return ((int64_t)ret_conv);
19735 }
19736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19737         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
19738         int64_t ret_val = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
19739         return ret_val;
19740 }
19741
19742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19743         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
19744         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
19745         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
19746         return ((int64_t)ret_conv);
19747 }
19748
19749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
19750         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
19751         CHECK_ACCESS(b_ptr);
19752         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
19753         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
19754         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
19755         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
19756         return ((int64_t)ret_conv);
19757 }
19758
19759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19760         if ((_res & 1) != 0) return;
19761         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19762         CHECK_ACCESS(_res_ptr);
19763         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
19764         FREE((void*)_res);
19765         C2Tuple_u32TxOutZ_free(_res_conv);
19766 }
19767
19768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19769         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
19770         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19771         if (_res_constr.datalen > 0)
19772                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
19773         else
19774                 _res_constr.data = NULL;
19775         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19776         for (size_t u = 0; u < _res_constr.datalen; u++) {
19777                 int64_t _res_conv_20 = _res_vals[u];
19778                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
19779                 CHECK_ACCESS(_res_conv_20_ptr);
19780                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
19781                 FREE((void*)_res_conv_20);
19782                 _res_constr.data[u] = _res_conv_20_conv;
19783         }
19784         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19785         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
19786 }
19787
19788 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
19789         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19790         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
19791         return ((int64_t)ret_conv);
19792 }
19793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19794         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
19795         int64_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
19796         return ret_val;
19797 }
19798
19799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19800         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
19801         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19802         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
19803         return ((int64_t)ret_conv);
19804 }
19805
19806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
19807         LDKThirtyTwoBytes a_ref;
19808         CHECK((*env)->GetArrayLength(env, a) == 32);
19809         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19810         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
19811         b_constr.datalen = (*env)->GetArrayLength(env, b);
19812         if (b_constr.datalen > 0)
19813                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
19814         else
19815                 b_constr.data = NULL;
19816         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
19817         for (size_t u = 0; u < b_constr.datalen; u++) {
19818                 int64_t b_conv_20 = b_vals[u];
19819                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
19820                 CHECK_ACCESS(b_conv_20_ptr);
19821                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
19822                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
19823                 b_constr.data[u] = b_conv_20_conv;
19824         }
19825         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
19826         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19827         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
19828         return ((int64_t)ret_conv);
19829 }
19830
19831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19832         if ((_res & 1) != 0) return;
19833         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19834         CHECK_ACCESS(_res_ptr);
19835         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
19836         FREE((void*)_res);
19837         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
19838 }
19839
19840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19841         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
19842         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19843         if (_res_constr.datalen > 0)
19844                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
19845         else
19846                 _res_constr.data = NULL;
19847         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19848         for (size_t n = 0; n < _res_constr.datalen; n++) {
19849                 int64_t _res_conv_39 = _res_vals[n];
19850                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
19851                 CHECK_ACCESS(_res_conv_39_ptr);
19852                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
19853                 FREE((void*)_res_conv_39);
19854                 _res_constr.data[n] = _res_conv_39_conv;
19855         }
19856         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19857         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
19858 }
19859
19860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19861         LDKCVec_BalanceZ _res_constr;
19862         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19863         if (_res_constr.datalen > 0)
19864                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
19865         else
19866                 _res_constr.data = NULL;
19867         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19868         for (size_t j = 0; j < _res_constr.datalen; j++) {
19869                 int64_t _res_conv_9 = _res_vals[j];
19870                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
19871                 CHECK_ACCESS(_res_conv_9_ptr);
19872                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
19873                 FREE((void*)_res_conv_9);
19874                 _res_constr.data[j] = _res_conv_9_conv;
19875         }
19876         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19877         CVec_BalanceZ_free(_res_constr);
19878 }
19879
19880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19881         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19882         CHECK_ACCESS(o_ptr);
19883         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
19884         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
19885         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19886         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
19887         return (int64_t)ret_conv;
19888 }
19889
19890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19891         LDKDecodeError e_conv;
19892         e_conv.inner = (void*)(e & (~1));
19893         e_conv.is_owned = (e & 1) || (e == 0);
19894         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19895         e_conv = DecodeError_clone(&e_conv);
19896         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19897         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
19898         return (int64_t)ret_conv;
19899 }
19900
19901 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19902         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
19903         jboolean ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
19904         return ret_val;
19905 }
19906
19907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19908         if ((_res & 1) != 0) return;
19909         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19910         CHECK_ACCESS(_res_ptr);
19911         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
19912         FREE((void*)_res);
19913         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
19914 }
19915
19916 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
19917         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19918         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
19919         return (int64_t)ret_conv;
19920 }
19921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19922         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
19923         int64_t ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
19924         return ret_val;
19925 }
19926
19927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19928         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
19929         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19930         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
19931         return (int64_t)ret_conv;
19932 }
19933
19934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
19935         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19936         *ret_conv = CResult_NoneLightningErrorZ_ok();
19937         return (int64_t)ret_conv;
19938 }
19939
19940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19941         LDKLightningError e_conv;
19942         e_conv.inner = (void*)(e & (~1));
19943         e_conv.is_owned = (e & 1) || (e == 0);
19944         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19945         e_conv = LightningError_clone(&e_conv);
19946         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19947         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
19948         return (int64_t)ret_conv;
19949 }
19950
19951 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19952         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
19953         jboolean ret_val = CResult_NoneLightningErrorZ_is_ok(o_conv);
19954         return ret_val;
19955 }
19956
19957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19958         if ((_res & 1) != 0) return;
19959         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19960         CHECK_ACCESS(_res_ptr);
19961         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
19962         FREE((void*)_res);
19963         CResult_NoneLightningErrorZ_free(_res_conv);
19964 }
19965
19966 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
19967         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19968         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
19969         return (int64_t)ret_conv;
19970 }
19971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19972         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
19973         int64_t ret_val = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
19974         return ret_val;
19975 }
19976
19977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19978         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
19979         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19980         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
19981         return (int64_t)ret_conv;
19982 }
19983
19984 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
19985         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
19986         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
19987         return ((int64_t)ret_conv);
19988 }
19989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19990         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
19991         int64_t ret_val = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
19992         return ret_val;
19993 }
19994
19995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19996         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
19997         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
19998         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
19999         return ((int64_t)ret_conv);
20000 }
20001
20002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
20003         LDKPublicKey a_ref;
20004         CHECK((*env)->GetArrayLength(env, a) == 33);
20005         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
20006         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
20007         CHECK_ACCESS(b_ptr);
20008         LDKType b_conv = *(LDKType*)(b_ptr);
20009         if (b_conv.free == LDKType_JCalls_free) {
20010                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20011                 LDKType_JCalls_cloned(&b_conv);
20012         }
20013         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
20014         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
20015         return ((int64_t)ret_conv);
20016 }
20017
20018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20019         if ((_res & 1) != 0) return;
20020         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20021         CHECK_ACCESS(_res_ptr);
20022         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
20023         FREE((void*)_res);
20024         C2Tuple_PublicKeyTypeZ_free(_res_conv);
20025 }
20026
20027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20028         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
20029         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20030         if (_res_constr.datalen > 0)
20031                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
20032         else
20033                 _res_constr.data = NULL;
20034         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20035         for (size_t z = 0; z < _res_constr.datalen; z++) {
20036                 int64_t _res_conv_25 = _res_vals[z];
20037                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
20038                 CHECK_ACCESS(_res_conv_25_ptr);
20039                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
20040                 FREE((void*)_res_conv_25);
20041                 _res_constr.data[z] = _res_conv_25_conv;
20042         }
20043         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20044         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
20045 }
20046
20047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
20048         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
20049         *ret_conv = CResult_boolLightningErrorZ_ok(o);
20050         return (int64_t)ret_conv;
20051 }
20052
20053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20054         LDKLightningError e_conv;
20055         e_conv.inner = (void*)(e & (~1));
20056         e_conv.is_owned = (e & 1) || (e == 0);
20057         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20058         e_conv = LightningError_clone(&e_conv);
20059         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
20060         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
20061         return (int64_t)ret_conv;
20062 }
20063
20064 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20065         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
20066         jboolean ret_val = CResult_boolLightningErrorZ_is_ok(o_conv);
20067         return ret_val;
20068 }
20069
20070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20071         if ((_res & 1) != 0) return;
20072         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20073         CHECK_ACCESS(_res_ptr);
20074         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
20075         FREE((void*)_res);
20076         CResult_boolLightningErrorZ_free(_res_conv);
20077 }
20078
20079 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
20080         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
20081         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
20082         return (int64_t)ret_conv;
20083 }
20084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20085         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
20086         int64_t ret_val = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
20087         return ret_val;
20088 }
20089
20090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20091         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
20092         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
20093         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
20094         return (int64_t)ret_conv;
20095 }
20096
20097 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
20098         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
20099         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
20100         return ((int64_t)ret_conv);
20101 }
20102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20103         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
20104         int64_t ret_val = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
20105         return ret_val;
20106 }
20107
20108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20109         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
20110         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
20111         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
20112         return ((int64_t)ret_conv);
20113 }
20114
20115 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) {
20116         LDKChannelAnnouncement a_conv;
20117         a_conv.inner = (void*)(a & (~1));
20118         a_conv.is_owned = (a & 1) || (a == 0);
20119         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20120         a_conv = ChannelAnnouncement_clone(&a_conv);
20121         LDKChannelUpdate b_conv;
20122         b_conv.inner = (void*)(b & (~1));
20123         b_conv.is_owned = (b & 1) || (b == 0);
20124         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
20125         b_conv = ChannelUpdate_clone(&b_conv);
20126         LDKChannelUpdate c_conv;
20127         c_conv.inner = (void*)(c & (~1));
20128         c_conv.is_owned = (c & 1) || (c == 0);
20129         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
20130         c_conv = ChannelUpdate_clone(&c_conv);
20131         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
20132         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
20133         return ((int64_t)ret_conv);
20134 }
20135
20136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20137         if ((_res & 1) != 0) return;
20138         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20139         CHECK_ACCESS(_res_ptr);
20140         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
20141         FREE((void*)_res);
20142         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
20143 }
20144
20145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20146         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
20147         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20148         if (_res_constr.datalen > 0)
20149                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
20150         else
20151                 _res_constr.data = NULL;
20152         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20153         for (size_t h = 0; h < _res_constr.datalen; h++) {
20154                 int64_t _res_conv_59 = _res_vals[h];
20155                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
20156                 CHECK_ACCESS(_res_conv_59_ptr);
20157                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
20158                 FREE((void*)_res_conv_59);
20159                 _res_constr.data[h] = _res_conv_59_conv;
20160         }
20161         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20162         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
20163 }
20164
20165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20166         LDKCVec_NodeAnnouncementZ _res_constr;
20167         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20168         if (_res_constr.datalen > 0)
20169                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
20170         else
20171                 _res_constr.data = NULL;
20172         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20173         for (size_t s = 0; s < _res_constr.datalen; s++) {
20174                 int64_t _res_conv_18 = _res_vals[s];
20175                 LDKNodeAnnouncement _res_conv_18_conv;
20176                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
20177                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
20178                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
20179                 _res_constr.data[s] = _res_conv_18_conv;
20180         }
20181         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20182         CVec_NodeAnnouncementZ_free(_res_constr);
20183 }
20184
20185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20186         LDKCVec_PublicKeyZ _res_constr;
20187         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20188         if (_res_constr.datalen > 0)
20189                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
20190         else
20191                 _res_constr.data = NULL;
20192         for (size_t i = 0; i < _res_constr.datalen; i++) {
20193                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
20194                 LDKPublicKey _res_conv_8_ref;
20195                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
20196                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
20197                 _res_constr.data[i] = _res_conv_8_ref;
20198         }
20199         CVec_PublicKeyZ_free(_res_constr);
20200 }
20201
20202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20203         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20204         CHECK_ACCESS(o_ptr);
20205         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
20206         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
20207         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
20208         *ret_copy = COption_NetAddressZ_some(o_conv);
20209         int64_t ret_ref = (uintptr_t)ret_copy;
20210         return ret_ref;
20211 }
20212
20213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
20214         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
20215         *ret_copy = COption_NetAddressZ_none();
20216         int64_t ret_ref = (uintptr_t)ret_copy;
20217         return ret_ref;
20218 }
20219
20220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20221         if ((_res & 1) != 0) return;
20222         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20223         CHECK_ACCESS(_res_ptr);
20224         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
20225         FREE((void*)_res);
20226         COption_NetAddressZ_free(_res_conv);
20227 }
20228
20229 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
20230         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
20231         *ret_copy = COption_NetAddressZ_clone(arg);
20232 int64_t ret_ref = (uintptr_t)ret_copy;
20233         return ret_ref;
20234 }
20235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20236         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
20237         int64_t ret_val = COption_NetAddressZ_clone_ptr(arg_conv);
20238         return ret_val;
20239 }
20240
20241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20242         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
20243         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
20244         *ret_copy = COption_NetAddressZ_clone(orig_conv);
20245         int64_t ret_ref = (uintptr_t)ret_copy;
20246         return ret_ref;
20247 }
20248
20249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20250         LDKCVec_u8Z o_ref;
20251         o_ref.datalen = (*env)->GetArrayLength(env, o);
20252         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
20253         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
20254         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20255         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
20256         return (int64_t)ret_conv;
20257 }
20258
20259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20260         LDKPeerHandleError e_conv;
20261         e_conv.inner = (void*)(e & (~1));
20262         e_conv.is_owned = (e & 1) || (e == 0);
20263         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20264         e_conv = PeerHandleError_clone(&e_conv);
20265         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20266         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
20267         return (int64_t)ret_conv;
20268 }
20269
20270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20271         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
20272         jboolean ret_val = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
20273         return ret_val;
20274 }
20275
20276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20277         if ((_res & 1) != 0) return;
20278         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20279         CHECK_ACCESS(_res_ptr);
20280         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
20281         FREE((void*)_res);
20282         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
20283 }
20284
20285 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
20286         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20287         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
20288         return (int64_t)ret_conv;
20289 }
20290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20291         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
20292         int64_t ret_val = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
20293         return ret_val;
20294 }
20295
20296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20297         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
20298         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20299         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
20300         return (int64_t)ret_conv;
20301 }
20302
20303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
20304         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20305         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
20306         return (int64_t)ret_conv;
20307 }
20308
20309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20310         LDKPeerHandleError e_conv;
20311         e_conv.inner = (void*)(e & (~1));
20312         e_conv.is_owned = (e & 1) || (e == 0);
20313         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20314         e_conv = PeerHandleError_clone(&e_conv);
20315         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20316         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
20317         return (int64_t)ret_conv;
20318 }
20319
20320 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20321         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
20322         jboolean ret_val = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
20323         return ret_val;
20324 }
20325
20326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20327         if ((_res & 1) != 0) return;
20328         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20329         CHECK_ACCESS(_res_ptr);
20330         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
20331         FREE((void*)_res);
20332         CResult_NonePeerHandleErrorZ_free(_res_conv);
20333 }
20334
20335 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
20336         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20337         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
20338         return (int64_t)ret_conv;
20339 }
20340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20341         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
20342         int64_t ret_val = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
20343         return ret_val;
20344 }
20345
20346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20347         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
20348         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20349         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
20350         return (int64_t)ret_conv;
20351 }
20352
20353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
20354         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20355         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
20356         return (int64_t)ret_conv;
20357 }
20358
20359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20360         LDKPeerHandleError e_conv;
20361         e_conv.inner = (void*)(e & (~1));
20362         e_conv.is_owned = (e & 1) || (e == 0);
20363         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20364         e_conv = PeerHandleError_clone(&e_conv);
20365         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20366         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
20367         return (int64_t)ret_conv;
20368 }
20369
20370 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20371         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
20372         jboolean ret_val = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
20373         return ret_val;
20374 }
20375
20376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20377         if ((_res & 1) != 0) return;
20378         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20379         CHECK_ACCESS(_res_ptr);
20380         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
20381         FREE((void*)_res);
20382         CResult_boolPeerHandleErrorZ_free(_res_conv);
20383 }
20384
20385 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
20386         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20387         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
20388         return (int64_t)ret_conv;
20389 }
20390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20391         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
20392         int64_t ret_val = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
20393         return ret_val;
20394 }
20395
20396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20397         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
20398         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20399         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
20400         return (int64_t)ret_conv;
20401 }
20402
20403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20404         LDKNodeId o_conv;
20405         o_conv.inner = (void*)(o & (~1));
20406         o_conv.is_owned = (o & 1) || (o == 0);
20407         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20408         o_conv = NodeId_clone(&o_conv);
20409         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
20410         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
20411         return (int64_t)ret_conv;
20412 }
20413
20414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20415         LDKDecodeError e_conv;
20416         e_conv.inner = (void*)(e & (~1));
20417         e_conv.is_owned = (e & 1) || (e == 0);
20418         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20419         e_conv = DecodeError_clone(&e_conv);
20420         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
20421         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
20422         return (int64_t)ret_conv;
20423 }
20424
20425 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20426         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
20427         jboolean ret_val = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
20428         return ret_val;
20429 }
20430
20431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20432         if ((_res & 1) != 0) return;
20433         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20434         CHECK_ACCESS(_res_ptr);
20435         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
20436         FREE((void*)_res);
20437         CResult_NodeIdDecodeErrorZ_free(_res_conv);
20438 }
20439
20440 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
20441         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
20442         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
20443         return (int64_t)ret_conv;
20444 }
20445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20446         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
20447         int64_t ret_val = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
20448         return ret_val;
20449 }
20450
20451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20452         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
20453         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
20454         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
20455         return (int64_t)ret_conv;
20456 }
20457
20458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20459         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20460         CHECK_ACCESS(o_ptr);
20461         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
20462         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
20463         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20464         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
20465         return (int64_t)ret_conv;
20466 }
20467
20468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20469         LDKDecodeError e_conv;
20470         e_conv.inner = (void*)(e & (~1));
20471         e_conv.is_owned = (e & 1) || (e == 0);
20472         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20473         e_conv = DecodeError_clone(&e_conv);
20474         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20475         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
20476         return (int64_t)ret_conv;
20477 }
20478
20479 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20480         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
20481         jboolean ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
20482         return ret_val;
20483 }
20484
20485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20486         if ((_res & 1) != 0) return;
20487         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20488         CHECK_ACCESS(_res_ptr);
20489         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
20490         FREE((void*)_res);
20491         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
20492 }
20493
20494 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
20495         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20496         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
20497         return (int64_t)ret_conv;
20498 }
20499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20500         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
20501         int64_t ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
20502         return ret_val;
20503 }
20504
20505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20506         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
20507         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20508         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
20509         return (int64_t)ret_conv;
20510 }
20511
20512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20513         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20514         CHECK_ACCESS(o_ptr);
20515         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
20516         if (o_conv.free == LDKAccess_JCalls_free) {
20517                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20518                 LDKAccess_JCalls_cloned(&o_conv);
20519         }
20520         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
20521         *ret_copy = COption_AccessZ_some(o_conv);
20522         int64_t ret_ref = (uintptr_t)ret_copy;
20523         return ret_ref;
20524 }
20525
20526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
20527         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
20528         *ret_copy = COption_AccessZ_none();
20529         int64_t ret_ref = (uintptr_t)ret_copy;
20530         return ret_ref;
20531 }
20532
20533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20534         if ((_res & 1) != 0) return;
20535         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20536         CHECK_ACCESS(_res_ptr);
20537         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
20538         FREE((void*)_res);
20539         COption_AccessZ_free(_res_conv);
20540 }
20541
20542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20543         LDKChannelUpdateInfo o_conv;
20544         o_conv.inner = (void*)(o & (~1));
20545         o_conv.is_owned = (o & 1) || (o == 0);
20546         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20547         o_conv = ChannelUpdateInfo_clone(&o_conv);
20548         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20549         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
20550         return (int64_t)ret_conv;
20551 }
20552
20553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20554         LDKDecodeError e_conv;
20555         e_conv.inner = (void*)(e & (~1));
20556         e_conv.is_owned = (e & 1) || (e == 0);
20557         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20558         e_conv = DecodeError_clone(&e_conv);
20559         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20560         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
20561         return (int64_t)ret_conv;
20562 }
20563
20564 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20565         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
20566         jboolean ret_val = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
20567         return ret_val;
20568 }
20569
20570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20571         if ((_res & 1) != 0) return;
20572         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20573         CHECK_ACCESS(_res_ptr);
20574         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
20575         FREE((void*)_res);
20576         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
20577 }
20578
20579 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
20580         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20581         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
20582         return (int64_t)ret_conv;
20583 }
20584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20585         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
20586         int64_t ret_val = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
20587         return ret_val;
20588 }
20589
20590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20591         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
20592         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20593         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
20594         return (int64_t)ret_conv;
20595 }
20596
20597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20598         LDKChannelInfo o_conv;
20599         o_conv.inner = (void*)(o & (~1));
20600         o_conv.is_owned = (o & 1) || (o == 0);
20601         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20602         o_conv = ChannelInfo_clone(&o_conv);
20603         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20604         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
20605         return (int64_t)ret_conv;
20606 }
20607
20608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20609         LDKDecodeError e_conv;
20610         e_conv.inner = (void*)(e & (~1));
20611         e_conv.is_owned = (e & 1) || (e == 0);
20612         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20613         e_conv = DecodeError_clone(&e_conv);
20614         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20615         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
20616         return (int64_t)ret_conv;
20617 }
20618
20619 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20620         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
20621         jboolean ret_val = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
20622         return ret_val;
20623 }
20624
20625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20626         if ((_res & 1) != 0) return;
20627         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20628         CHECK_ACCESS(_res_ptr);
20629         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
20630         FREE((void*)_res);
20631         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
20632 }
20633
20634 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
20635         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20636         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
20637         return (int64_t)ret_conv;
20638 }
20639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20640         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
20641         int64_t ret_val = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
20642         return ret_val;
20643 }
20644
20645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20646         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
20647         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20648         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
20649         return (int64_t)ret_conv;
20650 }
20651
20652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20653         LDKRoutingFees o_conv;
20654         o_conv.inner = (void*)(o & (~1));
20655         o_conv.is_owned = (o & 1) || (o == 0);
20656         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20657         o_conv = RoutingFees_clone(&o_conv);
20658         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20659         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
20660         return (int64_t)ret_conv;
20661 }
20662
20663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20664         LDKDecodeError e_conv;
20665         e_conv.inner = (void*)(e & (~1));
20666         e_conv.is_owned = (e & 1) || (e == 0);
20667         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20668         e_conv = DecodeError_clone(&e_conv);
20669         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20670         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
20671         return (int64_t)ret_conv;
20672 }
20673
20674 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20675         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
20676         jboolean ret_val = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
20677         return ret_val;
20678 }
20679
20680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20681         if ((_res & 1) != 0) return;
20682         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20683         CHECK_ACCESS(_res_ptr);
20684         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
20685         FREE((void*)_res);
20686         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
20687 }
20688
20689 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
20690         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20691         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
20692         return (int64_t)ret_conv;
20693 }
20694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20695         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
20696         int64_t ret_val = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
20697         return ret_val;
20698 }
20699
20700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20701         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
20702         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20703         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
20704         return (int64_t)ret_conv;
20705 }
20706
20707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20708         LDKNodeAnnouncementInfo o_conv;
20709         o_conv.inner = (void*)(o & (~1));
20710         o_conv.is_owned = (o & 1) || (o == 0);
20711         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20712         o_conv = NodeAnnouncementInfo_clone(&o_conv);
20713         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20714         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
20715         return (int64_t)ret_conv;
20716 }
20717
20718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20719         LDKDecodeError e_conv;
20720         e_conv.inner = (void*)(e & (~1));
20721         e_conv.is_owned = (e & 1) || (e == 0);
20722         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20723         e_conv = DecodeError_clone(&e_conv);
20724         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20725         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
20726         return (int64_t)ret_conv;
20727 }
20728
20729 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20730         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
20731         jboolean ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
20732         return ret_val;
20733 }
20734
20735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20736         if ((_res & 1) != 0) return;
20737         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20738         CHECK_ACCESS(_res_ptr);
20739         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
20740         FREE((void*)_res);
20741         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
20742 }
20743
20744 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
20745         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20746         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
20747         return (int64_t)ret_conv;
20748 }
20749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20750         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
20751         int64_t ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
20752         return ret_val;
20753 }
20754
20755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20756         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
20757         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20758         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
20759         return (int64_t)ret_conv;
20760 }
20761
20762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20763         LDKCVec_u64Z _res_constr;
20764         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20765         if (_res_constr.datalen > 0)
20766                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20767         else
20768                 _res_constr.data = NULL;
20769         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20770         for (size_t g = 0; g < _res_constr.datalen; g++) {
20771                 int64_t _res_conv_6 = _res_vals[g];
20772                 _res_constr.data[g] = _res_conv_6;
20773         }
20774         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20775         CVec_u64Z_free(_res_constr);
20776 }
20777
20778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20779         LDKNodeInfo o_conv;
20780         o_conv.inner = (void*)(o & (~1));
20781         o_conv.is_owned = (o & 1) || (o == 0);
20782         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20783         o_conv = NodeInfo_clone(&o_conv);
20784         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20785         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
20786         return (int64_t)ret_conv;
20787 }
20788
20789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20790         LDKDecodeError e_conv;
20791         e_conv.inner = (void*)(e & (~1));
20792         e_conv.is_owned = (e & 1) || (e == 0);
20793         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20794         e_conv = DecodeError_clone(&e_conv);
20795         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20796         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
20797         return (int64_t)ret_conv;
20798 }
20799
20800 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20801         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
20802         jboolean ret_val = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
20803         return ret_val;
20804 }
20805
20806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20807         if ((_res & 1) != 0) return;
20808         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20809         CHECK_ACCESS(_res_ptr);
20810         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
20811         FREE((void*)_res);
20812         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
20813 }
20814
20815 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
20816         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20817         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
20818         return (int64_t)ret_conv;
20819 }
20820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20821         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
20822         int64_t ret_val = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
20823         return ret_val;
20824 }
20825
20826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20827         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
20828         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20829         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
20830         return (int64_t)ret_conv;
20831 }
20832
20833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20834         LDKNetworkGraph o_conv;
20835         o_conv.inner = (void*)(o & (~1));
20836         o_conv.is_owned = (o & 1) || (o == 0);
20837         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20838         o_conv = NetworkGraph_clone(&o_conv);
20839         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20840         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
20841         return (int64_t)ret_conv;
20842 }
20843
20844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20845         LDKDecodeError e_conv;
20846         e_conv.inner = (void*)(e & (~1));
20847         e_conv.is_owned = (e & 1) || (e == 0);
20848         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20849         e_conv = DecodeError_clone(&e_conv);
20850         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20851         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
20852         return (int64_t)ret_conv;
20853 }
20854
20855 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20856         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
20857         jboolean ret_val = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
20858         return ret_val;
20859 }
20860
20861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20862         if ((_res & 1) != 0) return;
20863         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20864         CHECK_ACCESS(_res_ptr);
20865         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
20866         FREE((void*)_res);
20867         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
20868 }
20869
20870 static inline uintptr_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
20871         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20872         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
20873         return (int64_t)ret_conv;
20874 }
20875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20876         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
20877         int64_t ret_val = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
20878         return ret_val;
20879 }
20880
20881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20882         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
20883         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20884         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
20885         return (int64_t)ret_conv;
20886 }
20887
20888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
20889         LDKCVec_NetAddressZ o_constr;
20890         o_constr.datalen = (*env)->GetArrayLength(env, o);
20891         if (o_constr.datalen > 0)
20892                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
20893         else
20894                 o_constr.data = NULL;
20895         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
20896         for (size_t m = 0; m < o_constr.datalen; m++) {
20897                 int64_t o_conv_12 = o_vals[m];
20898                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
20899                 CHECK_ACCESS(o_conv_12_ptr);
20900                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
20901                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
20902                 o_constr.data[m] = o_conv_12_conv;
20903         }
20904         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
20905         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20906         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
20907         int64_t ret_ref = (uintptr_t)ret_copy;
20908         return ret_ref;
20909 }
20910
20911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
20912         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20913         *ret_copy = COption_CVec_NetAddressZZ_none();
20914         int64_t ret_ref = (uintptr_t)ret_copy;
20915         return ret_ref;
20916 }
20917
20918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20919         if ((_res & 1) != 0) return;
20920         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20921         CHECK_ACCESS(_res_ptr);
20922         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
20923         FREE((void*)_res);
20924         COption_CVec_NetAddressZZ_free(_res_conv);
20925 }
20926
20927 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
20928         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20929         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
20930 int64_t ret_ref = (uintptr_t)ret_copy;
20931         return ret_ref;
20932 }
20933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20934         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
20935         int64_t ret_val = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
20936         return ret_val;
20937 }
20938
20939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20940         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
20941         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20942         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
20943         int64_t ret_ref = (uintptr_t)ret_copy;
20944         return ret_ref;
20945 }
20946
20947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20948         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20949         CHECK_ACCESS(o_ptr);
20950         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
20951         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
20952         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20953         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
20954         return (int64_t)ret_conv;
20955 }
20956
20957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20958         LDKDecodeError e_conv;
20959         e_conv.inner = (void*)(e & (~1));
20960         e_conv.is_owned = (e & 1) || (e == 0);
20961         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20962         e_conv = DecodeError_clone(&e_conv);
20963         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20964         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
20965         return (int64_t)ret_conv;
20966 }
20967
20968 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20969         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
20970         jboolean ret_val = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
20971         return ret_val;
20972 }
20973
20974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20975         if ((_res & 1) != 0) return;
20976         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20977         CHECK_ACCESS(_res_ptr);
20978         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
20979         FREE((void*)_res);
20980         CResult_NetAddressDecodeErrorZ_free(_res_conv);
20981 }
20982
20983 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
20984         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20985         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
20986         return (int64_t)ret_conv;
20987 }
20988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20989         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
20990         int64_t ret_val = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
20991         return ret_val;
20992 }
20993
20994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20995         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
20996         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20997         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
20998         return (int64_t)ret_conv;
20999 }
21000
21001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21002         LDKCVec_UpdateAddHTLCZ _res_constr;
21003         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21004         if (_res_constr.datalen > 0)
21005                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
21006         else
21007                 _res_constr.data = NULL;
21008         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21009         for (size_t p = 0; p < _res_constr.datalen; p++) {
21010                 int64_t _res_conv_15 = _res_vals[p];
21011                 LDKUpdateAddHTLC _res_conv_15_conv;
21012                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
21013                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
21014                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
21015                 _res_constr.data[p] = _res_conv_15_conv;
21016         }
21017         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21018         CVec_UpdateAddHTLCZ_free(_res_constr);
21019 }
21020
21021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21022         LDKCVec_UpdateFulfillHTLCZ _res_constr;
21023         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21024         if (_res_constr.datalen > 0)
21025                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
21026         else
21027                 _res_constr.data = NULL;
21028         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21029         for (size_t t = 0; t < _res_constr.datalen; t++) {
21030                 int64_t _res_conv_19 = _res_vals[t];
21031                 LDKUpdateFulfillHTLC _res_conv_19_conv;
21032                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
21033                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
21034                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
21035                 _res_constr.data[t] = _res_conv_19_conv;
21036         }
21037         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21038         CVec_UpdateFulfillHTLCZ_free(_res_constr);
21039 }
21040
21041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21042         LDKCVec_UpdateFailHTLCZ _res_constr;
21043         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21044         if (_res_constr.datalen > 0)
21045                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
21046         else
21047                 _res_constr.data = NULL;
21048         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21049         for (size_t q = 0; q < _res_constr.datalen; q++) {
21050                 int64_t _res_conv_16 = _res_vals[q];
21051                 LDKUpdateFailHTLC _res_conv_16_conv;
21052                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
21053                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
21054                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
21055                 _res_constr.data[q] = _res_conv_16_conv;
21056         }
21057         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21058         CVec_UpdateFailHTLCZ_free(_res_constr);
21059 }
21060
21061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21062         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
21063         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21064         if (_res_constr.datalen > 0)
21065                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
21066         else
21067                 _res_constr.data = NULL;
21068         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21069         for (size_t z = 0; z < _res_constr.datalen; z++) {
21070                 int64_t _res_conv_25 = _res_vals[z];
21071                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
21072                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
21073                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
21074                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
21075                 _res_constr.data[z] = _res_conv_25_conv;
21076         }
21077         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21078         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
21079 }
21080
21081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21082         LDKAcceptChannel o_conv;
21083         o_conv.inner = (void*)(o & (~1));
21084         o_conv.is_owned = (o & 1) || (o == 0);
21085         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21086         o_conv = AcceptChannel_clone(&o_conv);
21087         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21088         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
21089         return (int64_t)ret_conv;
21090 }
21091
21092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21093         LDKDecodeError e_conv;
21094         e_conv.inner = (void*)(e & (~1));
21095         e_conv.is_owned = (e & 1) || (e == 0);
21096         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21097         e_conv = DecodeError_clone(&e_conv);
21098         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21099         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
21100         return (int64_t)ret_conv;
21101 }
21102
21103 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21104         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
21105         jboolean ret_val = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
21106         return ret_val;
21107 }
21108
21109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21110         if ((_res & 1) != 0) return;
21111         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21112         CHECK_ACCESS(_res_ptr);
21113         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
21114         FREE((void*)_res);
21115         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
21116 }
21117
21118 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
21119         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21120         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
21121         return (int64_t)ret_conv;
21122 }
21123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21124         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
21125         int64_t ret_val = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
21126         return ret_val;
21127 }
21128
21129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21130         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
21131         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21132         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
21133         return (int64_t)ret_conv;
21134 }
21135
21136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21137         LDKAnnouncementSignatures o_conv;
21138         o_conv.inner = (void*)(o & (~1));
21139         o_conv.is_owned = (o & 1) || (o == 0);
21140         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21141         o_conv = AnnouncementSignatures_clone(&o_conv);
21142         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21143         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
21144         return (int64_t)ret_conv;
21145 }
21146
21147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21148         LDKDecodeError e_conv;
21149         e_conv.inner = (void*)(e & (~1));
21150         e_conv.is_owned = (e & 1) || (e == 0);
21151         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21152         e_conv = DecodeError_clone(&e_conv);
21153         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21154         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
21155         return (int64_t)ret_conv;
21156 }
21157
21158 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21159         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
21160         jboolean ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
21161         return ret_val;
21162 }
21163
21164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21165         if ((_res & 1) != 0) return;
21166         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21167         CHECK_ACCESS(_res_ptr);
21168         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
21169         FREE((void*)_res);
21170         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
21171 }
21172
21173 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
21174         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21175         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
21176         return (int64_t)ret_conv;
21177 }
21178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21179         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
21180         int64_t ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
21181         return ret_val;
21182 }
21183
21184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21185         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
21186         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21187         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
21188         return (int64_t)ret_conv;
21189 }
21190
21191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21192         LDKChannelReestablish o_conv;
21193         o_conv.inner = (void*)(o & (~1));
21194         o_conv.is_owned = (o & 1) || (o == 0);
21195         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21196         o_conv = ChannelReestablish_clone(&o_conv);
21197         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21198         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
21199         return (int64_t)ret_conv;
21200 }
21201
21202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21203         LDKDecodeError e_conv;
21204         e_conv.inner = (void*)(e & (~1));
21205         e_conv.is_owned = (e & 1) || (e == 0);
21206         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21207         e_conv = DecodeError_clone(&e_conv);
21208         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21209         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
21210         return (int64_t)ret_conv;
21211 }
21212
21213 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21214         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
21215         jboolean ret_val = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
21216         return ret_val;
21217 }
21218
21219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21220         if ((_res & 1) != 0) return;
21221         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21222         CHECK_ACCESS(_res_ptr);
21223         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
21224         FREE((void*)_res);
21225         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
21226 }
21227
21228 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
21229         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21230         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
21231         return (int64_t)ret_conv;
21232 }
21233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21234         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
21235         int64_t ret_val = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
21236         return ret_val;
21237 }
21238
21239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21240         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
21241         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21242         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
21243         return (int64_t)ret_conv;
21244 }
21245
21246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21247         LDKClosingSigned o_conv;
21248         o_conv.inner = (void*)(o & (~1));
21249         o_conv.is_owned = (o & 1) || (o == 0);
21250         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21251         o_conv = ClosingSigned_clone(&o_conv);
21252         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21253         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
21254         return (int64_t)ret_conv;
21255 }
21256
21257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21258         LDKDecodeError e_conv;
21259         e_conv.inner = (void*)(e & (~1));
21260         e_conv.is_owned = (e & 1) || (e == 0);
21261         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21262         e_conv = DecodeError_clone(&e_conv);
21263         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21264         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
21265         return (int64_t)ret_conv;
21266 }
21267
21268 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21269         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
21270         jboolean ret_val = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
21271         return ret_val;
21272 }
21273
21274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21275         if ((_res & 1) != 0) return;
21276         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21277         CHECK_ACCESS(_res_ptr);
21278         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
21279         FREE((void*)_res);
21280         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
21281 }
21282
21283 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
21284         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21285         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
21286         return (int64_t)ret_conv;
21287 }
21288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21289         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
21290         int64_t ret_val = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
21291         return ret_val;
21292 }
21293
21294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21295         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
21296         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21297         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
21298         return (int64_t)ret_conv;
21299 }
21300
21301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21302         LDKClosingSignedFeeRange o_conv;
21303         o_conv.inner = (void*)(o & (~1));
21304         o_conv.is_owned = (o & 1) || (o == 0);
21305         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21306         o_conv = ClosingSignedFeeRange_clone(&o_conv);
21307         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21308         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
21309         return (int64_t)ret_conv;
21310 }
21311
21312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21313         LDKDecodeError e_conv;
21314         e_conv.inner = (void*)(e & (~1));
21315         e_conv.is_owned = (e & 1) || (e == 0);
21316         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21317         e_conv = DecodeError_clone(&e_conv);
21318         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21319         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
21320         return (int64_t)ret_conv;
21321 }
21322
21323 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21324         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
21325         jboolean ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
21326         return ret_val;
21327 }
21328
21329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21330         if ((_res & 1) != 0) return;
21331         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21332         CHECK_ACCESS(_res_ptr);
21333         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
21334         FREE((void*)_res);
21335         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
21336 }
21337
21338 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
21339         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21340         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
21341         return (int64_t)ret_conv;
21342 }
21343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21344         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
21345         int64_t ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
21346         return ret_val;
21347 }
21348
21349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21350         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
21351         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21352         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
21353         return (int64_t)ret_conv;
21354 }
21355
21356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21357         LDKCommitmentSigned o_conv;
21358         o_conv.inner = (void*)(o & (~1));
21359         o_conv.is_owned = (o & 1) || (o == 0);
21360         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21361         o_conv = CommitmentSigned_clone(&o_conv);
21362         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21363         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
21364         return (int64_t)ret_conv;
21365 }
21366
21367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21368         LDKDecodeError e_conv;
21369         e_conv.inner = (void*)(e & (~1));
21370         e_conv.is_owned = (e & 1) || (e == 0);
21371         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21372         e_conv = DecodeError_clone(&e_conv);
21373         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21374         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
21375         return (int64_t)ret_conv;
21376 }
21377
21378 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21379         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
21380         jboolean ret_val = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
21381         return ret_val;
21382 }
21383
21384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21385         if ((_res & 1) != 0) return;
21386         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21387         CHECK_ACCESS(_res_ptr);
21388         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
21389         FREE((void*)_res);
21390         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
21391 }
21392
21393 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
21394         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21395         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
21396         return (int64_t)ret_conv;
21397 }
21398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21399         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
21400         int64_t ret_val = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
21401         return ret_val;
21402 }
21403
21404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21405         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
21406         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21407         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
21408         return (int64_t)ret_conv;
21409 }
21410
21411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21412         LDKFundingCreated o_conv;
21413         o_conv.inner = (void*)(o & (~1));
21414         o_conv.is_owned = (o & 1) || (o == 0);
21415         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21416         o_conv = FundingCreated_clone(&o_conv);
21417         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21418         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
21419         return (int64_t)ret_conv;
21420 }
21421
21422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21423         LDKDecodeError e_conv;
21424         e_conv.inner = (void*)(e & (~1));
21425         e_conv.is_owned = (e & 1) || (e == 0);
21426         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21427         e_conv = DecodeError_clone(&e_conv);
21428         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21429         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
21430         return (int64_t)ret_conv;
21431 }
21432
21433 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21434         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
21435         jboolean ret_val = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
21436         return ret_val;
21437 }
21438
21439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21440         if ((_res & 1) != 0) return;
21441         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21442         CHECK_ACCESS(_res_ptr);
21443         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
21444         FREE((void*)_res);
21445         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
21446 }
21447
21448 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
21449         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21450         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
21451         return (int64_t)ret_conv;
21452 }
21453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21454         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
21455         int64_t ret_val = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
21456         return ret_val;
21457 }
21458
21459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21460         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
21461         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21462         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
21463         return (int64_t)ret_conv;
21464 }
21465
21466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21467         LDKFundingSigned o_conv;
21468         o_conv.inner = (void*)(o & (~1));
21469         o_conv.is_owned = (o & 1) || (o == 0);
21470         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21471         o_conv = FundingSigned_clone(&o_conv);
21472         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21473         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
21474         return (int64_t)ret_conv;
21475 }
21476
21477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21478         LDKDecodeError e_conv;
21479         e_conv.inner = (void*)(e & (~1));
21480         e_conv.is_owned = (e & 1) || (e == 0);
21481         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21482         e_conv = DecodeError_clone(&e_conv);
21483         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21484         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
21485         return (int64_t)ret_conv;
21486 }
21487
21488 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21489         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
21490         jboolean ret_val = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
21491         return ret_val;
21492 }
21493
21494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21495         if ((_res & 1) != 0) return;
21496         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21497         CHECK_ACCESS(_res_ptr);
21498         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
21499         FREE((void*)_res);
21500         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
21501 }
21502
21503 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
21504         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21505         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
21506         return (int64_t)ret_conv;
21507 }
21508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21509         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
21510         int64_t ret_val = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
21511         return ret_val;
21512 }
21513
21514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21515         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
21516         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21517         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
21518         return (int64_t)ret_conv;
21519 }
21520
21521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21522         LDKFundingLocked o_conv;
21523         o_conv.inner = (void*)(o & (~1));
21524         o_conv.is_owned = (o & 1) || (o == 0);
21525         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21526         o_conv = FundingLocked_clone(&o_conv);
21527         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21528         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
21529         return (int64_t)ret_conv;
21530 }
21531
21532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21533         LDKDecodeError e_conv;
21534         e_conv.inner = (void*)(e & (~1));
21535         e_conv.is_owned = (e & 1) || (e == 0);
21536         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21537         e_conv = DecodeError_clone(&e_conv);
21538         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21539         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
21540         return (int64_t)ret_conv;
21541 }
21542
21543 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21544         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
21545         jboolean ret_val = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
21546         return ret_val;
21547 }
21548
21549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21550         if ((_res & 1) != 0) return;
21551         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21552         CHECK_ACCESS(_res_ptr);
21553         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
21554         FREE((void*)_res);
21555         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
21556 }
21557
21558 static inline uintptr_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
21559         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21560         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
21561         return (int64_t)ret_conv;
21562 }
21563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21564         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
21565         int64_t ret_val = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
21566         return ret_val;
21567 }
21568
21569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21570         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
21571         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21572         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
21573         return (int64_t)ret_conv;
21574 }
21575
21576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21577         LDKInit o_conv;
21578         o_conv.inner = (void*)(o & (~1));
21579         o_conv.is_owned = (o & 1) || (o == 0);
21580         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21581         o_conv = Init_clone(&o_conv);
21582         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21583         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
21584         return (int64_t)ret_conv;
21585 }
21586
21587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21588         LDKDecodeError e_conv;
21589         e_conv.inner = (void*)(e & (~1));
21590         e_conv.is_owned = (e & 1) || (e == 0);
21591         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21592         e_conv = DecodeError_clone(&e_conv);
21593         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21594         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
21595         return (int64_t)ret_conv;
21596 }
21597
21598 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21599         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
21600         jboolean ret_val = CResult_InitDecodeErrorZ_is_ok(o_conv);
21601         return ret_val;
21602 }
21603
21604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21605         if ((_res & 1) != 0) return;
21606         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21607         CHECK_ACCESS(_res_ptr);
21608         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
21609         FREE((void*)_res);
21610         CResult_InitDecodeErrorZ_free(_res_conv);
21611 }
21612
21613 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
21614         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21615         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
21616         return (int64_t)ret_conv;
21617 }
21618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21619         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
21620         int64_t ret_val = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
21621         return ret_val;
21622 }
21623
21624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21625         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
21626         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21627         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
21628         return (int64_t)ret_conv;
21629 }
21630
21631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21632         LDKOpenChannel o_conv;
21633         o_conv.inner = (void*)(o & (~1));
21634         o_conv.is_owned = (o & 1) || (o == 0);
21635         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21636         o_conv = OpenChannel_clone(&o_conv);
21637         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21638         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
21639         return (int64_t)ret_conv;
21640 }
21641
21642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21643         LDKDecodeError e_conv;
21644         e_conv.inner = (void*)(e & (~1));
21645         e_conv.is_owned = (e & 1) || (e == 0);
21646         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21647         e_conv = DecodeError_clone(&e_conv);
21648         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21649         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
21650         return (int64_t)ret_conv;
21651 }
21652
21653 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21654         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
21655         jboolean ret_val = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
21656         return ret_val;
21657 }
21658
21659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21660         if ((_res & 1) != 0) return;
21661         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21662         CHECK_ACCESS(_res_ptr);
21663         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
21664         FREE((void*)_res);
21665         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
21666 }
21667
21668 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
21669         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21670         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
21671         return (int64_t)ret_conv;
21672 }
21673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21674         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
21675         int64_t ret_val = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
21676         return ret_val;
21677 }
21678
21679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21680         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
21681         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21682         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
21683         return (int64_t)ret_conv;
21684 }
21685
21686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21687         LDKRevokeAndACK o_conv;
21688         o_conv.inner = (void*)(o & (~1));
21689         o_conv.is_owned = (o & 1) || (o == 0);
21690         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21691         o_conv = RevokeAndACK_clone(&o_conv);
21692         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21693         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
21694         return (int64_t)ret_conv;
21695 }
21696
21697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21698         LDKDecodeError e_conv;
21699         e_conv.inner = (void*)(e & (~1));
21700         e_conv.is_owned = (e & 1) || (e == 0);
21701         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21702         e_conv = DecodeError_clone(&e_conv);
21703         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21704         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
21705         return (int64_t)ret_conv;
21706 }
21707
21708 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21709         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
21710         jboolean ret_val = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
21711         return ret_val;
21712 }
21713
21714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21715         if ((_res & 1) != 0) return;
21716         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21717         CHECK_ACCESS(_res_ptr);
21718         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
21719         FREE((void*)_res);
21720         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
21721 }
21722
21723 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
21724         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21725         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
21726         return (int64_t)ret_conv;
21727 }
21728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21729         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
21730         int64_t ret_val = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
21731         return ret_val;
21732 }
21733
21734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21735         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
21736         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21737         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
21738         return (int64_t)ret_conv;
21739 }
21740
21741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21742         LDKShutdown o_conv;
21743         o_conv.inner = (void*)(o & (~1));
21744         o_conv.is_owned = (o & 1) || (o == 0);
21745         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21746         o_conv = Shutdown_clone(&o_conv);
21747         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21748         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
21749         return (int64_t)ret_conv;
21750 }
21751
21752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21753         LDKDecodeError e_conv;
21754         e_conv.inner = (void*)(e & (~1));
21755         e_conv.is_owned = (e & 1) || (e == 0);
21756         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21757         e_conv = DecodeError_clone(&e_conv);
21758         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21759         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
21760         return (int64_t)ret_conv;
21761 }
21762
21763 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21764         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
21765         jboolean ret_val = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
21766         return ret_val;
21767 }
21768
21769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21770         if ((_res & 1) != 0) return;
21771         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21772         CHECK_ACCESS(_res_ptr);
21773         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
21774         FREE((void*)_res);
21775         CResult_ShutdownDecodeErrorZ_free(_res_conv);
21776 }
21777
21778 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
21779         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21780         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
21781         return (int64_t)ret_conv;
21782 }
21783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21784         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
21785         int64_t ret_val = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
21786         return ret_val;
21787 }
21788
21789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21790         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
21791         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21792         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
21793         return (int64_t)ret_conv;
21794 }
21795
21796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21797         LDKUpdateFailHTLC o_conv;
21798         o_conv.inner = (void*)(o & (~1));
21799         o_conv.is_owned = (o & 1) || (o == 0);
21800         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21801         o_conv = UpdateFailHTLC_clone(&o_conv);
21802         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21803         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
21804         return (int64_t)ret_conv;
21805 }
21806
21807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21808         LDKDecodeError e_conv;
21809         e_conv.inner = (void*)(e & (~1));
21810         e_conv.is_owned = (e & 1) || (e == 0);
21811         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21812         e_conv = DecodeError_clone(&e_conv);
21813         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21814         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
21815         return (int64_t)ret_conv;
21816 }
21817
21818 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21819         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
21820         jboolean ret_val = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
21821         return ret_val;
21822 }
21823
21824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21825         if ((_res & 1) != 0) return;
21826         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21827         CHECK_ACCESS(_res_ptr);
21828         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
21829         FREE((void*)_res);
21830         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
21831 }
21832
21833 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
21834         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21835         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
21836         return (int64_t)ret_conv;
21837 }
21838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21839         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
21840         int64_t ret_val = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
21841         return ret_val;
21842 }
21843
21844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21845         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
21846         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21847         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
21848         return (int64_t)ret_conv;
21849 }
21850
21851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21852         LDKUpdateFailMalformedHTLC o_conv;
21853         o_conv.inner = (void*)(o & (~1));
21854         o_conv.is_owned = (o & 1) || (o == 0);
21855         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21856         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
21857         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21858         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
21859         return (int64_t)ret_conv;
21860 }
21861
21862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21863         LDKDecodeError e_conv;
21864         e_conv.inner = (void*)(e & (~1));
21865         e_conv.is_owned = (e & 1) || (e == 0);
21866         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21867         e_conv = DecodeError_clone(&e_conv);
21868         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21869         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
21870         return (int64_t)ret_conv;
21871 }
21872
21873 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21874         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
21875         jboolean ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
21876         return ret_val;
21877 }
21878
21879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21880         if ((_res & 1) != 0) return;
21881         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21882         CHECK_ACCESS(_res_ptr);
21883         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
21884         FREE((void*)_res);
21885         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
21886 }
21887
21888 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
21889         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21890         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
21891         return (int64_t)ret_conv;
21892 }
21893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21894         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
21895         int64_t ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
21896         return ret_val;
21897 }
21898
21899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21900         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
21901         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21902         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
21903         return (int64_t)ret_conv;
21904 }
21905
21906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21907         LDKUpdateFee o_conv;
21908         o_conv.inner = (void*)(o & (~1));
21909         o_conv.is_owned = (o & 1) || (o == 0);
21910         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21911         o_conv = UpdateFee_clone(&o_conv);
21912         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21913         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
21914         return (int64_t)ret_conv;
21915 }
21916
21917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21918         LDKDecodeError e_conv;
21919         e_conv.inner = (void*)(e & (~1));
21920         e_conv.is_owned = (e & 1) || (e == 0);
21921         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21922         e_conv = DecodeError_clone(&e_conv);
21923         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21924         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
21925         return (int64_t)ret_conv;
21926 }
21927
21928 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21929         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
21930         jboolean ret_val = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
21931         return ret_val;
21932 }
21933
21934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21935         if ((_res & 1) != 0) return;
21936         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21937         CHECK_ACCESS(_res_ptr);
21938         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
21939         FREE((void*)_res);
21940         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
21941 }
21942
21943 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
21944         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21945         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
21946         return (int64_t)ret_conv;
21947 }
21948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21949         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
21950         int64_t ret_val = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
21951         return ret_val;
21952 }
21953
21954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21955         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
21956         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21957         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
21958         return (int64_t)ret_conv;
21959 }
21960
21961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21962         LDKUpdateFulfillHTLC o_conv;
21963         o_conv.inner = (void*)(o & (~1));
21964         o_conv.is_owned = (o & 1) || (o == 0);
21965         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21966         o_conv = UpdateFulfillHTLC_clone(&o_conv);
21967         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21968         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
21969         return (int64_t)ret_conv;
21970 }
21971
21972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21973         LDKDecodeError e_conv;
21974         e_conv.inner = (void*)(e & (~1));
21975         e_conv.is_owned = (e & 1) || (e == 0);
21976         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21977         e_conv = DecodeError_clone(&e_conv);
21978         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21979         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
21980         return (int64_t)ret_conv;
21981 }
21982
21983 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21984         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
21985         jboolean ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
21986         return ret_val;
21987 }
21988
21989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21990         if ((_res & 1) != 0) return;
21991         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21992         CHECK_ACCESS(_res_ptr);
21993         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
21994         FREE((void*)_res);
21995         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
21996 }
21997
21998 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
21999         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22000         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
22001         return (int64_t)ret_conv;
22002 }
22003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22004         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
22005         int64_t ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
22006         return ret_val;
22007 }
22008
22009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22010         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
22011         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22012         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
22013         return (int64_t)ret_conv;
22014 }
22015
22016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22017         LDKUpdateAddHTLC o_conv;
22018         o_conv.inner = (void*)(o & (~1));
22019         o_conv.is_owned = (o & 1) || (o == 0);
22020         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22021         o_conv = UpdateAddHTLC_clone(&o_conv);
22022         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22023         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
22024         return (int64_t)ret_conv;
22025 }
22026
22027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22028         LDKDecodeError e_conv;
22029         e_conv.inner = (void*)(e & (~1));
22030         e_conv.is_owned = (e & 1) || (e == 0);
22031         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22032         e_conv = DecodeError_clone(&e_conv);
22033         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22034         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
22035         return (int64_t)ret_conv;
22036 }
22037
22038 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22039         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
22040         jboolean ret_val = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
22041         return ret_val;
22042 }
22043
22044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22045         if ((_res & 1) != 0) return;
22046         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22047         CHECK_ACCESS(_res_ptr);
22048         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
22049         FREE((void*)_res);
22050         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
22051 }
22052
22053 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
22054         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22055         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
22056         return (int64_t)ret_conv;
22057 }
22058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22059         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
22060         int64_t ret_val = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
22061         return ret_val;
22062 }
22063
22064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22065         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
22066         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22067         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
22068         return (int64_t)ret_conv;
22069 }
22070
22071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22072         LDKPing o_conv;
22073         o_conv.inner = (void*)(o & (~1));
22074         o_conv.is_owned = (o & 1) || (o == 0);
22075         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22076         o_conv = Ping_clone(&o_conv);
22077         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22078         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
22079         return (int64_t)ret_conv;
22080 }
22081
22082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22083         LDKDecodeError e_conv;
22084         e_conv.inner = (void*)(e & (~1));
22085         e_conv.is_owned = (e & 1) || (e == 0);
22086         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22087         e_conv = DecodeError_clone(&e_conv);
22088         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22089         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
22090         return (int64_t)ret_conv;
22091 }
22092
22093 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22094         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
22095         jboolean ret_val = CResult_PingDecodeErrorZ_is_ok(o_conv);
22096         return ret_val;
22097 }
22098
22099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22100         if ((_res & 1) != 0) return;
22101         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22102         CHECK_ACCESS(_res_ptr);
22103         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
22104         FREE((void*)_res);
22105         CResult_PingDecodeErrorZ_free(_res_conv);
22106 }
22107
22108 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
22109         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22110         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
22111         return (int64_t)ret_conv;
22112 }
22113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22114         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
22115         int64_t ret_val = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
22116         return ret_val;
22117 }
22118
22119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22120         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
22121         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22122         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
22123         return (int64_t)ret_conv;
22124 }
22125
22126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22127         LDKPong o_conv;
22128         o_conv.inner = (void*)(o & (~1));
22129         o_conv.is_owned = (o & 1) || (o == 0);
22130         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22131         o_conv = Pong_clone(&o_conv);
22132         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22133         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
22134         return (int64_t)ret_conv;
22135 }
22136
22137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22138         LDKDecodeError e_conv;
22139         e_conv.inner = (void*)(e & (~1));
22140         e_conv.is_owned = (e & 1) || (e == 0);
22141         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22142         e_conv = DecodeError_clone(&e_conv);
22143         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22144         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
22145         return (int64_t)ret_conv;
22146 }
22147
22148 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22149         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
22150         jboolean ret_val = CResult_PongDecodeErrorZ_is_ok(o_conv);
22151         return ret_val;
22152 }
22153
22154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22155         if ((_res & 1) != 0) return;
22156         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22157         CHECK_ACCESS(_res_ptr);
22158         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
22159         FREE((void*)_res);
22160         CResult_PongDecodeErrorZ_free(_res_conv);
22161 }
22162
22163 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
22164         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22165         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
22166         return (int64_t)ret_conv;
22167 }
22168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22169         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
22170         int64_t ret_val = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
22171         return ret_val;
22172 }
22173
22174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22175         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
22176         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22177         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
22178         return (int64_t)ret_conv;
22179 }
22180
22181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22182         LDKUnsignedChannelAnnouncement o_conv;
22183         o_conv.inner = (void*)(o & (~1));
22184         o_conv.is_owned = (o & 1) || (o == 0);
22185         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22186         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
22187         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22188         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
22189         return (int64_t)ret_conv;
22190 }
22191
22192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22193         LDKDecodeError e_conv;
22194         e_conv.inner = (void*)(e & (~1));
22195         e_conv.is_owned = (e & 1) || (e == 0);
22196         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22197         e_conv = DecodeError_clone(&e_conv);
22198         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22199         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
22200         return (int64_t)ret_conv;
22201 }
22202
22203 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22204         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
22205         jboolean ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
22206         return ret_val;
22207 }
22208
22209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22210         if ((_res & 1) != 0) return;
22211         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22212         CHECK_ACCESS(_res_ptr);
22213         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
22214         FREE((void*)_res);
22215         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
22216 }
22217
22218 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22219         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22220         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
22221         return (int64_t)ret_conv;
22222 }
22223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22224         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
22225         int64_t ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22226         return ret_val;
22227 }
22228
22229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22230         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
22231         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22232         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
22233         return (int64_t)ret_conv;
22234 }
22235
22236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22237         LDKChannelAnnouncement o_conv;
22238         o_conv.inner = (void*)(o & (~1));
22239         o_conv.is_owned = (o & 1) || (o == 0);
22240         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22241         o_conv = ChannelAnnouncement_clone(&o_conv);
22242         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22243         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
22244         return (int64_t)ret_conv;
22245 }
22246
22247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22248         LDKDecodeError e_conv;
22249         e_conv.inner = (void*)(e & (~1));
22250         e_conv.is_owned = (e & 1) || (e == 0);
22251         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22252         e_conv = DecodeError_clone(&e_conv);
22253         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22254         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
22255         return (int64_t)ret_conv;
22256 }
22257
22258 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22259         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
22260         jboolean ret_val = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
22261         return ret_val;
22262 }
22263
22264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22265         if ((_res & 1) != 0) return;
22266         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22267         CHECK_ACCESS(_res_ptr);
22268         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
22269         FREE((void*)_res);
22270         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
22271 }
22272
22273 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22274         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22275         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
22276         return (int64_t)ret_conv;
22277 }
22278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22279         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
22280         int64_t ret_val = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22281         return ret_val;
22282 }
22283
22284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22285         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
22286         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22287         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
22288         return (int64_t)ret_conv;
22289 }
22290
22291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22292         LDKUnsignedChannelUpdate o_conv;
22293         o_conv.inner = (void*)(o & (~1));
22294         o_conv.is_owned = (o & 1) || (o == 0);
22295         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22296         o_conv = UnsignedChannelUpdate_clone(&o_conv);
22297         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22298         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
22299         return (int64_t)ret_conv;
22300 }
22301
22302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22303         LDKDecodeError e_conv;
22304         e_conv.inner = (void*)(e & (~1));
22305         e_conv.is_owned = (e & 1) || (e == 0);
22306         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22307         e_conv = DecodeError_clone(&e_conv);
22308         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22309         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
22310         return (int64_t)ret_conv;
22311 }
22312
22313 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22314         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
22315         jboolean ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
22316         return ret_val;
22317 }
22318
22319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22320         if ((_res & 1) != 0) return;
22321         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22322         CHECK_ACCESS(_res_ptr);
22323         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
22324         FREE((void*)_res);
22325         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
22326 }
22327
22328 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
22329         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22330         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
22331         return (int64_t)ret_conv;
22332 }
22333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22334         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
22335         int64_t ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
22336         return ret_val;
22337 }
22338
22339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22340         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
22341         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22342         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
22343         return (int64_t)ret_conv;
22344 }
22345
22346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22347         LDKChannelUpdate o_conv;
22348         o_conv.inner = (void*)(o & (~1));
22349         o_conv.is_owned = (o & 1) || (o == 0);
22350         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22351         o_conv = ChannelUpdate_clone(&o_conv);
22352         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22353         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
22354         return (int64_t)ret_conv;
22355 }
22356
22357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22358         LDKDecodeError e_conv;
22359         e_conv.inner = (void*)(e & (~1));
22360         e_conv.is_owned = (e & 1) || (e == 0);
22361         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22362         e_conv = DecodeError_clone(&e_conv);
22363         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22364         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
22365         return (int64_t)ret_conv;
22366 }
22367
22368 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22369         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
22370         jboolean ret_val = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
22371         return ret_val;
22372 }
22373
22374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22375         if ((_res & 1) != 0) return;
22376         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22377         CHECK_ACCESS(_res_ptr);
22378         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
22379         FREE((void*)_res);
22380         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
22381 }
22382
22383 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
22384         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22385         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
22386         return (int64_t)ret_conv;
22387 }
22388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22389         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
22390         int64_t ret_val = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
22391         return ret_val;
22392 }
22393
22394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22395         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
22396         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22397         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
22398         return (int64_t)ret_conv;
22399 }
22400
22401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22402         LDKErrorMessage o_conv;
22403         o_conv.inner = (void*)(o & (~1));
22404         o_conv.is_owned = (o & 1) || (o == 0);
22405         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22406         o_conv = ErrorMessage_clone(&o_conv);
22407         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22408         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
22409         return (int64_t)ret_conv;
22410 }
22411
22412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22413         LDKDecodeError e_conv;
22414         e_conv.inner = (void*)(e & (~1));
22415         e_conv.is_owned = (e & 1) || (e == 0);
22416         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22417         e_conv = DecodeError_clone(&e_conv);
22418         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22419         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
22420         return (int64_t)ret_conv;
22421 }
22422
22423 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22424         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
22425         jboolean ret_val = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
22426         return ret_val;
22427 }
22428
22429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22430         if ((_res & 1) != 0) return;
22431         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22432         CHECK_ACCESS(_res_ptr);
22433         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
22434         FREE((void*)_res);
22435         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
22436 }
22437
22438 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
22439         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22440         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
22441         return (int64_t)ret_conv;
22442 }
22443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22444         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
22445         int64_t ret_val = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
22446         return ret_val;
22447 }
22448
22449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22450         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
22451         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22452         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
22453         return (int64_t)ret_conv;
22454 }
22455
22456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22457         LDKWarningMessage o_conv;
22458         o_conv.inner = (void*)(o & (~1));
22459         o_conv.is_owned = (o & 1) || (o == 0);
22460         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22461         o_conv = WarningMessage_clone(&o_conv);
22462         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22463         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
22464         return (int64_t)ret_conv;
22465 }
22466
22467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22468         LDKDecodeError e_conv;
22469         e_conv.inner = (void*)(e & (~1));
22470         e_conv.is_owned = (e & 1) || (e == 0);
22471         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22472         e_conv = DecodeError_clone(&e_conv);
22473         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22474         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
22475         return (int64_t)ret_conv;
22476 }
22477
22478 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22479         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
22480         jboolean ret_val = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
22481         return ret_val;
22482 }
22483
22484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22485         if ((_res & 1) != 0) return;
22486         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22487         CHECK_ACCESS(_res_ptr);
22488         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
22489         FREE((void*)_res);
22490         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
22491 }
22492
22493 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
22494         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22495         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
22496         return (int64_t)ret_conv;
22497 }
22498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22499         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
22500         int64_t ret_val = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
22501         return ret_val;
22502 }
22503
22504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22505         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
22506         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22507         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
22508         return (int64_t)ret_conv;
22509 }
22510
22511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22512         LDKUnsignedNodeAnnouncement o_conv;
22513         o_conv.inner = (void*)(o & (~1));
22514         o_conv.is_owned = (o & 1) || (o == 0);
22515         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22516         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
22517         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22518         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
22519         return (int64_t)ret_conv;
22520 }
22521
22522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22523         LDKDecodeError e_conv;
22524         e_conv.inner = (void*)(e & (~1));
22525         e_conv.is_owned = (e & 1) || (e == 0);
22526         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22527         e_conv = DecodeError_clone(&e_conv);
22528         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22529         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
22530         return (int64_t)ret_conv;
22531 }
22532
22533 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22534         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
22535         jboolean ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
22536         return ret_val;
22537 }
22538
22539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22540         if ((_res & 1) != 0) return;
22541         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22542         CHECK_ACCESS(_res_ptr);
22543         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
22544         FREE((void*)_res);
22545         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
22546 }
22547
22548 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22549         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22550         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
22551         return (int64_t)ret_conv;
22552 }
22553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22554         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
22555         int64_t ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22556         return ret_val;
22557 }
22558
22559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22560         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
22561         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22562         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
22563         return (int64_t)ret_conv;
22564 }
22565
22566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22567         LDKNodeAnnouncement o_conv;
22568         o_conv.inner = (void*)(o & (~1));
22569         o_conv.is_owned = (o & 1) || (o == 0);
22570         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22571         o_conv = NodeAnnouncement_clone(&o_conv);
22572         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22573         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
22574         return (int64_t)ret_conv;
22575 }
22576
22577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22578         LDKDecodeError e_conv;
22579         e_conv.inner = (void*)(e & (~1));
22580         e_conv.is_owned = (e & 1) || (e == 0);
22581         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22582         e_conv = DecodeError_clone(&e_conv);
22583         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22584         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
22585         return (int64_t)ret_conv;
22586 }
22587
22588 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22589         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
22590         jboolean ret_val = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
22591         return ret_val;
22592 }
22593
22594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22595         if ((_res & 1) != 0) return;
22596         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22597         CHECK_ACCESS(_res_ptr);
22598         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
22599         FREE((void*)_res);
22600         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
22601 }
22602
22603 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22604         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22605         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
22606         return (int64_t)ret_conv;
22607 }
22608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22609         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
22610         int64_t ret_val = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22611         return ret_val;
22612 }
22613
22614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22615         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
22616         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22617         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
22618         return (int64_t)ret_conv;
22619 }
22620
22621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22622         LDKQueryShortChannelIds o_conv;
22623         o_conv.inner = (void*)(o & (~1));
22624         o_conv.is_owned = (o & 1) || (o == 0);
22625         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22626         o_conv = QueryShortChannelIds_clone(&o_conv);
22627         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22628         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
22629         return (int64_t)ret_conv;
22630 }
22631
22632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22633         LDKDecodeError e_conv;
22634         e_conv.inner = (void*)(e & (~1));
22635         e_conv.is_owned = (e & 1) || (e == 0);
22636         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22637         e_conv = DecodeError_clone(&e_conv);
22638         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22639         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
22640         return (int64_t)ret_conv;
22641 }
22642
22643 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22644         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
22645         jboolean ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
22646         return ret_val;
22647 }
22648
22649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22650         if ((_res & 1) != 0) return;
22651         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22652         CHECK_ACCESS(_res_ptr);
22653         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
22654         FREE((void*)_res);
22655         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
22656 }
22657
22658 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
22659         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22660         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
22661         return (int64_t)ret_conv;
22662 }
22663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22664         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
22665         int64_t ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
22666         return ret_val;
22667 }
22668
22669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22670         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
22671         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22672         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
22673         return (int64_t)ret_conv;
22674 }
22675
22676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22677         LDKReplyShortChannelIdsEnd o_conv;
22678         o_conv.inner = (void*)(o & (~1));
22679         o_conv.is_owned = (o & 1) || (o == 0);
22680         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22681         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
22682         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22683         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
22684         return (int64_t)ret_conv;
22685 }
22686
22687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22688         LDKDecodeError e_conv;
22689         e_conv.inner = (void*)(e & (~1));
22690         e_conv.is_owned = (e & 1) || (e == 0);
22691         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22692         e_conv = DecodeError_clone(&e_conv);
22693         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22694         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
22695         return (int64_t)ret_conv;
22696 }
22697
22698 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22699         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
22700         jboolean ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
22701         return ret_val;
22702 }
22703
22704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22705         if ((_res & 1) != 0) return;
22706         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22707         CHECK_ACCESS(_res_ptr);
22708         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
22709         FREE((void*)_res);
22710         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
22711 }
22712
22713 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
22714         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22715         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
22716         return (int64_t)ret_conv;
22717 }
22718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22719         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
22720         int64_t ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
22721         return ret_val;
22722 }
22723
22724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22725         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
22726         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22727         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
22728         return (int64_t)ret_conv;
22729 }
22730
22731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22732         LDKQueryChannelRange o_conv;
22733         o_conv.inner = (void*)(o & (~1));
22734         o_conv.is_owned = (o & 1) || (o == 0);
22735         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22736         o_conv = QueryChannelRange_clone(&o_conv);
22737         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22738         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
22739         return (int64_t)ret_conv;
22740 }
22741
22742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22743         LDKDecodeError e_conv;
22744         e_conv.inner = (void*)(e & (~1));
22745         e_conv.is_owned = (e & 1) || (e == 0);
22746         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22747         e_conv = DecodeError_clone(&e_conv);
22748         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22749         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
22750         return (int64_t)ret_conv;
22751 }
22752
22753 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22754         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
22755         jboolean ret_val = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
22756         return ret_val;
22757 }
22758
22759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22760         if ((_res & 1) != 0) return;
22761         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22762         CHECK_ACCESS(_res_ptr);
22763         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
22764         FREE((void*)_res);
22765         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
22766 }
22767
22768 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
22769         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22770         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
22771         return (int64_t)ret_conv;
22772 }
22773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22774         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
22775         int64_t ret_val = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
22776         return ret_val;
22777 }
22778
22779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22780         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
22781         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22782         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
22783         return (int64_t)ret_conv;
22784 }
22785
22786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22787         LDKReplyChannelRange o_conv;
22788         o_conv.inner = (void*)(o & (~1));
22789         o_conv.is_owned = (o & 1) || (o == 0);
22790         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22791         o_conv = ReplyChannelRange_clone(&o_conv);
22792         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22793         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
22794         return (int64_t)ret_conv;
22795 }
22796
22797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22798         LDKDecodeError e_conv;
22799         e_conv.inner = (void*)(e & (~1));
22800         e_conv.is_owned = (e & 1) || (e == 0);
22801         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22802         e_conv = DecodeError_clone(&e_conv);
22803         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22804         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
22805         return (int64_t)ret_conv;
22806 }
22807
22808 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22809         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
22810         jboolean ret_val = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
22811         return ret_val;
22812 }
22813
22814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22815         if ((_res & 1) != 0) return;
22816         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22817         CHECK_ACCESS(_res_ptr);
22818         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
22819         FREE((void*)_res);
22820         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
22821 }
22822
22823 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
22824         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22825         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
22826         return (int64_t)ret_conv;
22827 }
22828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22829         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
22830         int64_t ret_val = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
22831         return ret_val;
22832 }
22833
22834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22835         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
22836         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22837         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
22838         return (int64_t)ret_conv;
22839 }
22840
22841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22842         LDKGossipTimestampFilter o_conv;
22843         o_conv.inner = (void*)(o & (~1));
22844         o_conv.is_owned = (o & 1) || (o == 0);
22845         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22846         o_conv = GossipTimestampFilter_clone(&o_conv);
22847         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22848         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
22849         return (int64_t)ret_conv;
22850 }
22851
22852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22853         LDKDecodeError e_conv;
22854         e_conv.inner = (void*)(e & (~1));
22855         e_conv.is_owned = (e & 1) || (e == 0);
22856         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22857         e_conv = DecodeError_clone(&e_conv);
22858         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22859         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
22860         return (int64_t)ret_conv;
22861 }
22862
22863 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22864         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
22865         jboolean ret_val = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
22866         return ret_val;
22867 }
22868
22869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22870         if ((_res & 1) != 0) return;
22871         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22872         CHECK_ACCESS(_res_ptr);
22873         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
22874         FREE((void*)_res);
22875         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
22876 }
22877
22878 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
22879         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22880         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
22881         return (int64_t)ret_conv;
22882 }
22883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22884         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
22885         int64_t ret_val = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
22886         return ret_val;
22887 }
22888
22889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22890         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
22891         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22892         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
22893         return (int64_t)ret_conv;
22894 }
22895
22896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22897         LDKCVec_PhantomRouteHintsZ _res_constr;
22898         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22899         if (_res_constr.datalen > 0)
22900                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
22901         else
22902                 _res_constr.data = NULL;
22903         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22904         for (size_t t = 0; t < _res_constr.datalen; t++) {
22905                 int64_t _res_conv_19 = _res_vals[t];
22906                 LDKPhantomRouteHints _res_conv_19_conv;
22907                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
22908                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
22909                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
22910                 _res_constr.data[t] = _res_conv_19_conv;
22911         }
22912         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22913         CVec_PhantomRouteHintsZ_free(_res_constr);
22914 }
22915
22916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22917         LDKInvoice o_conv;
22918         o_conv.inner = (void*)(o & (~1));
22919         o_conv.is_owned = (o & 1) || (o == 0);
22920         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22921         o_conv = Invoice_clone(&o_conv);
22922         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22923         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
22924         return (int64_t)ret_conv;
22925 }
22926
22927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22928         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
22929         CHECK_ACCESS(e_ptr);
22930         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
22931         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
22932         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22933         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
22934         return (int64_t)ret_conv;
22935 }
22936
22937 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22938         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
22939         jboolean ret_val = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
22940         return ret_val;
22941 }
22942
22943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22944         if ((_res & 1) != 0) return;
22945         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22946         CHECK_ACCESS(_res_ptr);
22947         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
22948         FREE((void*)_res);
22949         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
22950 }
22951
22952 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
22953         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22954         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
22955         return (int64_t)ret_conv;
22956 }
22957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22958         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
22959         int64_t ret_val = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
22960         return ret_val;
22961 }
22962
22963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22964         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
22965         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22966         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
22967         return (int64_t)ret_conv;
22968 }
22969
22970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22971         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
22972         CHECK_ACCESS(o_ptr);
22973         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
22974         if (o_conv.free == LDKFilter_JCalls_free) {
22975                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22976                 LDKFilter_JCalls_cloned(&o_conv);
22977         }
22978         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
22979         *ret_copy = COption_FilterZ_some(o_conv);
22980         int64_t ret_ref = (uintptr_t)ret_copy;
22981         return ret_ref;
22982 }
22983
22984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
22985         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
22986         *ret_copy = COption_FilterZ_none();
22987         int64_t ret_ref = (uintptr_t)ret_copy;
22988         return ret_ref;
22989 }
22990
22991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22992         if ((_res & 1) != 0) return;
22993         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22994         CHECK_ACCESS(_res_ptr);
22995         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
22996         FREE((void*)_res);
22997         COption_FilterZ_free(_res_conv);
22998 }
22999
23000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23001         LDKLockedChannelMonitor o_conv;
23002         o_conv.inner = (void*)(o & (~1));
23003         o_conv.is_owned = (o & 1) || (o == 0);
23004         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23005         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
23006         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
23007         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
23008         return (int64_t)ret_conv;
23009 }
23010
23011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
23012         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
23013         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
23014         return (int64_t)ret_conv;
23015 }
23016
23017 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23018         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
23019         jboolean ret_val = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
23020         return ret_val;
23021 }
23022
23023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23024         if ((_res & 1) != 0) return;
23025         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23026         CHECK_ACCESS(_res_ptr);
23027         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
23028         FREE((void*)_res);
23029         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
23030 }
23031
23032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23033         LDKCVec_OutPointZ _res_constr;
23034         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23035         if (_res_constr.datalen > 0)
23036                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
23037         else
23038                 _res_constr.data = NULL;
23039         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23040         for (size_t k = 0; k < _res_constr.datalen; k++) {
23041                 int64_t _res_conv_10 = _res_vals[k];
23042                 LDKOutPoint _res_conv_10_conv;
23043                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
23044                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
23045                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
23046                 _res_constr.data[k] = _res_conv_10_conv;
23047         }
23048         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23049         CVec_OutPointZ_free(_res_constr);
23050 }
23051
23052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23053         if ((this_ptr & 1) != 0) return;
23054         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23055         CHECK_ACCESS(this_ptr_ptr);
23056         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
23057         FREE((void*)this_ptr);
23058         PaymentPurpose_free(this_ptr_conv);
23059 }
23060
23061 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
23062         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23063         *ret_copy = PaymentPurpose_clone(arg);
23064 int64_t ret_ref = (uintptr_t)ret_copy;
23065         return ret_ref;
23066 }
23067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23068         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
23069         int64_t ret_val = PaymentPurpose_clone_ptr(arg_conv);
23070         return ret_val;
23071 }
23072
23073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23074         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
23075         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23076         *ret_copy = PaymentPurpose_clone(orig_conv);
23077         int64_t ret_ref = (uintptr_t)ret_copy;
23078         return ret_ref;
23079 }
23080
23081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
23082         LDKThirtyTwoBytes payment_preimage_ref;
23083         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
23084         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
23085         LDKThirtyTwoBytes payment_secret_ref;
23086         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
23087         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
23088         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23089         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
23090         int64_t ret_ref = (uintptr_t)ret_copy;
23091         return ret_ref;
23092 }
23093
23094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
23095         LDKThirtyTwoBytes a_ref;
23096         CHECK((*env)->GetArrayLength(env, a) == 32);
23097         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
23098         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23099         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
23100         int64_t ret_ref = (uintptr_t)ret_copy;
23101         return ret_ref;
23102 }
23103
23104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23105         if ((this_ptr & 1) != 0) return;
23106         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23107         CHECK_ACCESS(this_ptr_ptr);
23108         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
23109         FREE((void*)this_ptr);
23110         ClosureReason_free(this_ptr_conv);
23111 }
23112
23113 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
23114         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23115         *ret_copy = ClosureReason_clone(arg);
23116 int64_t ret_ref = (uintptr_t)ret_copy;
23117         return ret_ref;
23118 }
23119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23120         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
23121         int64_t ret_val = ClosureReason_clone_ptr(arg_conv);
23122         return ret_val;
23123 }
23124
23125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23126         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
23127         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23128         *ret_copy = ClosureReason_clone(orig_conv);
23129         int64_t ret_ref = (uintptr_t)ret_copy;
23130         return ret_ref;
23131 }
23132
23133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
23134         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
23135         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23136         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
23137         int64_t ret_ref = (uintptr_t)ret_copy;
23138         return ret_ref;
23139 }
23140
23141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
23142         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23143         *ret_copy = ClosureReason_holder_force_closed();
23144         int64_t ret_ref = (uintptr_t)ret_copy;
23145         return ret_ref;
23146 }
23147
23148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
23149         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23150         *ret_copy = ClosureReason_cooperative_closure();
23151         int64_t ret_ref = (uintptr_t)ret_copy;
23152         return ret_ref;
23153 }
23154
23155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
23156         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23157         *ret_copy = ClosureReason_commitment_tx_confirmed();
23158         int64_t ret_ref = (uintptr_t)ret_copy;
23159         return ret_ref;
23160 }
23161
23162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
23163         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23164         *ret_copy = ClosureReason_funding_timed_out();
23165         int64_t ret_ref = (uintptr_t)ret_copy;
23166         return ret_ref;
23167 }
23168
23169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
23170         LDKStr err_conv = java_to_owned_str(env, err);
23171         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23172         *ret_copy = ClosureReason_processing_error(err_conv);
23173         int64_t ret_ref = (uintptr_t)ret_copy;
23174         return ret_ref;
23175 }
23176
23177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
23178         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23179         *ret_copy = ClosureReason_disconnected_peer();
23180         int64_t ret_ref = (uintptr_t)ret_copy;
23181         return ret_ref;
23182 }
23183
23184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
23185         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23186         *ret_copy = ClosureReason_outdated_channel_manager();
23187         int64_t ret_ref = (uintptr_t)ret_copy;
23188         return ret_ref;
23189 }
23190
23191 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
23192         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
23193         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
23194         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23195         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23196         CVec_u8Z_free(ret_var);
23197         return ret_arr;
23198 }
23199
23200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23201         LDKu8slice ser_ref;
23202         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23203         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23204         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
23205         *ret_conv = ClosureReason_read(ser_ref);
23206         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23207         return (int64_t)ret_conv;
23208 }
23209
23210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23211         if ((this_ptr & 1) != 0) return;
23212         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23213         CHECK_ACCESS(this_ptr_ptr);
23214         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
23215         FREE((void*)this_ptr);
23216         Event_free(this_ptr_conv);
23217 }
23218
23219 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
23220         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23221         *ret_copy = Event_clone(arg);
23222 int64_t ret_ref = (uintptr_t)ret_copy;
23223         return ret_ref;
23224 }
23225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23226         LDKEvent* arg_conv = (LDKEvent*)arg;
23227         int64_t ret_val = Event_clone_ptr(arg_conv);
23228         return ret_val;
23229 }
23230
23231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23232         LDKEvent* orig_conv = (LDKEvent*)orig;
23233         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23234         *ret_copy = Event_clone(orig_conv);
23235         int64_t ret_ref = (uintptr_t)ret_copy;
23236         return ret_ref;
23237 }
23238
23239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1funding_1generation_1ready(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
23240         LDKThirtyTwoBytes temporary_channel_id_ref;
23241         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
23242         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
23243         LDKCVec_u8Z output_script_ref;
23244         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
23245         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
23246         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
23247         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23248         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
23249         int64_t ret_ref = (uintptr_t)ret_copy;
23250         return ret_ref;
23251 }
23252
23253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amt, int64_t purpose) {
23254         LDKThirtyTwoBytes payment_hash_ref;
23255         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23256         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23257         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
23258         CHECK_ACCESS(purpose_ptr);
23259         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
23260         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
23261         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23262         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
23263         int64_t ret_ref = (uintptr_t)ret_copy;
23264         return ret_ref;
23265 }
23266
23267 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) {
23268         LDKThirtyTwoBytes payment_id_ref;
23269         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23270         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23271         LDKThirtyTwoBytes payment_preimage_ref;
23272         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
23273         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
23274         LDKThirtyTwoBytes payment_hash_ref;
23275         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23276         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23277         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
23278         CHECK_ACCESS(fee_paid_msat_ptr);
23279         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
23280         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
23281         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23282         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
23283         int64_t ret_ref = (uintptr_t)ret_copy;
23284         return ret_ref;
23285 }
23286
23287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_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) {
23288         LDKThirtyTwoBytes payment_id_ref;
23289         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23290         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23291         LDKThirtyTwoBytes payment_hash_ref;
23292         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23293         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23294         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
23295         CHECK_ACCESS(network_update_ptr);
23296         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
23297         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
23298         LDKCVec_RouteHopZ path_constr;
23299         path_constr.datalen = (*env)->GetArrayLength(env, path);
23300         if (path_constr.datalen > 0)
23301                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23302         else
23303                 path_constr.data = NULL;
23304         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
23305         for (size_t k = 0; k < path_constr.datalen; k++) {
23306                 int64_t path_conv_10 = path_vals[k];
23307                 LDKRouteHop path_conv_10_conv;
23308                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
23309                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
23310                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
23311                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
23312                 path_constr.data[k] = path_conv_10_conv;
23313         }
23314         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
23315         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
23316         CHECK_ACCESS(short_channel_id_ptr);
23317         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
23318         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
23319         LDKRouteParameters retry_conv;
23320         retry_conv.inner = (void*)(retry & (~1));
23321         retry_conv.is_owned = (retry & 1) || (retry == 0);
23322         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
23323         retry_conv = RouteParameters_clone(&retry_conv);
23324         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23325         *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);
23326         int64_t ret_ref = (uintptr_t)ret_copy;
23327         return ret_ref;
23328 }
23329
23330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
23331         LDKThirtyTwoBytes payment_id_ref;
23332         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23333         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23334         LDKThirtyTwoBytes payment_hash_ref;
23335         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23336         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23337         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23338         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
23339         int64_t ret_ref = (uintptr_t)ret_copy;
23340         return ret_ref;
23341 }
23342
23343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
23344         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23345         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
23346         int64_t ret_ref = (uintptr_t)ret_copy;
23347         return ret_ref;
23348 }
23349
23350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
23351         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
23352         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
23353         if (outputs_constr.datalen > 0)
23354                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23355         else
23356                 outputs_constr.data = NULL;
23357         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
23358         for (size_t b = 0; b < outputs_constr.datalen; b++) {
23359                 int64_t outputs_conv_27 = outputs_vals[b];
23360                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
23361                 CHECK_ACCESS(outputs_conv_27_ptr);
23362                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
23363                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
23364                 outputs_constr.data[b] = outputs_conv_27_conv;
23365         }
23366         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
23367         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23368         *ret_copy = Event_spendable_outputs(outputs_constr);
23369         int64_t ret_ref = (uintptr_t)ret_copy;
23370         return ret_ref;
23371 }
23372
23373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) {
23374         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
23375         CHECK_ACCESS(fee_earned_msat_ptr);
23376         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
23377         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
23378         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23379         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
23380         int64_t ret_ref = (uintptr_t)ret_copy;
23381         return ret_ref;
23382 }
23383
23384 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) {
23385         LDKThirtyTwoBytes channel_id_ref;
23386         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
23387         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
23388         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
23389         CHECK_ACCESS(reason_ptr);
23390         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
23391         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
23392         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23393         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
23394         int64_t ret_ref = (uintptr_t)ret_copy;
23395         return ret_ref;
23396 }
23397
23398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
23399         LDKThirtyTwoBytes channel_id_ref;
23400         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
23401         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
23402         LDKTransaction transaction_ref;
23403         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
23404         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
23405         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
23406         transaction_ref.data_is_owned = true;
23407         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23408         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
23409         int64_t ret_ref = (uintptr_t)ret_copy;
23410         return ret_ref;
23411 }
23412
23413 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) {
23414         LDKThirtyTwoBytes payment_id_ref;
23415         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23416         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23417         LDKThirtyTwoBytes payment_hash_ref;
23418         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23419         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23420         LDKCVec_RouteHopZ path_constr;
23421         path_constr.datalen = (*env)->GetArrayLength(env, path);
23422         if (path_constr.datalen > 0)
23423                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23424         else
23425                 path_constr.data = NULL;
23426         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
23427         for (size_t k = 0; k < path_constr.datalen; k++) {
23428                 int64_t path_conv_10 = path_vals[k];
23429                 LDKRouteHop path_conv_10_conv;
23430                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
23431                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
23432                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
23433                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
23434                 path_constr.data[k] = path_conv_10_conv;
23435         }
23436         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
23437         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23438         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
23439         int64_t ret_ref = (uintptr_t)ret_copy;
23440         return ret_ref;
23441 }
23442
23443 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) {
23444         LDKThirtyTwoBytes temporary_channel_id_ref;
23445         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
23446         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
23447         LDKPublicKey counterparty_node_id_ref;
23448         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
23449         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
23450         LDKChannelTypeFeatures channel_type_conv;
23451         channel_type_conv.inner = (void*)(channel_type & (~1));
23452         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
23453         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
23454         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
23455         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23456         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
23457         int64_t ret_ref = (uintptr_t)ret_copy;
23458         return ret_ref;
23459 }
23460
23461 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
23462         LDKEvent* obj_conv = (LDKEvent*)obj;
23463         LDKCVec_u8Z ret_var = Event_write(obj_conv);
23464         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23465         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23466         CVec_u8Z_free(ret_var);
23467         return ret_arr;
23468 }
23469
23470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23471         LDKu8slice ser_ref;
23472         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23473         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23474         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
23475         *ret_conv = Event_read(ser_ref);
23476         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23477         return (int64_t)ret_conv;
23478 }
23479
23480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23481         if ((this_ptr & 1) != 0) return;
23482         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23483         CHECK_ACCESS(this_ptr_ptr);
23484         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
23485         FREE((void*)this_ptr);
23486         MessageSendEvent_free(this_ptr_conv);
23487 }
23488
23489 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
23490         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23491         *ret_copy = MessageSendEvent_clone(arg);
23492 int64_t ret_ref = (uintptr_t)ret_copy;
23493         return ret_ref;
23494 }
23495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23496         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
23497         int64_t ret_val = MessageSendEvent_clone_ptr(arg_conv);
23498         return ret_val;
23499 }
23500
23501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23502         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
23503         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23504         *ret_copy = MessageSendEvent_clone(orig_conv);
23505         int64_t ret_ref = (uintptr_t)ret_copy;
23506         return ret_ref;
23507 }
23508
23509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23510         LDKPublicKey node_id_ref;
23511         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23512         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23513         LDKAcceptChannel msg_conv;
23514         msg_conv.inner = (void*)(msg & (~1));
23515         msg_conv.is_owned = (msg & 1) || (msg == 0);
23516         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23517         msg_conv = AcceptChannel_clone(&msg_conv);
23518         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23519         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
23520         int64_t ret_ref = (uintptr_t)ret_copy;
23521         return ret_ref;
23522 }
23523
23524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23525         LDKPublicKey node_id_ref;
23526         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23527         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23528         LDKOpenChannel msg_conv;
23529         msg_conv.inner = (void*)(msg & (~1));
23530         msg_conv.is_owned = (msg & 1) || (msg == 0);
23531         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23532         msg_conv = OpenChannel_clone(&msg_conv);
23533         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23534         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
23535         int64_t ret_ref = (uintptr_t)ret_copy;
23536         return ret_ref;
23537 }
23538
23539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23540         LDKPublicKey node_id_ref;
23541         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23542         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23543         LDKFundingCreated msg_conv;
23544         msg_conv.inner = (void*)(msg & (~1));
23545         msg_conv.is_owned = (msg & 1) || (msg == 0);
23546         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23547         msg_conv = FundingCreated_clone(&msg_conv);
23548         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23549         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
23550         int64_t ret_ref = (uintptr_t)ret_copy;
23551         return ret_ref;
23552 }
23553
23554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23555         LDKPublicKey node_id_ref;
23556         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23557         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23558         LDKFundingSigned msg_conv;
23559         msg_conv.inner = (void*)(msg & (~1));
23560         msg_conv.is_owned = (msg & 1) || (msg == 0);
23561         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23562         msg_conv = FundingSigned_clone(&msg_conv);
23563         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23564         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
23565         int64_t ret_ref = (uintptr_t)ret_copy;
23566         return ret_ref;
23567 }
23568
23569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1locked(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23570         LDKPublicKey node_id_ref;
23571         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23572         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23573         LDKFundingLocked msg_conv;
23574         msg_conv.inner = (void*)(msg & (~1));
23575         msg_conv.is_owned = (msg & 1) || (msg == 0);
23576         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23577         msg_conv = FundingLocked_clone(&msg_conv);
23578         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23579         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
23580         int64_t ret_ref = (uintptr_t)ret_copy;
23581         return ret_ref;
23582 }
23583
23584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23585         LDKPublicKey node_id_ref;
23586         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23587         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23588         LDKAnnouncementSignatures msg_conv;
23589         msg_conv.inner = (void*)(msg & (~1));
23590         msg_conv.is_owned = (msg & 1) || (msg == 0);
23591         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23592         msg_conv = AnnouncementSignatures_clone(&msg_conv);
23593         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23594         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
23595         int64_t ret_ref = (uintptr_t)ret_copy;
23596         return ret_ref;
23597 }
23598
23599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
23600         LDKPublicKey node_id_ref;
23601         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23602         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23603         LDKCommitmentUpdate updates_conv;
23604         updates_conv.inner = (void*)(updates & (~1));
23605         updates_conv.is_owned = (updates & 1) || (updates == 0);
23606         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
23607         updates_conv = CommitmentUpdate_clone(&updates_conv);
23608         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23609         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
23610         int64_t ret_ref = (uintptr_t)ret_copy;
23611         return ret_ref;
23612 }
23613
23614 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) {
23615         LDKPublicKey node_id_ref;
23616         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23617         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23618         LDKRevokeAndACK msg_conv;
23619         msg_conv.inner = (void*)(msg & (~1));
23620         msg_conv.is_owned = (msg & 1) || (msg == 0);
23621         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23622         msg_conv = RevokeAndACK_clone(&msg_conv);
23623         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23624         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
23625         int64_t ret_ref = (uintptr_t)ret_copy;
23626         return ret_ref;
23627 }
23628
23629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23630         LDKPublicKey node_id_ref;
23631         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23632         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23633         LDKClosingSigned msg_conv;
23634         msg_conv.inner = (void*)(msg & (~1));
23635         msg_conv.is_owned = (msg & 1) || (msg == 0);
23636         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23637         msg_conv = ClosingSigned_clone(&msg_conv);
23638         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23639         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
23640         int64_t ret_ref = (uintptr_t)ret_copy;
23641         return ret_ref;
23642 }
23643
23644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23645         LDKPublicKey node_id_ref;
23646         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23647         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23648         LDKShutdown msg_conv;
23649         msg_conv.inner = (void*)(msg & (~1));
23650         msg_conv.is_owned = (msg & 1) || (msg == 0);
23651         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23652         msg_conv = Shutdown_clone(&msg_conv);
23653         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23654         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
23655         int64_t ret_ref = (uintptr_t)ret_copy;
23656         return ret_ref;
23657 }
23658
23659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23660         LDKPublicKey node_id_ref;
23661         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23662         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23663         LDKChannelReestablish msg_conv;
23664         msg_conv.inner = (void*)(msg & (~1));
23665         msg_conv.is_owned = (msg & 1) || (msg == 0);
23666         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23667         msg_conv = ChannelReestablish_clone(&msg_conv);
23668         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23669         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
23670         int64_t ret_ref = (uintptr_t)ret_copy;
23671         return ret_ref;
23672 }
23673
23674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
23675         LDKChannelAnnouncement msg_conv;
23676         msg_conv.inner = (void*)(msg & (~1));
23677         msg_conv.is_owned = (msg & 1) || (msg == 0);
23678         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23679         msg_conv = ChannelAnnouncement_clone(&msg_conv);
23680         LDKChannelUpdate update_msg_conv;
23681         update_msg_conv.inner = (void*)(update_msg & (~1));
23682         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
23683         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
23684         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
23685         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23686         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
23687         int64_t ret_ref = (uintptr_t)ret_copy;
23688         return ret_ref;
23689 }
23690
23691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
23692         LDKNodeAnnouncement msg_conv;
23693         msg_conv.inner = (void*)(msg & (~1));
23694         msg_conv.is_owned = (msg & 1) || (msg == 0);
23695         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23696         msg_conv = NodeAnnouncement_clone(&msg_conv);
23697         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23698         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
23699         int64_t ret_ref = (uintptr_t)ret_copy;
23700         return ret_ref;
23701 }
23702
23703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
23704         LDKChannelUpdate msg_conv;
23705         msg_conv.inner = (void*)(msg & (~1));
23706         msg_conv.is_owned = (msg & 1) || (msg == 0);
23707         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23708         msg_conv = ChannelUpdate_clone(&msg_conv);
23709         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23710         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
23711         int64_t ret_ref = (uintptr_t)ret_copy;
23712         return ret_ref;
23713 }
23714
23715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23716         LDKPublicKey node_id_ref;
23717         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23718         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23719         LDKChannelUpdate msg_conv;
23720         msg_conv.inner = (void*)(msg & (~1));
23721         msg_conv.is_owned = (msg & 1) || (msg == 0);
23722         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23723         msg_conv = ChannelUpdate_clone(&msg_conv);
23724         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23725         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
23726         int64_t ret_ref = (uintptr_t)ret_copy;
23727         return ret_ref;
23728 }
23729
23730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
23731         LDKPublicKey node_id_ref;
23732         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23733         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23734         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
23735         CHECK_ACCESS(action_ptr);
23736         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
23737         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
23738         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23739         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
23740         int64_t ret_ref = (uintptr_t)ret_copy;
23741         return ret_ref;
23742 }
23743
23744 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) {
23745         LDKPublicKey node_id_ref;
23746         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23747         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23748         LDKQueryChannelRange msg_conv;
23749         msg_conv.inner = (void*)(msg & (~1));
23750         msg_conv.is_owned = (msg & 1) || (msg == 0);
23751         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23752         msg_conv = QueryChannelRange_clone(&msg_conv);
23753         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23754         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
23755         int64_t ret_ref = (uintptr_t)ret_copy;
23756         return ret_ref;
23757 }
23758
23759 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) {
23760         LDKPublicKey node_id_ref;
23761         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23762         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23763         LDKQueryShortChannelIds msg_conv;
23764         msg_conv.inner = (void*)(msg & (~1));
23765         msg_conv.is_owned = (msg & 1) || (msg == 0);
23766         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23767         msg_conv = QueryShortChannelIds_clone(&msg_conv);
23768         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23769         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
23770         int64_t ret_ref = (uintptr_t)ret_copy;
23771         return ret_ref;
23772 }
23773
23774 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) {
23775         LDKPublicKey node_id_ref;
23776         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23777         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23778         LDKReplyChannelRange msg_conv;
23779         msg_conv.inner = (void*)(msg & (~1));
23780         msg_conv.is_owned = (msg & 1) || (msg == 0);
23781         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23782         msg_conv = ReplyChannelRange_clone(&msg_conv);
23783         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23784         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
23785         int64_t ret_ref = (uintptr_t)ret_copy;
23786         return ret_ref;
23787 }
23788
23789 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) {
23790         LDKPublicKey node_id_ref;
23791         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23792         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23793         LDKGossipTimestampFilter msg_conv;
23794         msg_conv.inner = (void*)(msg & (~1));
23795         msg_conv.is_owned = (msg & 1) || (msg == 0);
23796         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23797         msg_conv = GossipTimestampFilter_clone(&msg_conv);
23798         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23799         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
23800         int64_t ret_ref = (uintptr_t)ret_copy;
23801         return ret_ref;
23802 }
23803
23804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23805         if ((this_ptr & 1) != 0) return;
23806         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23807         CHECK_ACCESS(this_ptr_ptr);
23808         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
23809         FREE((void*)this_ptr);
23810         MessageSendEventsProvider_free(this_ptr_conv);
23811 }
23812
23813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23814         if ((this_ptr & 1) != 0) return;
23815         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23816         CHECK_ACCESS(this_ptr_ptr);
23817         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
23818         FREE((void*)this_ptr);
23819         EventsProvider_free(this_ptr_conv);
23820 }
23821
23822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23823         if ((this_ptr & 1) != 0) return;
23824         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23825         CHECK_ACCESS(this_ptr_ptr);
23826         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
23827         FREE((void*)this_ptr);
23828         EventHandler_free(this_ptr_conv);
23829 }
23830
23831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23832         if ((this_ptr & 1) != 0) return;
23833         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23834         CHECK_ACCESS(this_ptr_ptr);
23835         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
23836         FREE((void*)this_ptr);
23837         APIError_free(this_ptr_conv);
23838 }
23839
23840 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
23841         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23842         *ret_copy = APIError_clone(arg);
23843 int64_t ret_ref = (uintptr_t)ret_copy;
23844         return ret_ref;
23845 }
23846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23847         LDKAPIError* arg_conv = (LDKAPIError*)arg;
23848         int64_t ret_val = APIError_clone_ptr(arg_conv);
23849         return ret_val;
23850 }
23851
23852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23853         LDKAPIError* orig_conv = (LDKAPIError*)orig;
23854         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23855         *ret_copy = APIError_clone(orig_conv);
23856         int64_t ret_ref = (uintptr_t)ret_copy;
23857         return ret_ref;
23858 }
23859
23860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
23861         LDKStr err_conv = java_to_owned_str(env, err);
23862         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23863         *ret_copy = APIError_apimisuse_error(err_conv);
23864         int64_t ret_ref = (uintptr_t)ret_copy;
23865         return ret_ref;
23866 }
23867
23868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
23869         LDKStr err_conv = java_to_owned_str(env, err);
23870         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23871         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
23872         int64_t ret_ref = (uintptr_t)ret_copy;
23873         return ret_ref;
23874 }
23875
23876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
23877         LDKStr err_conv = java_to_owned_str(env, err);
23878         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23879         *ret_copy = APIError_route_error(err_conv);
23880         int64_t ret_ref = (uintptr_t)ret_copy;
23881         return ret_ref;
23882 }
23883
23884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
23885         LDKStr err_conv = java_to_owned_str(env, err);
23886         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23887         *ret_copy = APIError_channel_unavailable(err_conv);
23888         int64_t ret_ref = (uintptr_t)ret_copy;
23889         return ret_ref;
23890 }
23891
23892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
23893         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23894         *ret_copy = APIError_monitor_update_failed();
23895         int64_t ret_ref = (uintptr_t)ret_copy;
23896         return ret_ref;
23897 }
23898
23899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
23900         LDKShutdownScript script_conv;
23901         script_conv.inner = (void*)(script & (~1));
23902         script_conv.is_owned = (script & 1) || (script == 0);
23903         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
23904         script_conv = ShutdownScript_clone(&script_conv);
23905         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23906         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
23907         int64_t ret_ref = (uintptr_t)ret_copy;
23908         return ret_ref;
23909 }
23910
23911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
23912         LDKu8slice msg_ref;
23913         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
23914         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
23915         unsigned char sk_arr[32];
23916         CHECK((*env)->GetArrayLength(env, sk) == 32);
23917         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
23918         unsigned char (*sk_ref)[32] = &sk_arr;
23919         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
23920         *ret_conv = sign(msg_ref, sk_ref);
23921         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
23922         return (int64_t)ret_conv;
23923 }
23924
23925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
23926         LDKu8slice msg_ref;
23927         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
23928         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
23929         LDKStr sig_conv = java_to_owned_str(env, sig);
23930         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
23931         *ret_conv = recover_pk(msg_ref, sig_conv);
23932         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
23933         return (int64_t)ret_conv;
23934 }
23935
23936 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
23937         LDKu8slice msg_ref;
23938         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
23939         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
23940         LDKStr sig_conv = java_to_owned_str(env, sig);
23941         LDKPublicKey pk_ref;
23942         CHECK((*env)->GetArrayLength(env, pk) == 33);
23943         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
23944         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
23945         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
23946         return ret_val;
23947 }
23948
23949 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
23950         LDKu8slice hrp_bytes_ref;
23951         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
23952         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
23953         LDKCVec_u5Z data_without_signature_constr;
23954         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
23955         if (data_without_signature_constr.datalen > 0)
23956                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
23957         else
23958                 data_without_signature_constr.data = NULL;
23959         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
23960         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
23961                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
23962                 
23963                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
23964         }
23965         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
23966         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
23967         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23968         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23969         CVec_u8Z_free(ret_var);
23970         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
23971         return ret_arr;
23972 }
23973
23974 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23975         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
23976         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
23977         return ret_conv;
23978 }
23979
23980 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
23981         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
23982         return ret_conv;
23983 }
23984
23985 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
23986         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
23987         return ret_conv;
23988 }
23989
23990 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
23991         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
23992         return ret_conv;
23993 }
23994
23995 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
23996         jclass ret_conv = LDKLevel_to_java(env, Level_info());
23997         return ret_conv;
23998 }
23999
24000 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
24001         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
24002         return ret_conv;
24003 }
24004
24005 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
24006         jclass ret_conv = LDKLevel_to_java(env, Level_error());
24007         return ret_conv;
24008 }
24009
24010 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24011         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
24012         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
24013         jboolean ret_val = Level_eq(a_conv, b_conv);
24014         return ret_val;
24015 }
24016
24017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
24018         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
24019         int64_t ret_val = Level_hash(o_conv);
24020         return ret_val;
24021 }
24022
24023 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
24024         jclass ret_conv = LDKLevel_to_java(env, Level_max());
24025         return ret_conv;
24026 }
24027
24028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24029         LDKRecord this_obj_conv;
24030         this_obj_conv.inner = (void*)(this_obj & (~1));
24031         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24033         Record_free(this_obj_conv);
24034 }
24035
24036 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
24037         LDKRecord this_ptr_conv;
24038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24039         this_ptr_conv.is_owned = false;
24040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24041         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
24042         return ret_conv;
24043 }
24044
24045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
24046         LDKRecord this_ptr_conv;
24047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24048         this_ptr_conv.is_owned = false;
24049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24050         LDKLevel val_conv = LDKLevel_from_java(env, val);
24051         Record_set_level(&this_ptr_conv, val_conv);
24052 }
24053
24054 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
24055         LDKRecord this_ptr_conv;
24056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24057         this_ptr_conv.is_owned = false;
24058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24059         LDKStr ret_str = Record_get_args(&this_ptr_conv);
24060         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24061         Str_free(ret_str);
24062         return ret_conv;
24063 }
24064
24065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24066         LDKRecord this_ptr_conv;
24067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24068         this_ptr_conv.is_owned = false;
24069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24070         LDKStr val_conv = java_to_owned_str(env, val);
24071         Record_set_args(&this_ptr_conv, val_conv);
24072 }
24073
24074 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
24075         LDKRecord this_ptr_conv;
24076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24077         this_ptr_conv.is_owned = false;
24078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24079         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
24080         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24081         Str_free(ret_str);
24082         return ret_conv;
24083 }
24084
24085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24086         LDKRecord this_ptr_conv;
24087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24088         this_ptr_conv.is_owned = false;
24089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24090         LDKStr val_conv = java_to_owned_str(env, val);
24091         Record_set_module_path(&this_ptr_conv, val_conv);
24092 }
24093
24094 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
24095         LDKRecord this_ptr_conv;
24096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24097         this_ptr_conv.is_owned = false;
24098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24099         LDKStr ret_str = Record_get_file(&this_ptr_conv);
24100         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24101         Str_free(ret_str);
24102         return ret_conv;
24103 }
24104
24105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24106         LDKRecord this_ptr_conv;
24107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24108         this_ptr_conv.is_owned = false;
24109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24110         LDKStr val_conv = java_to_owned_str(env, val);
24111         Record_set_file(&this_ptr_conv, val_conv);
24112 }
24113
24114 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
24115         LDKRecord this_ptr_conv;
24116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24117         this_ptr_conv.is_owned = false;
24118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24119         int32_t ret_val = Record_get_line(&this_ptr_conv);
24120         return ret_val;
24121 }
24122
24123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24124         LDKRecord this_ptr_conv;
24125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24126         this_ptr_conv.is_owned = false;
24127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24128         Record_set_line(&this_ptr_conv, val);
24129 }
24130
24131 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
24132         LDKRecord ret_var = Record_clone(arg);
24133 int64_t ret_ref = 0;
24134 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24135 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24136 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24137 ret_ref = (uintptr_t)ret_var.inner;
24138 if (ret_var.is_owned) {
24139         ret_ref |= 1;
24140 }
24141         return ret_ref;
24142 }
24143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24144         LDKRecord arg_conv;
24145         arg_conv.inner = (void*)(arg & (~1));
24146         arg_conv.is_owned = false;
24147         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24148         int64_t ret_val = Record_clone_ptr(&arg_conv);
24149         return ret_val;
24150 }
24151
24152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24153         LDKRecord orig_conv;
24154         orig_conv.inner = (void*)(orig & (~1));
24155         orig_conv.is_owned = false;
24156         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24157         LDKRecord ret_var = Record_clone(&orig_conv);
24158         int64_t ret_ref = 0;
24159         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24160         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24162         ret_ref = (uintptr_t)ret_var.inner;
24163         if (ret_var.is_owned) {
24164                 ret_ref |= 1;
24165         }
24166         return ret_ref;
24167 }
24168
24169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24170         if ((this_ptr & 1) != 0) return;
24171         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24172         CHECK_ACCESS(this_ptr_ptr);
24173         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
24174         FREE((void*)this_ptr);
24175         Logger_free(this_ptr_conv);
24176 }
24177
24178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24179         LDKChannelHandshakeConfig this_obj_conv;
24180         this_obj_conv.inner = (void*)(this_obj & (~1));
24181         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24183         ChannelHandshakeConfig_free(this_obj_conv);
24184 }
24185
24186 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
24187         LDKChannelHandshakeConfig this_ptr_conv;
24188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24189         this_ptr_conv.is_owned = false;
24190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24191         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
24192         return ret_val;
24193 }
24194
24195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24196         LDKChannelHandshakeConfig this_ptr_conv;
24197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24198         this_ptr_conv.is_owned = false;
24199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24200         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
24201 }
24202
24203 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
24204         LDKChannelHandshakeConfig this_ptr_conv;
24205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24206         this_ptr_conv.is_owned = false;
24207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24208         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
24209         return ret_val;
24210 }
24211
24212 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) {
24213         LDKChannelHandshakeConfig this_ptr_conv;
24214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24215         this_ptr_conv.is_owned = false;
24216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24217         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
24218 }
24219
24220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24221         LDKChannelHandshakeConfig this_ptr_conv;
24222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24223         this_ptr_conv.is_owned = false;
24224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24225         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
24226         return ret_val;
24227 }
24228
24229 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) {
24230         LDKChannelHandshakeConfig this_ptr_conv;
24231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24232         this_ptr_conv.is_owned = false;
24233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24234         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
24235 }
24236
24237 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
24238         LDKChannelHandshakeConfig this_ptr_conv;
24239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24240         this_ptr_conv.is_owned = false;
24241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24242         jboolean ret_val = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
24243         return ret_val;
24244 }
24245
24246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24247         LDKChannelHandshakeConfig this_ptr_conv;
24248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24249         this_ptr_conv.is_owned = false;
24250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24251         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
24252 }
24253
24254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1new(JNIEnv *env, jclass clz, int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg, jboolean negotiate_scid_privacy_arg) {
24255         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, negotiate_scid_privacy_arg);
24256         int64_t ret_ref = 0;
24257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24260         ret_ref = (uintptr_t)ret_var.inner;
24261         if (ret_var.is_owned) {
24262                 ret_ref |= 1;
24263         }
24264         return ret_ref;
24265 }
24266
24267 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
24268         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
24269 int64_t ret_ref = 0;
24270 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24271 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24272 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24273 ret_ref = (uintptr_t)ret_var.inner;
24274 if (ret_var.is_owned) {
24275         ret_ref |= 1;
24276 }
24277         return ret_ref;
24278 }
24279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24280         LDKChannelHandshakeConfig arg_conv;
24281         arg_conv.inner = (void*)(arg & (~1));
24282         arg_conv.is_owned = false;
24283         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24284         int64_t ret_val = ChannelHandshakeConfig_clone_ptr(&arg_conv);
24285         return ret_val;
24286 }
24287
24288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24289         LDKChannelHandshakeConfig orig_conv;
24290         orig_conv.inner = (void*)(orig & (~1));
24291         orig_conv.is_owned = false;
24292         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24293         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
24294         int64_t ret_ref = 0;
24295         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24296         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24298         ret_ref = (uintptr_t)ret_var.inner;
24299         if (ret_var.is_owned) {
24300                 ret_ref |= 1;
24301         }
24302         return ret_ref;
24303 }
24304
24305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
24306         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
24307         int64_t ret_ref = 0;
24308         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24309         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24311         ret_ref = (uintptr_t)ret_var.inner;
24312         if (ret_var.is_owned) {
24313                 ret_ref |= 1;
24314         }
24315         return ret_ref;
24316 }
24317
24318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24319         LDKChannelHandshakeLimits this_obj_conv;
24320         this_obj_conv.inner = (void*)(this_obj & (~1));
24321         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24323         ChannelHandshakeLimits_free(this_obj_conv);
24324 }
24325
24326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
24327         LDKChannelHandshakeLimits this_ptr_conv;
24328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24329         this_ptr_conv.is_owned = false;
24330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24331         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
24332         return ret_val;
24333 }
24334
24335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24336         LDKChannelHandshakeLimits this_ptr_conv;
24337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24338         this_ptr_conv.is_owned = false;
24339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24340         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
24341 }
24342
24343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24344         LDKChannelHandshakeLimits this_ptr_conv;
24345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24346         this_ptr_conv.is_owned = false;
24347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24348         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
24349         return ret_val;
24350 }
24351
24352 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) {
24353         LDKChannelHandshakeLimits this_ptr_conv;
24354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24355         this_ptr_conv.is_owned = false;
24356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24357         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
24358 }
24359
24360 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) {
24361         LDKChannelHandshakeLimits this_ptr_conv;
24362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24363         this_ptr_conv.is_owned = false;
24364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24365         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
24366         return ret_val;
24367 }
24368
24369 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) {
24370         LDKChannelHandshakeLimits this_ptr_conv;
24371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24372         this_ptr_conv.is_owned = false;
24373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24374         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
24375 }
24376
24377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
24378         LDKChannelHandshakeLimits this_ptr_conv;
24379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24380         this_ptr_conv.is_owned = false;
24381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24382         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
24383         return ret_val;
24384 }
24385
24386 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) {
24387         LDKChannelHandshakeLimits this_ptr_conv;
24388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24389         this_ptr_conv.is_owned = false;
24390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24391         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
24392 }
24393
24394 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
24395         LDKChannelHandshakeLimits this_ptr_conv;
24396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24397         this_ptr_conv.is_owned = false;
24398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24399         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
24400         return ret_val;
24401 }
24402
24403 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) {
24404         LDKChannelHandshakeLimits this_ptr_conv;
24405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24406         this_ptr_conv.is_owned = false;
24407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24408         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
24409 }
24410
24411 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
24412         LDKChannelHandshakeLimits this_ptr_conv;
24413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24414         this_ptr_conv.is_owned = false;
24415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24416         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
24417         return ret_val;
24418 }
24419
24420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24421         LDKChannelHandshakeLimits this_ptr_conv;
24422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24423         this_ptr_conv.is_owned = false;
24424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24425         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
24426 }
24427
24428 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
24429         LDKChannelHandshakeLimits this_ptr_conv;
24430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24431         this_ptr_conv.is_owned = false;
24432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24433         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
24434         return ret_val;
24435 }
24436
24437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24438         LDKChannelHandshakeLimits this_ptr_conv;
24439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24440         this_ptr_conv.is_owned = false;
24441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24442         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
24443 }
24444
24445 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
24446         LDKChannelHandshakeLimits this_ptr_conv;
24447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24448         this_ptr_conv.is_owned = false;
24449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24450         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
24451         return ret_val;
24452 }
24453
24454 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) {
24455         LDKChannelHandshakeLimits this_ptr_conv;
24456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24457         this_ptr_conv.is_owned = false;
24458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24459         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
24460 }
24461
24462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(JNIEnv *env, jclass clz, int64_t min_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int32_t max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
24463         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
24464         int64_t ret_ref = 0;
24465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24468         ret_ref = (uintptr_t)ret_var.inner;
24469         if (ret_var.is_owned) {
24470                 ret_ref |= 1;
24471         }
24472         return ret_ref;
24473 }
24474
24475 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
24476         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
24477 int64_t ret_ref = 0;
24478 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24479 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24480 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24481 ret_ref = (uintptr_t)ret_var.inner;
24482 if (ret_var.is_owned) {
24483         ret_ref |= 1;
24484 }
24485         return ret_ref;
24486 }
24487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24488         LDKChannelHandshakeLimits arg_conv;
24489         arg_conv.inner = (void*)(arg & (~1));
24490         arg_conv.is_owned = false;
24491         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24492         int64_t ret_val = ChannelHandshakeLimits_clone_ptr(&arg_conv);
24493         return ret_val;
24494 }
24495
24496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24497         LDKChannelHandshakeLimits orig_conv;
24498         orig_conv.inner = (void*)(orig & (~1));
24499         orig_conv.is_owned = false;
24500         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24501         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
24502         int64_t ret_ref = 0;
24503         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24504         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24506         ret_ref = (uintptr_t)ret_var.inner;
24507         if (ret_var.is_owned) {
24508                 ret_ref |= 1;
24509         }
24510         return ret_ref;
24511 }
24512
24513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
24514         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
24515         int64_t ret_ref = 0;
24516         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24517         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24519         ret_ref = (uintptr_t)ret_var.inner;
24520         if (ret_var.is_owned) {
24521                 ret_ref |= 1;
24522         }
24523         return ret_ref;
24524 }
24525
24526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24527         LDKChannelConfig this_obj_conv;
24528         this_obj_conv.inner = (void*)(this_obj & (~1));
24529         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24531         ChannelConfig_free(this_obj_conv);
24532 }
24533
24534 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
24535         LDKChannelConfig this_ptr_conv;
24536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24537         this_ptr_conv.is_owned = false;
24538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24539         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
24540         return ret_val;
24541 }
24542
24543 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) {
24544         LDKChannelConfig this_ptr_conv;
24545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24546         this_ptr_conv.is_owned = false;
24547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24548         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
24549 }
24550
24551 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24552         LDKChannelConfig this_ptr_conv;
24553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24554         this_ptr_conv.is_owned = false;
24555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24556         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
24557         return ret_val;
24558 }
24559
24560 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) {
24561         LDKChannelConfig this_ptr_conv;
24562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24563         this_ptr_conv.is_owned = false;
24564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24565         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
24566 }
24567
24568 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24569         LDKChannelConfig this_ptr_conv;
24570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24571         this_ptr_conv.is_owned = false;
24572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24573         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
24574         return ret_val;
24575 }
24576
24577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
24578         LDKChannelConfig this_ptr_conv;
24579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24580         this_ptr_conv.is_owned = false;
24581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24582         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
24583 }
24584
24585 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
24586         LDKChannelConfig this_ptr_conv;
24587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24588         this_ptr_conv.is_owned = false;
24589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24590         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
24591         return ret_val;
24592 }
24593
24594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24595         LDKChannelConfig this_ptr_conv;
24596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24597         this_ptr_conv.is_owned = false;
24598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24599         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
24600 }
24601
24602 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
24603         LDKChannelConfig this_ptr_conv;
24604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24605         this_ptr_conv.is_owned = false;
24606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24607         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
24608         return ret_val;
24609 }
24610
24611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24612         LDKChannelConfig this_ptr_conv;
24613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24614         this_ptr_conv.is_owned = false;
24615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24616         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
24617 }
24618
24619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24620         LDKChannelConfig this_ptr_conv;
24621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24622         this_ptr_conv.is_owned = false;
24623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24624         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
24625         return ret_val;
24626 }
24627
24628 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) {
24629         LDKChannelConfig this_ptr_conv;
24630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24631         this_ptr_conv.is_owned = false;
24632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24633         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
24634 }
24635
24636 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) {
24637         LDKChannelConfig this_ptr_conv;
24638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24639         this_ptr_conv.is_owned = false;
24640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24641         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
24642         return ret_val;
24643 }
24644
24645 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) {
24646         LDKChannelConfig this_ptr_conv;
24647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24648         this_ptr_conv.is_owned = false;
24649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24650         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
24651 }
24652
24653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
24654         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
24655         int64_t ret_ref = 0;
24656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24659         ret_ref = (uintptr_t)ret_var.inner;
24660         if (ret_var.is_owned) {
24661                 ret_ref |= 1;
24662         }
24663         return ret_ref;
24664 }
24665
24666 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
24667         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
24668 int64_t ret_ref = 0;
24669 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24670 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24671 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24672 ret_ref = (uintptr_t)ret_var.inner;
24673 if (ret_var.is_owned) {
24674         ret_ref |= 1;
24675 }
24676         return ret_ref;
24677 }
24678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24679         LDKChannelConfig arg_conv;
24680         arg_conv.inner = (void*)(arg & (~1));
24681         arg_conv.is_owned = false;
24682         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24683         int64_t ret_val = ChannelConfig_clone_ptr(&arg_conv);
24684         return ret_val;
24685 }
24686
24687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24688         LDKChannelConfig orig_conv;
24689         orig_conv.inner = (void*)(orig & (~1));
24690         orig_conv.is_owned = false;
24691         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24692         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
24693         int64_t ret_ref = 0;
24694         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24695         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24697         ret_ref = (uintptr_t)ret_var.inner;
24698         if (ret_var.is_owned) {
24699                 ret_ref |= 1;
24700         }
24701         return ret_ref;
24702 }
24703
24704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
24705         LDKChannelConfig ret_var = ChannelConfig_default();
24706         int64_t ret_ref = 0;
24707         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24708         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24710         ret_ref = (uintptr_t)ret_var.inner;
24711         if (ret_var.is_owned) {
24712                 ret_ref |= 1;
24713         }
24714         return ret_ref;
24715 }
24716
24717 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
24718         LDKChannelConfig obj_conv;
24719         obj_conv.inner = (void*)(obj & (~1));
24720         obj_conv.is_owned = false;
24721         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24722         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
24723         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24724         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24725         CVec_u8Z_free(ret_var);
24726         return ret_arr;
24727 }
24728
24729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24730         LDKu8slice ser_ref;
24731         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24732         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24733         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
24734         *ret_conv = ChannelConfig_read(ser_ref);
24735         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24736         return (int64_t)ret_conv;
24737 }
24738
24739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24740         LDKUserConfig this_obj_conv;
24741         this_obj_conv.inner = (void*)(this_obj & (~1));
24742         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24744         UserConfig_free(this_obj_conv);
24745 }
24746
24747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
24748         LDKUserConfig this_ptr_conv;
24749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24750         this_ptr_conv.is_owned = false;
24751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24752         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
24753         int64_t ret_ref = 0;
24754         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24755         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24757         ret_ref = (uintptr_t)ret_var.inner;
24758         if (ret_var.is_owned) {
24759                 ret_ref |= 1;
24760         }
24761         return ret_ref;
24762 }
24763
24764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24765         LDKUserConfig 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         LDKChannelHandshakeConfig val_conv;
24770         val_conv.inner = (void*)(val & (~1));
24771         val_conv.is_owned = (val & 1) || (val == 0);
24772         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24773         val_conv = ChannelHandshakeConfig_clone(&val_conv);
24774         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
24775 }
24776
24777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
24778         LDKUserConfig this_ptr_conv;
24779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24780         this_ptr_conv.is_owned = false;
24781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24782         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
24783         int64_t ret_ref = 0;
24784         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24785         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24787         ret_ref = (uintptr_t)ret_var.inner;
24788         if (ret_var.is_owned) {
24789                 ret_ref |= 1;
24790         }
24791         return ret_ref;
24792 }
24793
24794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24795         LDKUserConfig this_ptr_conv;
24796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24797         this_ptr_conv.is_owned = false;
24798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24799         LDKChannelHandshakeLimits val_conv;
24800         val_conv.inner = (void*)(val & (~1));
24801         val_conv.is_owned = (val & 1) || (val == 0);
24802         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24803         val_conv = ChannelHandshakeLimits_clone(&val_conv);
24804         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
24805 }
24806
24807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
24808         LDKUserConfig this_ptr_conv;
24809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24810         this_ptr_conv.is_owned = false;
24811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24812         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
24813         int64_t ret_ref = 0;
24814         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24815         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24817         ret_ref = (uintptr_t)ret_var.inner;
24818         if (ret_var.is_owned) {
24819                 ret_ref |= 1;
24820         }
24821         return ret_ref;
24822 }
24823
24824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24825         LDKUserConfig this_ptr_conv;
24826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24827         this_ptr_conv.is_owned = false;
24828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24829         LDKChannelConfig val_conv;
24830         val_conv.inner = (void*)(val & (~1));
24831         val_conv.is_owned = (val & 1) || (val == 0);
24832         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24833         val_conv = ChannelConfig_clone(&val_conv);
24834         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
24835 }
24836
24837 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
24838         LDKUserConfig this_ptr_conv;
24839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24840         this_ptr_conv.is_owned = false;
24841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24842         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
24843         return ret_val;
24844 }
24845
24846 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) {
24847         LDKUserConfig this_ptr_conv;
24848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24849         this_ptr_conv.is_owned = false;
24850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24851         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
24852 }
24853
24854 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
24855         LDKUserConfig this_ptr_conv;
24856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24857         this_ptr_conv.is_owned = false;
24858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24859         jboolean ret_val = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
24860         return ret_val;
24861 }
24862
24863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24864         LDKUserConfig this_ptr_conv;
24865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24866         this_ptr_conv.is_owned = false;
24867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24868         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
24869 }
24870
24871 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
24872         LDKUserConfig this_ptr_conv;
24873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24874         this_ptr_conv.is_owned = false;
24875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24876         jboolean ret_val = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
24877         return ret_val;
24878 }
24879
24880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24881         LDKUserConfig this_ptr_conv;
24882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24883         this_ptr_conv.is_owned = false;
24884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24885         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
24886 }
24887
24888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t own_channel_config_arg, int64_t peer_channel_config_limits_arg, int64_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg, jboolean manually_accept_inbound_channels_arg) {
24889         LDKChannelHandshakeConfig own_channel_config_arg_conv;
24890         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
24891         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
24892         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
24893         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
24894         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
24895         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
24896         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
24897         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
24898         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
24899         LDKChannelConfig channel_options_arg_conv;
24900         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
24901         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
24902         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
24903         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
24904         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg);
24905         int64_t ret_ref = 0;
24906         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24907         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24909         ret_ref = (uintptr_t)ret_var.inner;
24910         if (ret_var.is_owned) {
24911                 ret_ref |= 1;
24912         }
24913         return ret_ref;
24914 }
24915
24916 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
24917         LDKUserConfig ret_var = UserConfig_clone(arg);
24918 int64_t ret_ref = 0;
24919 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24920 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24921 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24922 ret_ref = (uintptr_t)ret_var.inner;
24923 if (ret_var.is_owned) {
24924         ret_ref |= 1;
24925 }
24926         return ret_ref;
24927 }
24928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24929         LDKUserConfig arg_conv;
24930         arg_conv.inner = (void*)(arg & (~1));
24931         arg_conv.is_owned = false;
24932         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24933         int64_t ret_val = UserConfig_clone_ptr(&arg_conv);
24934         return ret_val;
24935 }
24936
24937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24938         LDKUserConfig orig_conv;
24939         orig_conv.inner = (void*)(orig & (~1));
24940         orig_conv.is_owned = false;
24941         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24942         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
24943         int64_t ret_ref = 0;
24944         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24945         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24947         ret_ref = (uintptr_t)ret_var.inner;
24948         if (ret_var.is_owned) {
24949                 ret_ref |= 1;
24950         }
24951         return ret_ref;
24952 }
24953
24954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
24955         LDKUserConfig ret_var = UserConfig_default();
24956         int64_t ret_ref = 0;
24957         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24958         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24960         ret_ref = (uintptr_t)ret_var.inner;
24961         if (ret_var.is_owned) {
24962                 ret_ref |= 1;
24963         }
24964         return ret_ref;
24965 }
24966
24967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24968         LDKBestBlock this_obj_conv;
24969         this_obj_conv.inner = (void*)(this_obj & (~1));
24970         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24972         BestBlock_free(this_obj_conv);
24973 }
24974
24975 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
24976         LDKBestBlock ret_var = BestBlock_clone(arg);
24977 int64_t ret_ref = 0;
24978 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24979 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24980 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24981 ret_ref = (uintptr_t)ret_var.inner;
24982 if (ret_var.is_owned) {
24983         ret_ref |= 1;
24984 }
24985         return ret_ref;
24986 }
24987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24988         LDKBestBlock arg_conv;
24989         arg_conv.inner = (void*)(arg & (~1));
24990         arg_conv.is_owned = false;
24991         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24992         int64_t ret_val = BestBlock_clone_ptr(&arg_conv);
24993         return ret_val;
24994 }
24995
24996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24997         LDKBestBlock orig_conv;
24998         orig_conv.inner = (void*)(orig & (~1));
24999         orig_conv.is_owned = false;
25000         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25001         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
25002         int64_t ret_ref = 0;
25003         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25004         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25006         ret_ref = (uintptr_t)ret_var.inner;
25007         if (ret_var.is_owned) {
25008                 ret_ref |= 1;
25009         }
25010         return ret_ref;
25011 }
25012
25013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
25014         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
25015         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
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
25027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
25028         LDKThirtyTwoBytes block_hash_ref;
25029         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
25030         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
25031         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
25032         int64_t ret_ref = 0;
25033         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25034         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25035         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25036         ret_ref = (uintptr_t)ret_var.inner;
25037         if (ret_var.is_owned) {
25038                 ret_ref |= 1;
25039         }
25040         return ret_ref;
25041 }
25042
25043 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25044         LDKBestBlock this_arg_conv;
25045         this_arg_conv.inner = (void*)(this_arg & (~1));
25046         this_arg_conv.is_owned = false;
25047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25048         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25049         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
25050         return ret_arr;
25051 }
25052
25053 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
25054         LDKBestBlock this_arg_conv;
25055         this_arg_conv.inner = (void*)(this_arg & (~1));
25056         this_arg_conv.is_owned = false;
25057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25058         int32_t ret_val = BestBlock_height(&this_arg_conv);
25059         return ret_val;
25060 }
25061
25062 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25063         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
25064         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
25065         return ret_conv;
25066 }
25067
25068 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
25069         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
25070         return ret_conv;
25071 }
25072
25073 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
25074         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
25075         return ret_conv;
25076 }
25077
25078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25079         if ((this_ptr & 1) != 0) return;
25080         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25081         CHECK_ACCESS(this_ptr_ptr);
25082         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
25083         FREE((void*)this_ptr);
25084         Access_free(this_ptr_conv);
25085 }
25086
25087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25088         if ((this_ptr & 1) != 0) return;
25089         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25090         CHECK_ACCESS(this_ptr_ptr);
25091         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
25092         FREE((void*)this_ptr);
25093         Listen_free(this_ptr_conv);
25094 }
25095
25096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25097         if ((this_ptr & 1) != 0) return;
25098         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25099         CHECK_ACCESS(this_ptr_ptr);
25100         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
25101         FREE((void*)this_ptr);
25102         Confirm_free(this_ptr_conv);
25103 }
25104
25105 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25106         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
25107         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
25108         return ret_conv;
25109 }
25110
25111 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
25112         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
25113         return ret_conv;
25114 }
25115
25116 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
25117         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
25118         return ret_conv;
25119 }
25120
25121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25122         if ((this_ptr & 1) != 0) return;
25123         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25124         CHECK_ACCESS(this_ptr_ptr);
25125         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
25126         FREE((void*)this_ptr);
25127         Watch_free(this_ptr_conv);
25128 }
25129
25130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25131         if ((this_ptr & 1) != 0) return;
25132         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25133         CHECK_ACCESS(this_ptr_ptr);
25134         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
25135         FREE((void*)this_ptr);
25136         Filter_free(this_ptr_conv);
25137 }
25138
25139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25140         LDKWatchedOutput this_obj_conv;
25141         this_obj_conv.inner = (void*)(this_obj & (~1));
25142         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25144         WatchedOutput_free(this_obj_conv);
25145 }
25146
25147 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
25148         LDKWatchedOutput this_ptr_conv;
25149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25150         this_ptr_conv.is_owned = false;
25151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25152         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25153         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
25154         return ret_arr;
25155 }
25156
25157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25158         LDKWatchedOutput this_ptr_conv;
25159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25160         this_ptr_conv.is_owned = false;
25161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25162         LDKThirtyTwoBytes val_ref;
25163         CHECK((*env)->GetArrayLength(env, val) == 32);
25164         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25165         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
25166 }
25167
25168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
25169         LDKWatchedOutput this_ptr_conv;
25170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25171         this_ptr_conv.is_owned = false;
25172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25173         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
25174         int64_t ret_ref = 0;
25175         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25176         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25178         ret_ref = (uintptr_t)ret_var.inner;
25179         if (ret_var.is_owned) {
25180                 ret_ref |= 1;
25181         }
25182         return ret_ref;
25183 }
25184
25185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25186         LDKWatchedOutput this_ptr_conv;
25187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25188         this_ptr_conv.is_owned = false;
25189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25190         LDKOutPoint val_conv;
25191         val_conv.inner = (void*)(val & (~1));
25192         val_conv.is_owned = (val & 1) || (val == 0);
25193         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25194         val_conv = OutPoint_clone(&val_conv);
25195         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
25196 }
25197
25198 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
25199         LDKWatchedOutput this_ptr_conv;
25200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25201         this_ptr_conv.is_owned = false;
25202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25203         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
25204         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25205         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25206         return ret_arr;
25207 }
25208
25209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25210         LDKWatchedOutput this_ptr_conv;
25211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25212         this_ptr_conv.is_owned = false;
25213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25214         LDKCVec_u8Z val_ref;
25215         val_ref.datalen = (*env)->GetArrayLength(env, val);
25216         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
25217         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
25218         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
25219 }
25220
25221 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) {
25222         LDKThirtyTwoBytes block_hash_arg_ref;
25223         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
25224         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
25225         LDKOutPoint outpoint_arg_conv;
25226         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
25227         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
25228         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
25229         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
25230         LDKCVec_u8Z script_pubkey_arg_ref;
25231         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
25232         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
25233         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
25234         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
25235         int64_t ret_ref = 0;
25236         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25237         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25239         ret_ref = (uintptr_t)ret_var.inner;
25240         if (ret_var.is_owned) {
25241                 ret_ref |= 1;
25242         }
25243         return ret_ref;
25244 }
25245
25246 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
25247         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
25248 int64_t ret_ref = 0;
25249 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25250 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25251 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25252 ret_ref = (uintptr_t)ret_var.inner;
25253 if (ret_var.is_owned) {
25254         ret_ref |= 1;
25255 }
25256         return ret_ref;
25257 }
25258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25259         LDKWatchedOutput arg_conv;
25260         arg_conv.inner = (void*)(arg & (~1));
25261         arg_conv.is_owned = false;
25262         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25263         int64_t ret_val = WatchedOutput_clone_ptr(&arg_conv);
25264         return ret_val;
25265 }
25266
25267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25268         LDKWatchedOutput orig_conv;
25269         orig_conv.inner = (void*)(orig & (~1));
25270         orig_conv.is_owned = false;
25271         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25272         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
25273         int64_t ret_ref = 0;
25274         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25275         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25277         ret_ref = (uintptr_t)ret_var.inner;
25278         if (ret_var.is_owned) {
25279                 ret_ref |= 1;
25280         }
25281         return ret_ref;
25282 }
25283
25284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
25285         LDKWatchedOutput o_conv;
25286         o_conv.inner = (void*)(o & (~1));
25287         o_conv.is_owned = false;
25288         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25289         int64_t ret_val = WatchedOutput_hash(&o_conv);
25290         return ret_val;
25291 }
25292
25293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25294         if ((this_ptr & 1) != 0) return;
25295         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25296         CHECK_ACCESS(this_ptr_ptr);
25297         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
25298         FREE((void*)this_ptr);
25299         BroadcasterInterface_free(this_ptr_conv);
25300 }
25301
25302 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25303         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
25304         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
25305         return ret_conv;
25306 }
25307
25308 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
25309         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
25310         return ret_conv;
25311 }
25312
25313 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
25314         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
25315         return ret_conv;
25316 }
25317
25318 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
25319         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
25320         return ret_conv;
25321 }
25322
25323 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25324         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
25325         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
25326         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
25327         return ret_val;
25328 }
25329
25330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25331         if ((this_ptr & 1) != 0) return;
25332         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25333         CHECK_ACCESS(this_ptr_ptr);
25334         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
25335         FREE((void*)this_ptr);
25336         FeeEstimator_free(this_ptr_conv);
25337 }
25338
25339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25340         LDKMonitorUpdateId this_obj_conv;
25341         this_obj_conv.inner = (void*)(this_obj & (~1));
25342         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25344         MonitorUpdateId_free(this_obj_conv);
25345 }
25346
25347 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
25348         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
25349 int64_t ret_ref = 0;
25350 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25351 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25352 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25353 ret_ref = (uintptr_t)ret_var.inner;
25354 if (ret_var.is_owned) {
25355         ret_ref |= 1;
25356 }
25357         return ret_ref;
25358 }
25359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25360         LDKMonitorUpdateId arg_conv;
25361         arg_conv.inner = (void*)(arg & (~1));
25362         arg_conv.is_owned = false;
25363         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25364         int64_t ret_val = MonitorUpdateId_clone_ptr(&arg_conv);
25365         return ret_val;
25366 }
25367
25368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25369         LDKMonitorUpdateId orig_conv;
25370         orig_conv.inner = (void*)(orig & (~1));
25371         orig_conv.is_owned = false;
25372         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25373         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
25374         int64_t ret_ref = 0;
25375         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25376         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25378         ret_ref = (uintptr_t)ret_var.inner;
25379         if (ret_var.is_owned) {
25380                 ret_ref |= 1;
25381         }
25382         return ret_ref;
25383 }
25384
25385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
25386         LDKMonitorUpdateId o_conv;
25387         o_conv.inner = (void*)(o & (~1));
25388         o_conv.is_owned = false;
25389         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25390         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
25391         return ret_val;
25392 }
25393
25394 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25395         LDKMonitorUpdateId a_conv;
25396         a_conv.inner = (void*)(a & (~1));
25397         a_conv.is_owned = false;
25398         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25399         LDKMonitorUpdateId b_conv;
25400         b_conv.inner = (void*)(b & (~1));
25401         b_conv.is_owned = false;
25402         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
25403         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
25404         return ret_val;
25405 }
25406
25407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25408         if ((this_ptr & 1) != 0) return;
25409         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25410         CHECK_ACCESS(this_ptr_ptr);
25411         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
25412         FREE((void*)this_ptr);
25413         Persist_free(this_ptr_conv);
25414 }
25415
25416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25417         LDKLockedChannelMonitor this_obj_conv;
25418         this_obj_conv.inner = (void*)(this_obj & (~1));
25419         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25421         LockedChannelMonitor_free(this_obj_conv);
25422 }
25423
25424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25425         LDKChainMonitor this_obj_conv;
25426         this_obj_conv.inner = (void*)(this_obj & (~1));
25427         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25429         ChainMonitor_free(this_obj_conv);
25430 }
25431
25432 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) {
25433         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
25434         CHECK_ACCESS(chain_source_ptr);
25435         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
25436         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
25437         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
25438                 // Manually implement clone for Java trait instances
25439                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
25440                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25441                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
25442                 }
25443         }
25444         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
25445         CHECK_ACCESS(broadcaster_ptr);
25446         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
25447         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25448                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25449                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
25450         }
25451         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25452         CHECK_ACCESS(logger_ptr);
25453         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25454         if (logger_conv.free == LDKLogger_JCalls_free) {
25455                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25456                 LDKLogger_JCalls_cloned(&logger_conv);
25457         }
25458         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
25459         CHECK_ACCESS(feeest_ptr);
25460         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
25461         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
25462                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25463                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
25464         }
25465         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
25466         CHECK_ACCESS(persister_ptr);
25467         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
25468         if (persister_conv.free == LDKPersist_JCalls_free) {
25469                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25470                 LDKPersist_JCalls_cloned(&persister_conv);
25471         }
25472         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
25473         int64_t ret_ref = 0;
25474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25477         ret_ref = (uintptr_t)ret_var.inner;
25478         if (ret_var.is_owned) {
25479                 ret_ref |= 1;
25480         }
25481         return ret_ref;
25482 }
25483
25484 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) {
25485         LDKChainMonitor this_arg_conv;
25486         this_arg_conv.inner = (void*)(this_arg & (~1));
25487         this_arg_conv.is_owned = false;
25488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25489         LDKCVec_ChannelDetailsZ ignored_channels_constr;
25490         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
25491         if (ignored_channels_constr.datalen > 0)
25492                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25493         else
25494                 ignored_channels_constr.data = NULL;
25495         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
25496         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
25497                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
25498                 LDKChannelDetails ignored_channels_conv_16_conv;
25499                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
25500                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
25501                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
25502                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
25503                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
25504         }
25505         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
25506         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
25507         int64_tArray ret_arr = NULL;
25508         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25509         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25510         for (size_t j = 0; j < ret_var.datalen; j++) {
25511                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25512                 *ret_conv_9_copy = ret_var.data[j];
25513                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
25514                 ret_arr_ptr[j] = ret_conv_9_ref;
25515         }
25516         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25517         FREE(ret_var.data);
25518         return ret_arr;
25519 }
25520
25521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
25522         LDKChainMonitor this_arg_conv;
25523         this_arg_conv.inner = (void*)(this_arg & (~1));
25524         this_arg_conv.is_owned = false;
25525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25526         LDKOutPoint funding_txo_conv;
25527         funding_txo_conv.inner = (void*)(funding_txo & (~1));
25528         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
25529         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25530         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25531         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
25532         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
25533         return (int64_t)ret_conv;
25534 }
25535
25536 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
25537         LDKChainMonitor this_arg_conv;
25538         this_arg_conv.inner = (void*)(this_arg & (~1));
25539         this_arg_conv.is_owned = false;
25540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25541         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
25542         int64_tArray ret_arr = NULL;
25543         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25544         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25545         for (size_t k = 0; k < ret_var.datalen; k++) {
25546                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
25547                 int64_t ret_conv_10_ref = 0;
25548                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25549                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25550                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
25551                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
25552                 if (ret_conv_10_var.is_owned) {
25553                         ret_conv_10_ref |= 1;
25554                 }
25555                 ret_arr_ptr[k] = ret_conv_10_ref;
25556         }
25557         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25558         FREE(ret_var.data);
25559         return ret_arr;
25560 }
25561
25562 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) {
25563         LDKChainMonitor this_arg_conv;
25564         this_arg_conv.inner = (void*)(this_arg & (~1));
25565         this_arg_conv.is_owned = false;
25566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25567         LDKOutPoint funding_txo_conv;
25568         funding_txo_conv.inner = (void*)(funding_txo & (~1));
25569         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
25570         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25571         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25572         LDKMonitorUpdateId completed_update_id_conv;
25573         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
25574         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
25575         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
25576         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
25577         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25578         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
25579         return (int64_t)ret_conv;
25580 }
25581
25582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
25583         LDKChainMonitor this_arg_conv;
25584         this_arg_conv.inner = (void*)(this_arg & (~1));
25585         this_arg_conv.is_owned = false;
25586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25587         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
25588         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
25589         return (int64_t)ret_ret;
25590 }
25591
25592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
25593         LDKChainMonitor this_arg_conv;
25594         this_arg_conv.inner = (void*)(this_arg & (~1));
25595         this_arg_conv.is_owned = false;
25596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25597         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
25598         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
25599         return (int64_t)ret_ret;
25600 }
25601
25602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
25603         LDKChainMonitor this_arg_conv;
25604         this_arg_conv.inner = (void*)(this_arg & (~1));
25605         this_arg_conv.is_owned = false;
25606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25607         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
25608         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
25609         return (int64_t)ret_ret;
25610 }
25611
25612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
25613         LDKChainMonitor this_arg_conv;
25614         this_arg_conv.inner = (void*)(this_arg & (~1));
25615         this_arg_conv.is_owned = false;
25616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25617         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
25618         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
25619         return (int64_t)ret_ret;
25620 }
25621
25622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25623         LDKChannelMonitorUpdate this_obj_conv;
25624         this_obj_conv.inner = (void*)(this_obj & (~1));
25625         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25627         ChannelMonitorUpdate_free(this_obj_conv);
25628 }
25629
25630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
25631         LDKChannelMonitorUpdate this_ptr_conv;
25632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25633         this_ptr_conv.is_owned = false;
25634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25635         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
25636         return ret_val;
25637 }
25638
25639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25640         LDKChannelMonitorUpdate this_ptr_conv;
25641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25642         this_ptr_conv.is_owned = false;
25643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25644         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
25645 }
25646
25647 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
25648         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
25649 int64_t ret_ref = 0;
25650 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25651 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25652 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25653 ret_ref = (uintptr_t)ret_var.inner;
25654 if (ret_var.is_owned) {
25655         ret_ref |= 1;
25656 }
25657         return ret_ref;
25658 }
25659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25660         LDKChannelMonitorUpdate arg_conv;
25661         arg_conv.inner = (void*)(arg & (~1));
25662         arg_conv.is_owned = false;
25663         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25664         int64_t ret_val = ChannelMonitorUpdate_clone_ptr(&arg_conv);
25665         return ret_val;
25666 }
25667
25668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25669         LDKChannelMonitorUpdate orig_conv;
25670         orig_conv.inner = (void*)(orig & (~1));
25671         orig_conv.is_owned = false;
25672         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25673         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
25674         int64_t ret_ref = 0;
25675         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25676         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25678         ret_ref = (uintptr_t)ret_var.inner;
25679         if (ret_var.is_owned) {
25680                 ret_ref |= 1;
25681         }
25682         return ret_ref;
25683 }
25684
25685 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
25686         LDKChannelMonitorUpdate obj_conv;
25687         obj_conv.inner = (void*)(obj & (~1));
25688         obj_conv.is_owned = false;
25689         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25690         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
25691         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25692         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25693         CVec_u8Z_free(ret_var);
25694         return ret_arr;
25695 }
25696
25697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25698         LDKu8slice ser_ref;
25699         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25700         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25701         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
25702         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
25703         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25704         return (int64_t)ret_conv;
25705 }
25706
25707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25708         if ((this_ptr & 1) != 0) return;
25709         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25710         CHECK_ACCESS(this_ptr_ptr);
25711         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
25712         FREE((void*)this_ptr);
25713         MonitorEvent_free(this_ptr_conv);
25714 }
25715
25716 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
25717         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25718         *ret_copy = MonitorEvent_clone(arg);
25719 int64_t ret_ref = (uintptr_t)ret_copy;
25720         return ret_ref;
25721 }
25722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25723         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
25724         int64_t ret_val = MonitorEvent_clone_ptr(arg_conv);
25725         return ret_val;
25726 }
25727
25728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25729         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
25730         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25731         *ret_copy = MonitorEvent_clone(orig_conv);
25732         int64_t ret_ref = (uintptr_t)ret_copy;
25733         return ret_ref;
25734 }
25735
25736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
25737         LDKHTLCUpdate a_conv;
25738         a_conv.inner = (void*)(a & (~1));
25739         a_conv.is_owned = (a & 1) || (a == 0);
25740         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25741         a_conv = HTLCUpdate_clone(&a_conv);
25742         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25743         *ret_copy = MonitorEvent_htlcevent(a_conv);
25744         int64_t ret_ref = (uintptr_t)ret_copy;
25745         return ret_ref;
25746 }
25747
25748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
25749         LDKOutPoint a_conv;
25750         a_conv.inner = (void*)(a & (~1));
25751         a_conv.is_owned = (a & 1) || (a == 0);
25752         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25753         a_conv = OutPoint_clone(&a_conv);
25754         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25755         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
25756         int64_t ret_ref = (uintptr_t)ret_copy;
25757         return ret_ref;
25758 }
25759
25760 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) {
25761         LDKOutPoint funding_txo_conv;
25762         funding_txo_conv.inner = (void*)(funding_txo & (~1));
25763         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
25764         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25765         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25766         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25767         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
25768         int64_t ret_ref = (uintptr_t)ret_copy;
25769         return ret_ref;
25770 }
25771
25772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
25773         LDKOutPoint a_conv;
25774         a_conv.inner = (void*)(a & (~1));
25775         a_conv.is_owned = (a & 1) || (a == 0);
25776         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25777         a_conv = OutPoint_clone(&a_conv);
25778         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25779         *ret_copy = MonitorEvent_update_failed(a_conv);
25780         int64_t ret_ref = (uintptr_t)ret_copy;
25781         return ret_ref;
25782 }
25783
25784 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
25785         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
25786         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
25787         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25788         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25789         CVec_u8Z_free(ret_var);
25790         return ret_arr;
25791 }
25792
25793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25794         LDKu8slice ser_ref;
25795         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25796         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25797         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
25798         *ret_conv = MonitorEvent_read(ser_ref);
25799         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25800         return (int64_t)ret_conv;
25801 }
25802
25803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25804         LDKHTLCUpdate this_obj_conv;
25805         this_obj_conv.inner = (void*)(this_obj & (~1));
25806         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25808         HTLCUpdate_free(this_obj_conv);
25809 }
25810
25811 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
25812         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
25813 int64_t ret_ref = 0;
25814 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25815 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25816 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25817 ret_ref = (uintptr_t)ret_var.inner;
25818 if (ret_var.is_owned) {
25819         ret_ref |= 1;
25820 }
25821         return ret_ref;
25822 }
25823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25824         LDKHTLCUpdate arg_conv;
25825         arg_conv.inner = (void*)(arg & (~1));
25826         arg_conv.is_owned = false;
25827         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25828         int64_t ret_val = HTLCUpdate_clone_ptr(&arg_conv);
25829         return ret_val;
25830 }
25831
25832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25833         LDKHTLCUpdate orig_conv;
25834         orig_conv.inner = (void*)(orig & (~1));
25835         orig_conv.is_owned = false;
25836         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25837         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
25838         int64_t ret_ref = 0;
25839         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25840         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25841         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25842         ret_ref = (uintptr_t)ret_var.inner;
25843         if (ret_var.is_owned) {
25844                 ret_ref |= 1;
25845         }
25846         return ret_ref;
25847 }
25848
25849 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
25850         LDKHTLCUpdate obj_conv;
25851         obj_conv.inner = (void*)(obj & (~1));
25852         obj_conv.is_owned = false;
25853         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25854         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
25855         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25856         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25857         CVec_u8Z_free(ret_var);
25858         return ret_arr;
25859 }
25860
25861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25862         LDKu8slice ser_ref;
25863         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25864         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25865         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
25866         *ret_conv = HTLCUpdate_read(ser_ref);
25867         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25868         return (int64_t)ret_conv;
25869 }
25870
25871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25872         if ((this_ptr & 1) != 0) return;
25873         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25874         CHECK_ACCESS(this_ptr_ptr);
25875         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
25876         FREE((void*)this_ptr);
25877         Balance_free(this_ptr_conv);
25878 }
25879
25880 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
25881         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25882         *ret_copy = Balance_clone(arg);
25883 int64_t ret_ref = (uintptr_t)ret_copy;
25884         return ret_ref;
25885 }
25886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25887         LDKBalance* arg_conv = (LDKBalance*)arg;
25888         int64_t ret_val = Balance_clone_ptr(arg_conv);
25889         return ret_val;
25890 }
25891
25892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25893         LDKBalance* orig_conv = (LDKBalance*)orig;
25894         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25895         *ret_copy = Balance_clone(orig_conv);
25896         int64_t ret_ref = (uintptr_t)ret_copy;
25897         return ret_ref;
25898 }
25899
25900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
25901         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25902         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
25903         int64_t ret_ref = (uintptr_t)ret_copy;
25904         return ret_ref;
25905 }
25906
25907 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) {
25908         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25909         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
25910         int64_t ret_ref = (uintptr_t)ret_copy;
25911         return ret_ref;
25912 }
25913
25914 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) {
25915         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25916         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
25917         int64_t ret_ref = (uintptr_t)ret_copy;
25918         return ret_ref;
25919 }
25920
25921 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) {
25922         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25923         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
25924         int64_t ret_ref = (uintptr_t)ret_copy;
25925         return ret_ref;
25926 }
25927
25928 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25929         LDKBalance* a_conv = (LDKBalance*)a;
25930         LDKBalance* b_conv = (LDKBalance*)b;
25931         jboolean ret_val = Balance_eq(a_conv, b_conv);
25932         return ret_val;
25933 }
25934
25935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25936         LDKChannelMonitor this_obj_conv;
25937         this_obj_conv.inner = (void*)(this_obj & (~1));
25938         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25940         ChannelMonitor_free(this_obj_conv);
25941 }
25942
25943 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
25944         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
25945 int64_t ret_ref = 0;
25946 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25947 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25948 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25949 ret_ref = (uintptr_t)ret_var.inner;
25950 if (ret_var.is_owned) {
25951         ret_ref |= 1;
25952 }
25953         return ret_ref;
25954 }
25955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25956         LDKChannelMonitor arg_conv;
25957         arg_conv.inner = (void*)(arg & (~1));
25958         arg_conv.is_owned = false;
25959         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25960         int64_t ret_val = ChannelMonitor_clone_ptr(&arg_conv);
25961         return ret_val;
25962 }
25963
25964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25965         LDKChannelMonitor orig_conv;
25966         orig_conv.inner = (void*)(orig & (~1));
25967         orig_conv.is_owned = false;
25968         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25969         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
25970         int64_t ret_ref = 0;
25971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25974         ret_ref = (uintptr_t)ret_var.inner;
25975         if (ret_var.is_owned) {
25976                 ret_ref |= 1;
25977         }
25978         return ret_ref;
25979 }
25980
25981 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
25982         LDKChannelMonitor obj_conv;
25983         obj_conv.inner = (void*)(obj & (~1));
25984         obj_conv.is_owned = false;
25985         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25986         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
25987         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25988         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25989         CVec_u8Z_free(ret_var);
25990         return ret_arr;
25991 }
25992
25993 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) {
25994         LDKChannelMonitor this_arg_conv;
25995         this_arg_conv.inner = (void*)(this_arg & (~1));
25996         this_arg_conv.is_owned = false;
25997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25998         LDKChannelMonitorUpdate updates_conv;
25999         updates_conv.inner = (void*)(updates & (~1));
26000         updates_conv.is_owned = false;
26001         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
26002         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26003         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
26004         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
26005         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26006         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
26007         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
26008         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26009         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
26010         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
26011         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
26012         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
26013         return (int64_t)ret_conv;
26014 }
26015
26016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
26017         LDKChannelMonitor this_arg_conv;
26018         this_arg_conv.inner = (void*)(this_arg & (~1));
26019         this_arg_conv.is_owned = false;
26020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26021         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
26022         return ret_val;
26023 }
26024
26025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
26026         LDKChannelMonitor this_arg_conv;
26027         this_arg_conv.inner = (void*)(this_arg & (~1));
26028         this_arg_conv.is_owned = false;
26029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26030         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
26031         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
26032         return ((int64_t)ret_conv);
26033 }
26034
26035 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
26036         LDKChannelMonitor this_arg_conv;
26037         this_arg_conv.inner = (void*)(this_arg & (~1));
26038         this_arg_conv.is_owned = false;
26039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26040         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
26041         int64_tArray ret_arr = NULL;
26042         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26043         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26044         for (size_t o = 0; o < ret_var.datalen; o++) {
26045                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
26046                 *ret_conv_40_conv = ret_var.data[o];
26047                 ret_arr_ptr[o] = ((int64_t)ret_conv_40_conv);
26048         }
26049         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26050         FREE(ret_var.data);
26051         return ret_arr;
26052 }
26053
26054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
26055         LDKChannelMonitor this_arg_conv;
26056         this_arg_conv.inner = (void*)(this_arg & (~1));
26057         this_arg_conv.is_owned = false;
26058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26059         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
26060         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
26061         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
26062         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
26063 }
26064
26065 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
26066         LDKChannelMonitor this_arg_conv;
26067         this_arg_conv.inner = (void*)(this_arg & (~1));
26068         this_arg_conv.is_owned = false;
26069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26070         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
26071         int64_tArray ret_arr = NULL;
26072         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26073         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26074         for (size_t o = 0; o < ret_var.datalen; o++) {
26075                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26076                 *ret_conv_14_copy = ret_var.data[o];
26077                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
26078                 ret_arr_ptr[o] = ret_conv_14_ref;
26079         }
26080         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26081         FREE(ret_var.data);
26082         return ret_arr;
26083 }
26084
26085 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
26086         LDKChannelMonitor this_arg_conv;
26087         this_arg_conv.inner = (void*)(this_arg & (~1));
26088         this_arg_conv.is_owned = false;
26089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26090         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
26091         int64_tArray ret_arr = NULL;
26092         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26093         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26094         for (size_t h = 0; h < ret_var.datalen; h++) {
26095                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26096                 *ret_conv_7_copy = ret_var.data[h];
26097                 int64_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
26098                 ret_arr_ptr[h] = ret_conv_7_ref;
26099         }
26100         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26101         FREE(ret_var.data);
26102         return ret_arr;
26103 }
26104
26105 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) {
26106         LDKChannelMonitor this_arg_conv;
26107         this_arg_conv.inner = (void*)(this_arg & (~1));
26108         this_arg_conv.is_owned = false;
26109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26110         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26111         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
26112         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
26113         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
26114         jobjectArray ret_arr = NULL;
26115         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
26116         ;
26117         for (size_t i = 0; i < ret_var.datalen; i++) {
26118                 LDKTransaction ret_conv_8_var = ret_var.data[i];
26119                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
26120                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
26121                 Transaction_free(ret_conv_8_var);
26122                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
26123         }
26124         
26125         FREE(ret_var.data);
26126         return ret_arr;
26127 }
26128
26129 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) {
26130         LDKChannelMonitor this_arg_conv;
26131         this_arg_conv.inner = (void*)(this_arg & (~1));
26132         this_arg_conv.is_owned = false;
26133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26134         unsigned char header_arr[80];
26135         CHECK((*env)->GetArrayLength(env, header) == 80);
26136         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26137         unsigned char (*header_ref)[80] = &header_arr;
26138         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
26139         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
26140         if (txdata_constr.datalen > 0)
26141                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
26142         else
26143                 txdata_constr.data = NULL;
26144         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
26145         for (size_t c = 0; c < txdata_constr.datalen; c++) {
26146                 int64_t txdata_conv_28 = txdata_vals[c];
26147                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
26148                 CHECK_ACCESS(txdata_conv_28_ptr);
26149                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
26150                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
26151                 txdata_constr.data[c] = txdata_conv_28_conv;
26152         }
26153         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
26154         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26155         CHECK_ACCESS(broadcaster_ptr);
26156         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26157         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26158                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26159                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26160         }
26161         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26162         CHECK_ACCESS(fee_estimator_ptr);
26163         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26164         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26165                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26166                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26167         }
26168         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26169         CHECK_ACCESS(logger_ptr);
26170         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26171         if (logger_conv.free == LDKLogger_JCalls_free) {
26172                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26173                 LDKLogger_JCalls_cloned(&logger_conv);
26174         }
26175         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);
26176         int64_tArray ret_arr = NULL;
26177         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26178         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26179         for (size_t n = 0; n < ret_var.datalen; n++) {
26180                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
26181                 *ret_conv_39_conv = ret_var.data[n];
26182                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
26183         }
26184         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26185         FREE(ret_var.data);
26186         return ret_arr;
26187 }
26188
26189 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) {
26190         LDKChannelMonitor this_arg_conv;
26191         this_arg_conv.inner = (void*)(this_arg & (~1));
26192         this_arg_conv.is_owned = false;
26193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26194         unsigned char header_arr[80];
26195         CHECK((*env)->GetArrayLength(env, header) == 80);
26196         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26197         unsigned char (*header_ref)[80] = &header_arr;
26198         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26199         CHECK_ACCESS(broadcaster_ptr);
26200         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26201         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26202                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26203                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26204         }
26205         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26206         CHECK_ACCESS(fee_estimator_ptr);
26207         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26208         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26209                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26210                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26211         }
26212         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26213         CHECK_ACCESS(logger_ptr);
26214         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26215         if (logger_conv.free == LDKLogger_JCalls_free) {
26216                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26217                 LDKLogger_JCalls_cloned(&logger_conv);
26218         }
26219         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
26220 }
26221
26222 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) {
26223         LDKChannelMonitor this_arg_conv;
26224         this_arg_conv.inner = (void*)(this_arg & (~1));
26225         this_arg_conv.is_owned = false;
26226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26227         unsigned char header_arr[80];
26228         CHECK((*env)->GetArrayLength(env, header) == 80);
26229         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26230         unsigned char (*header_ref)[80] = &header_arr;
26231         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
26232         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
26233         if (txdata_constr.datalen > 0)
26234                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
26235         else
26236                 txdata_constr.data = NULL;
26237         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
26238         for (size_t c = 0; c < txdata_constr.datalen; c++) {
26239                 int64_t txdata_conv_28 = txdata_vals[c];
26240                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
26241                 CHECK_ACCESS(txdata_conv_28_ptr);
26242                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
26243                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
26244                 txdata_constr.data[c] = txdata_conv_28_conv;
26245         }
26246         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
26247         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26248         CHECK_ACCESS(broadcaster_ptr);
26249         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26250         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26251                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26252                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26253         }
26254         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26255         CHECK_ACCESS(fee_estimator_ptr);
26256         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26257         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26258                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26259                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26260         }
26261         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26262         CHECK_ACCESS(logger_ptr);
26263         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26264         if (logger_conv.free == LDKLogger_JCalls_free) {
26265                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26266                 LDKLogger_JCalls_cloned(&logger_conv);
26267         }
26268         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);
26269         int64_tArray ret_arr = NULL;
26270         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26271         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26272         for (size_t n = 0; n < ret_var.datalen; n++) {
26273                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
26274                 *ret_conv_39_conv = ret_var.data[n];
26275                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
26276         }
26277         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26278         FREE(ret_var.data);
26279         return ret_arr;
26280 }
26281
26282 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) {
26283         LDKChannelMonitor this_arg_conv;
26284         this_arg_conv.inner = (void*)(this_arg & (~1));
26285         this_arg_conv.is_owned = false;
26286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26287         unsigned char txid_arr[32];
26288         CHECK((*env)->GetArrayLength(env, txid) == 32);
26289         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
26290         unsigned char (*txid_ref)[32] = &txid_arr;
26291         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26292         CHECK_ACCESS(broadcaster_ptr);
26293         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26294         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26295                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26296                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26297         }
26298         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26299         CHECK_ACCESS(fee_estimator_ptr);
26300         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26301         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26302                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26303                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26304         }
26305         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26306         CHECK_ACCESS(logger_ptr);
26307         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26308         if (logger_conv.free == LDKLogger_JCalls_free) {
26309                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26310                 LDKLogger_JCalls_cloned(&logger_conv);
26311         }
26312         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
26313 }
26314
26315 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) {
26316         LDKChannelMonitor this_arg_conv;
26317         this_arg_conv.inner = (void*)(this_arg & (~1));
26318         this_arg_conv.is_owned = false;
26319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26320         unsigned char header_arr[80];
26321         CHECK((*env)->GetArrayLength(env, header) == 80);
26322         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26323         unsigned char (*header_ref)[80] = &header_arr;
26324         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26325         CHECK_ACCESS(broadcaster_ptr);
26326         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26327         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26328                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26329                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26330         }
26331         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26332         CHECK_ACCESS(fee_estimator_ptr);
26333         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26334         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26335                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26336                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26337         }
26338         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26339         CHECK_ACCESS(logger_ptr);
26340         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26341         if (logger_conv.free == LDKLogger_JCalls_free) {
26342                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26343                 LDKLogger_JCalls_cloned(&logger_conv);
26344         }
26345         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
26346         int64_tArray ret_arr = NULL;
26347         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26348         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26349         for (size_t n = 0; n < ret_var.datalen; n++) {
26350                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
26351                 *ret_conv_39_conv = ret_var.data[n];
26352                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
26353         }
26354         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26355         FREE(ret_var.data);
26356         return ret_arr;
26357 }
26358
26359 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
26360         LDKChannelMonitor this_arg_conv;
26361         this_arg_conv.inner = (void*)(this_arg & (~1));
26362         this_arg_conv.is_owned = false;
26363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26364         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
26365         jobjectArray ret_arr = NULL;
26366         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
26367         ;
26368         for (size_t i = 0; i < ret_var.datalen; i++) {
26369                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
26370                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
26371                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
26372         }
26373         
26374         FREE(ret_var.data);
26375         return ret_arr;
26376 }
26377
26378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
26379         LDKChannelMonitor this_arg_conv;
26380         this_arg_conv.inner = (void*)(this_arg & (~1));
26381         this_arg_conv.is_owned = false;
26382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26383         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
26384         int64_t ret_ref = 0;
26385         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26386         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26388         ret_ref = (uintptr_t)ret_var.inner;
26389         if (ret_var.is_owned) {
26390                 ret_ref |= 1;
26391         }
26392         return ret_ref;
26393 }
26394
26395 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
26396         LDKChannelMonitor this_arg_conv;
26397         this_arg_conv.inner = (void*)(this_arg & (~1));
26398         this_arg_conv.is_owned = false;
26399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26400         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
26401         int64_tArray ret_arr = NULL;
26402         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26403         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26404         for (size_t j = 0; j < ret_var.datalen; j++) {
26405                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26406                 *ret_conv_9_copy = ret_var.data[j];
26407                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
26408                 ret_arr_ptr[j] = ret_conv_9_ref;
26409         }
26410         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26411         FREE(ret_var.data);
26412         return ret_arr;
26413 }
26414
26415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
26416         LDKu8slice ser_ref;
26417         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26418         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26419         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
26420         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
26421         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
26422         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
26423         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
26424         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26425         return (int64_t)ret_conv;
26426 }
26427
26428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26429         LDKOutPoint this_obj_conv;
26430         this_obj_conv.inner = (void*)(this_obj & (~1));
26431         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26433         OutPoint_free(this_obj_conv);
26434 }
26435
26436 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
26437         LDKOutPoint this_ptr_conv;
26438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26439         this_ptr_conv.is_owned = false;
26440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26441         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26442         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
26443         return ret_arr;
26444 }
26445
26446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26447         LDKOutPoint this_ptr_conv;
26448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26449         this_ptr_conv.is_owned = false;
26450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26451         LDKThirtyTwoBytes val_ref;
26452         CHECK((*env)->GetArrayLength(env, val) == 32);
26453         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26454         OutPoint_set_txid(&this_ptr_conv, val_ref);
26455 }
26456
26457 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
26458         LDKOutPoint this_ptr_conv;
26459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26460         this_ptr_conv.is_owned = false;
26461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26462         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
26463         return ret_val;
26464 }
26465
26466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26467         LDKOutPoint this_ptr_conv;
26468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26469         this_ptr_conv.is_owned = false;
26470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26471         OutPoint_set_index(&this_ptr_conv, val);
26472 }
26473
26474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
26475         LDKThirtyTwoBytes txid_arg_ref;
26476         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
26477         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
26478         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
26479         int64_t ret_ref = 0;
26480         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26481         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26483         ret_ref = (uintptr_t)ret_var.inner;
26484         if (ret_var.is_owned) {
26485                 ret_ref |= 1;
26486         }
26487         return ret_ref;
26488 }
26489
26490 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
26491         LDKOutPoint ret_var = OutPoint_clone(arg);
26492 int64_t ret_ref = 0;
26493 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26494 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26495 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26496 ret_ref = (uintptr_t)ret_var.inner;
26497 if (ret_var.is_owned) {
26498         ret_ref |= 1;
26499 }
26500         return ret_ref;
26501 }
26502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26503         LDKOutPoint arg_conv;
26504         arg_conv.inner = (void*)(arg & (~1));
26505         arg_conv.is_owned = false;
26506         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26507         int64_t ret_val = OutPoint_clone_ptr(&arg_conv);
26508         return ret_val;
26509 }
26510
26511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26512         LDKOutPoint orig_conv;
26513         orig_conv.inner = (void*)(orig & (~1));
26514         orig_conv.is_owned = false;
26515         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26516         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
26517         int64_t ret_ref = 0;
26518         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26519         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26521         ret_ref = (uintptr_t)ret_var.inner;
26522         if (ret_var.is_owned) {
26523                 ret_ref |= 1;
26524         }
26525         return ret_ref;
26526 }
26527
26528 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26529         LDKOutPoint a_conv;
26530         a_conv.inner = (void*)(a & (~1));
26531         a_conv.is_owned = false;
26532         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26533         LDKOutPoint b_conv;
26534         b_conv.inner = (void*)(b & (~1));
26535         b_conv.is_owned = false;
26536         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
26537         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
26538         return ret_val;
26539 }
26540
26541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
26542         LDKOutPoint o_conv;
26543         o_conv.inner = (void*)(o & (~1));
26544         o_conv.is_owned = false;
26545         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26546         int64_t ret_val = OutPoint_hash(&o_conv);
26547         return ret_val;
26548 }
26549
26550 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
26551         LDKOutPoint this_arg_conv;
26552         this_arg_conv.inner = (void*)(this_arg & (~1));
26553         this_arg_conv.is_owned = false;
26554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26555         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26556         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
26557         return ret_arr;
26558 }
26559
26560 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
26561         LDKOutPoint obj_conv;
26562         obj_conv.inner = (void*)(obj & (~1));
26563         obj_conv.is_owned = false;
26564         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26565         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
26566         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26567         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26568         CVec_u8Z_free(ret_var);
26569         return ret_arr;
26570 }
26571
26572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26573         LDKu8slice ser_ref;
26574         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26575         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26576         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
26577         *ret_conv = OutPoint_read(ser_ref);
26578         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26579         return (int64_t)ret_conv;
26580 }
26581
26582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26583         LDKDelayedPaymentOutputDescriptor this_obj_conv;
26584         this_obj_conv.inner = (void*)(this_obj & (~1));
26585         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26587         DelayedPaymentOutputDescriptor_free(this_obj_conv);
26588 }
26589
26590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26591         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26593         this_ptr_conv.is_owned = false;
26594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26595         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
26596         int64_t ret_ref = 0;
26597         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26598         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26600         ret_ref = (uintptr_t)ret_var.inner;
26601         if (ret_var.is_owned) {
26602                 ret_ref |= 1;
26603         }
26604         return ret_ref;
26605 }
26606
26607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26608         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26610         this_ptr_conv.is_owned = false;
26611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26612         LDKOutPoint val_conv;
26613         val_conv.inner = (void*)(val & (~1));
26614         val_conv.is_owned = (val & 1) || (val == 0);
26615         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26616         val_conv = OutPoint_clone(&val_conv);
26617         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
26618 }
26619
26620 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
26621         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26623         this_ptr_conv.is_owned = false;
26624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26625         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26626         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
26627         return ret_arr;
26628 }
26629
26630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26631         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26633         this_ptr_conv.is_owned = false;
26634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26635         LDKPublicKey val_ref;
26636         CHECK((*env)->GetArrayLength(env, val) == 33);
26637         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26638         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
26639 }
26640
26641 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26642         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26644         this_ptr_conv.is_owned = false;
26645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26646         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
26647         return ret_val;
26648 }
26649
26650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26651         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26653         this_ptr_conv.is_owned = false;
26654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26655         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
26656 }
26657
26658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26659         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26661         this_ptr_conv.is_owned = false;
26662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26663         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26664         CHECK_ACCESS(val_ptr);
26665         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
26666         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
26667         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
26668 }
26669
26670 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26671         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26673         this_ptr_conv.is_owned = false;
26674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26675         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26676         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
26677         return ret_arr;
26678 }
26679
26680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26681         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26683         this_ptr_conv.is_owned = false;
26684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26685         LDKPublicKey val_ref;
26686         CHECK((*env)->GetArrayLength(env, val) == 33);
26687         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26688         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
26689 }
26690
26691 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26692         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26694         this_ptr_conv.is_owned = false;
26695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26696         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26697         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
26698         return ret_arr;
26699 }
26700
26701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26702         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26704         this_ptr_conv.is_owned = false;
26705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26706         LDKThirtyTwoBytes val_ref;
26707         CHECK((*env)->GetArrayLength(env, val) == 32);
26708         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26709         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
26710 }
26711
26712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26713         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26715         this_ptr_conv.is_owned = false;
26716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26717         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
26718         return ret_val;
26719 }
26720
26721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26722         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26724         this_ptr_conv.is_owned = false;
26725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26726         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
26727 }
26728
26729 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) {
26730         LDKOutPoint outpoint_arg_conv;
26731         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
26732         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
26733         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
26734         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
26735         LDKPublicKey per_commitment_point_arg_ref;
26736         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
26737         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
26738         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
26739         CHECK_ACCESS(output_arg_ptr);
26740         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
26741         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
26742         LDKPublicKey revocation_pubkey_arg_ref;
26743         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
26744         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
26745         LDKThirtyTwoBytes channel_keys_id_arg_ref;
26746         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
26747         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
26748         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);
26749         int64_t ret_ref = 0;
26750         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26751         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26753         ret_ref = (uintptr_t)ret_var.inner;
26754         if (ret_var.is_owned) {
26755                 ret_ref |= 1;
26756         }
26757         return ret_ref;
26758 }
26759
26760 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
26761         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
26762 int64_t ret_ref = 0;
26763 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26764 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26765 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26766 ret_ref = (uintptr_t)ret_var.inner;
26767 if (ret_var.is_owned) {
26768         ret_ref |= 1;
26769 }
26770         return ret_ref;
26771 }
26772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26773         LDKDelayedPaymentOutputDescriptor arg_conv;
26774         arg_conv.inner = (void*)(arg & (~1));
26775         arg_conv.is_owned = false;
26776         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26777         int64_t ret_val = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
26778         return ret_val;
26779 }
26780
26781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26782         LDKDelayedPaymentOutputDescriptor orig_conv;
26783         orig_conv.inner = (void*)(orig & (~1));
26784         orig_conv.is_owned = false;
26785         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26786         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
26787         int64_t ret_ref = 0;
26788         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26789         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26791         ret_ref = (uintptr_t)ret_var.inner;
26792         if (ret_var.is_owned) {
26793                 ret_ref |= 1;
26794         }
26795         return ret_ref;
26796 }
26797
26798 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
26799         LDKDelayedPaymentOutputDescriptor obj_conv;
26800         obj_conv.inner = (void*)(obj & (~1));
26801         obj_conv.is_owned = false;
26802         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26803         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
26804         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26805         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26806         CVec_u8Z_free(ret_var);
26807         return ret_arr;
26808 }
26809
26810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26811         LDKu8slice ser_ref;
26812         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26813         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26814         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
26815         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
26816         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26817         return (int64_t)ret_conv;
26818 }
26819
26820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26821         LDKStaticPaymentOutputDescriptor this_obj_conv;
26822         this_obj_conv.inner = (void*)(this_obj & (~1));
26823         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26825         StaticPaymentOutputDescriptor_free(this_obj_conv);
26826 }
26827
26828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26829         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26831         this_ptr_conv.is_owned = false;
26832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26833         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
26834         int64_t ret_ref = 0;
26835         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26836         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26838         ret_ref = (uintptr_t)ret_var.inner;
26839         if (ret_var.is_owned) {
26840                 ret_ref |= 1;
26841         }
26842         return ret_ref;
26843 }
26844
26845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26846         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26848         this_ptr_conv.is_owned = false;
26849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26850         LDKOutPoint val_conv;
26851         val_conv.inner = (void*)(val & (~1));
26852         val_conv.is_owned = (val & 1) || (val == 0);
26853         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26854         val_conv = OutPoint_clone(&val_conv);
26855         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
26856 }
26857
26858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26859         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26861         this_ptr_conv.is_owned = false;
26862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26863         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26864         CHECK_ACCESS(val_ptr);
26865         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
26866         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
26867         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
26868 }
26869
26870 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26871         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26873         this_ptr_conv.is_owned = false;
26874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26875         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26876         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
26877         return ret_arr;
26878 }
26879
26880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26881         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26883         this_ptr_conv.is_owned = false;
26884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26885         LDKThirtyTwoBytes val_ref;
26886         CHECK((*env)->GetArrayLength(env, val) == 32);
26887         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26888         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
26889 }
26890
26891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26892         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26894         this_ptr_conv.is_owned = false;
26895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26896         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
26897         return ret_val;
26898 }
26899
26900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26901         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26903         this_ptr_conv.is_owned = false;
26904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26905         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
26906 }
26907
26908 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) {
26909         LDKOutPoint outpoint_arg_conv;
26910         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
26911         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
26912         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
26913         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
26914         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
26915         CHECK_ACCESS(output_arg_ptr);
26916         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
26917         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
26918         LDKThirtyTwoBytes channel_keys_id_arg_ref;
26919         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
26920         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
26921         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
26922         int64_t ret_ref = 0;
26923         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26924         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26926         ret_ref = (uintptr_t)ret_var.inner;
26927         if (ret_var.is_owned) {
26928                 ret_ref |= 1;
26929         }
26930         return ret_ref;
26931 }
26932
26933 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
26934         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
26935 int64_t ret_ref = 0;
26936 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26937 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26938 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26939 ret_ref = (uintptr_t)ret_var.inner;
26940 if (ret_var.is_owned) {
26941         ret_ref |= 1;
26942 }
26943         return ret_ref;
26944 }
26945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26946         LDKStaticPaymentOutputDescriptor arg_conv;
26947         arg_conv.inner = (void*)(arg & (~1));
26948         arg_conv.is_owned = false;
26949         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26950         int64_t ret_val = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
26951         return ret_val;
26952 }
26953
26954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26955         LDKStaticPaymentOutputDescriptor orig_conv;
26956         orig_conv.inner = (void*)(orig & (~1));
26957         orig_conv.is_owned = false;
26958         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26959         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
26960         int64_t ret_ref = 0;
26961         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26962         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26964         ret_ref = (uintptr_t)ret_var.inner;
26965         if (ret_var.is_owned) {
26966                 ret_ref |= 1;
26967         }
26968         return ret_ref;
26969 }
26970
26971 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
26972         LDKStaticPaymentOutputDescriptor obj_conv;
26973         obj_conv.inner = (void*)(obj & (~1));
26974         obj_conv.is_owned = false;
26975         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26976         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
26977         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26978         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26979         CVec_u8Z_free(ret_var);
26980         return ret_arr;
26981 }
26982
26983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26984         LDKu8slice ser_ref;
26985         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26986         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26987         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
26988         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
26989         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26990         return (int64_t)ret_conv;
26991 }
26992
26993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26994         if ((this_ptr & 1) != 0) return;
26995         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26996         CHECK_ACCESS(this_ptr_ptr);
26997         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
26998         FREE((void*)this_ptr);
26999         SpendableOutputDescriptor_free(this_ptr_conv);
27000 }
27001
27002 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
27003         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27004         *ret_copy = SpendableOutputDescriptor_clone(arg);
27005 int64_t ret_ref = (uintptr_t)ret_copy;
27006         return ret_ref;
27007 }
27008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27009         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
27010         int64_t ret_val = SpendableOutputDescriptor_clone_ptr(arg_conv);
27011         return ret_val;
27012 }
27013
27014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27015         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
27016         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27017         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
27018         int64_t ret_ref = (uintptr_t)ret_copy;
27019         return ret_ref;
27020 }
27021
27022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
27023         LDKOutPoint outpoint_conv;
27024         outpoint_conv.inner = (void*)(outpoint & (~1));
27025         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
27026         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
27027         outpoint_conv = OutPoint_clone(&outpoint_conv);
27028         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
27029         CHECK_ACCESS(output_ptr);
27030         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
27031         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
27032         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27033         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
27034         int64_t ret_ref = (uintptr_t)ret_copy;
27035         return ret_ref;
27036 }
27037
27038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
27039         LDKDelayedPaymentOutputDescriptor a_conv;
27040         a_conv.inner = (void*)(a & (~1));
27041         a_conv.is_owned = (a & 1) || (a == 0);
27042         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27043         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
27044         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27045         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
27046         int64_t ret_ref = (uintptr_t)ret_copy;
27047         return ret_ref;
27048 }
27049
27050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
27051         LDKStaticPaymentOutputDescriptor a_conv;
27052         a_conv.inner = (void*)(a & (~1));
27053         a_conv.is_owned = (a & 1) || (a == 0);
27054         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27055         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
27056         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27057         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
27058         int64_t ret_ref = (uintptr_t)ret_copy;
27059         return ret_ref;
27060 }
27061
27062 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27063         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
27064         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
27065         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27066         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27067         CVec_u8Z_free(ret_var);
27068         return ret_arr;
27069 }
27070
27071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27072         LDKu8slice ser_ref;
27073         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27074         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27075         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
27076         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
27077         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27078         return (int64_t)ret_conv;
27079 }
27080
27081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27082         if ((this_ptr & 1) != 0) return;
27083         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27084         CHECK_ACCESS(this_ptr_ptr);
27085         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
27086         FREE((void*)this_ptr);
27087         BaseSign_free(this_ptr_conv);
27088 }
27089
27090 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
27091         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
27092         *ret_ret = Sign_clone(arg);
27093         return (int64_t)ret_ret;
27094 }
27095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27096         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
27097         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
27098         LDKSign* arg_conv = (LDKSign*)arg_ptr;
27099         int64_t ret_val = Sign_clone_ptr(arg_conv);
27100         return ret_val;
27101 }
27102
27103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27104         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
27105         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
27106         LDKSign* orig_conv = (LDKSign*)orig_ptr;
27107         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
27108         *ret_ret = Sign_clone(orig_conv);
27109         return (int64_t)ret_ret;
27110 }
27111
27112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27113         if ((this_ptr & 1) != 0) return;
27114         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27115         CHECK_ACCESS(this_ptr_ptr);
27116         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
27117         FREE((void*)this_ptr);
27118         Sign_free(this_ptr_conv);
27119 }
27120
27121 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27122         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
27123         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
27124         return ret_conv;
27125 }
27126
27127 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
27128         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
27129         return ret_conv;
27130 }
27131
27132 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
27133         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
27134         return ret_conv;
27135 }
27136
27137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27138         if ((this_ptr & 1) != 0) return;
27139         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27140         CHECK_ACCESS(this_ptr_ptr);
27141         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
27142         FREE((void*)this_ptr);
27143         KeysInterface_free(this_ptr_conv);
27144 }
27145
27146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27147         LDKInMemorySigner this_obj_conv;
27148         this_obj_conv.inner = (void*)(this_obj & (~1));
27149         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27151         InMemorySigner_free(this_obj_conv);
27152 }
27153
27154 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27155         LDKInMemorySigner this_ptr_conv;
27156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27157         this_ptr_conv.is_owned = false;
27158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27159         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27160         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
27161         return ret_arr;
27162 }
27163
27164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27165         LDKInMemorySigner this_ptr_conv;
27166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27167         this_ptr_conv.is_owned = false;
27168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27169         LDKSecretKey val_ref;
27170         CHECK((*env)->GetArrayLength(env, val) == 32);
27171         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27172         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
27173 }
27174
27175 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27176         LDKInMemorySigner this_ptr_conv;
27177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27178         this_ptr_conv.is_owned = false;
27179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27180         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27181         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
27182         return ret_arr;
27183 }
27184
27185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27186         LDKInMemorySigner this_ptr_conv;
27187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27188         this_ptr_conv.is_owned = false;
27189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27190         LDKSecretKey val_ref;
27191         CHECK((*env)->GetArrayLength(env, val) == 32);
27192         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27193         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
27194 }
27195
27196 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27197         LDKInMemorySigner this_ptr_conv;
27198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27199         this_ptr_conv.is_owned = false;
27200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27201         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27202         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
27203         return ret_arr;
27204 }
27205
27206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27207         LDKInMemorySigner this_ptr_conv;
27208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27209         this_ptr_conv.is_owned = false;
27210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27211         LDKSecretKey val_ref;
27212         CHECK((*env)->GetArrayLength(env, val) == 32);
27213         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27214         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
27215 }
27216
27217 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27218         LDKInMemorySigner this_ptr_conv;
27219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27220         this_ptr_conv.is_owned = false;
27221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27222         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27223         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
27224         return ret_arr;
27225 }
27226
27227 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) {
27228         LDKInMemorySigner this_ptr_conv;
27229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27230         this_ptr_conv.is_owned = false;
27231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27232         LDKSecretKey val_ref;
27233         CHECK((*env)->GetArrayLength(env, val) == 32);
27234         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27235         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
27236 }
27237
27238 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27239         LDKInMemorySigner this_ptr_conv;
27240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27241         this_ptr_conv.is_owned = false;
27242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27243         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27244         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
27245         return ret_arr;
27246 }
27247
27248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27249         LDKInMemorySigner this_ptr_conv;
27250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27251         this_ptr_conv.is_owned = false;
27252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27253         LDKSecretKey val_ref;
27254         CHECK((*env)->GetArrayLength(env, val) == 32);
27255         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27256         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
27257 }
27258
27259 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
27260         LDKInMemorySigner this_ptr_conv;
27261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27262         this_ptr_conv.is_owned = false;
27263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27264         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27265         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
27266         return ret_arr;
27267 }
27268
27269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27270         LDKInMemorySigner this_ptr_conv;
27271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27272         this_ptr_conv.is_owned = false;
27273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27274         LDKThirtyTwoBytes val_ref;
27275         CHECK((*env)->GetArrayLength(env, val) == 32);
27276         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27277         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
27278 }
27279
27280 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
27281         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
27282 int64_t ret_ref = 0;
27283 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27284 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27285 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27286 ret_ref = (uintptr_t)ret_var.inner;
27287 if (ret_var.is_owned) {
27288         ret_ref |= 1;
27289 }
27290         return ret_ref;
27291 }
27292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27293         LDKInMemorySigner arg_conv;
27294         arg_conv.inner = (void*)(arg & (~1));
27295         arg_conv.is_owned = false;
27296         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27297         int64_t ret_val = InMemorySigner_clone_ptr(&arg_conv);
27298         return ret_val;
27299 }
27300
27301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27302         LDKInMemorySigner orig_conv;
27303         orig_conv.inner = (void*)(orig & (~1));
27304         orig_conv.is_owned = false;
27305         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27306         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
27307         int64_t ret_ref = 0;
27308         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27309         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27311         ret_ref = (uintptr_t)ret_var.inner;
27312         if (ret_var.is_owned) {
27313                 ret_ref |= 1;
27314         }
27315         return ret_ref;
27316 }
27317
27318 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) {
27319         LDKSecretKey node_secret_ref;
27320         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
27321         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
27322         LDKSecretKey funding_key_ref;
27323         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
27324         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
27325         LDKSecretKey revocation_base_key_ref;
27326         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
27327         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
27328         LDKSecretKey payment_key_ref;
27329         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
27330         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
27331         LDKSecretKey delayed_payment_base_key_ref;
27332         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
27333         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
27334         LDKSecretKey htlc_base_key_ref;
27335         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
27336         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
27337         LDKThirtyTwoBytes commitment_seed_ref;
27338         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
27339         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
27340         LDKThirtyTwoBytes channel_keys_id_ref;
27341         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
27342         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
27343         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);
27344         int64_t ret_ref = 0;
27345         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27346         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27348         ret_ref = (uintptr_t)ret_var.inner;
27349         if (ret_var.is_owned) {
27350                 ret_ref |= 1;
27351         }
27352         return ret_ref;
27353 }
27354
27355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
27356         LDKInMemorySigner this_arg_conv;
27357         this_arg_conv.inner = (void*)(this_arg & (~1));
27358         this_arg_conv.is_owned = false;
27359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27360         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
27361         int64_t ret_ref = 0;
27362         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27363         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27365         ret_ref = (uintptr_t)ret_var.inner;
27366         if (ret_var.is_owned) {
27367                 ret_ref |= 1;
27368         }
27369         return ret_ref;
27370 }
27371
27372 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
27373         LDKInMemorySigner this_arg_conv;
27374         this_arg_conv.inner = (void*)(this_arg & (~1));
27375         this_arg_conv.is_owned = false;
27376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27377         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
27378         return ret_val;
27379 }
27380
27381 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
27382         LDKInMemorySigner this_arg_conv;
27383         this_arg_conv.inner = (void*)(this_arg & (~1));
27384         this_arg_conv.is_owned = false;
27385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27386         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
27387         return ret_val;
27388 }
27389
27390 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
27391         LDKInMemorySigner this_arg_conv;
27392         this_arg_conv.inner = (void*)(this_arg & (~1));
27393         this_arg_conv.is_owned = false;
27394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27395         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
27396         return ret_val;
27397 }
27398
27399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
27400         LDKInMemorySigner this_arg_conv;
27401         this_arg_conv.inner = (void*)(this_arg & (~1));
27402         this_arg_conv.is_owned = false;
27403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27404         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
27405         int64_t ret_ref = 0;
27406         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27407         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27409         ret_ref = (uintptr_t)ret_var.inner;
27410         if (ret_var.is_owned) {
27411                 ret_ref |= 1;
27412         }
27413         return ret_ref;
27414 }
27415
27416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
27417         LDKInMemorySigner this_arg_conv;
27418         this_arg_conv.inner = (void*)(this_arg & (~1));
27419         this_arg_conv.is_owned = false;
27420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27421         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
27422         int64_t ret_ref = 0;
27423         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27424         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27426         ret_ref = (uintptr_t)ret_var.inner;
27427         if (ret_var.is_owned) {
27428                 ret_ref |= 1;
27429         }
27430         return ret_ref;
27431 }
27432
27433 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
27434         LDKInMemorySigner this_arg_conv;
27435         this_arg_conv.inner = (void*)(this_arg & (~1));
27436         this_arg_conv.is_owned = false;
27437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27438         jboolean ret_val = InMemorySigner_opt_anchors(&this_arg_conv);
27439         return ret_val;
27440 }
27441
27442 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) {
27443         LDKInMemorySigner this_arg_conv;
27444         this_arg_conv.inner = (void*)(this_arg & (~1));
27445         this_arg_conv.is_owned = false;
27446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27447         LDKTransaction spend_tx_ref;
27448         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
27449         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
27450         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
27451         spend_tx_ref.data_is_owned = true;
27452         LDKStaticPaymentOutputDescriptor descriptor_conv;
27453         descriptor_conv.inner = (void*)(descriptor & (~1));
27454         descriptor_conv.is_owned = false;
27455         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
27456         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
27457         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
27458         return (int64_t)ret_conv;
27459 }
27460
27461 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) {
27462         LDKInMemorySigner this_arg_conv;
27463         this_arg_conv.inner = (void*)(this_arg & (~1));
27464         this_arg_conv.is_owned = false;
27465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27466         LDKTransaction spend_tx_ref;
27467         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
27468         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
27469         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
27470         spend_tx_ref.data_is_owned = true;
27471         LDKDelayedPaymentOutputDescriptor descriptor_conv;
27472         descriptor_conv.inner = (void*)(descriptor & (~1));
27473         descriptor_conv.is_owned = false;
27474         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
27475         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
27476         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
27477         return (int64_t)ret_conv;
27478 }
27479
27480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
27481         LDKInMemorySigner this_arg_conv;
27482         this_arg_conv.inner = (void*)(this_arg & (~1));
27483         this_arg_conv.is_owned = false;
27484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27485         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
27486         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
27487         return (int64_t)ret_ret;
27488 }
27489
27490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
27491         LDKInMemorySigner this_arg_conv;
27492         this_arg_conv.inner = (void*)(this_arg & (~1));
27493         this_arg_conv.is_owned = false;
27494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27495         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
27496         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
27497         return (int64_t)ret_ret;
27498 }
27499
27500 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
27501         LDKInMemorySigner obj_conv;
27502         obj_conv.inner = (void*)(obj & (~1));
27503         obj_conv.is_owned = false;
27504         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27505         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
27506         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27507         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27508         CVec_u8Z_free(ret_var);
27509         return ret_arr;
27510 }
27511
27512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
27513         LDKu8slice ser_ref;
27514         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27515         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27516         LDKSecretKey arg_ref;
27517         CHECK((*env)->GetArrayLength(env, arg) == 32);
27518         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
27519         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
27520         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
27521         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27522         return (int64_t)ret_conv;
27523 }
27524
27525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27526         LDKKeysManager this_obj_conv;
27527         this_obj_conv.inner = (void*)(this_obj & (~1));
27528         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27530         KeysManager_free(this_obj_conv);
27531 }
27532
27533 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) {
27534         unsigned char seed_arr[32];
27535         CHECK((*env)->GetArrayLength(env, seed) == 32);
27536         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
27537         unsigned char (*seed_ref)[32] = &seed_arr;
27538         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
27539         int64_t ret_ref = 0;
27540         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27541         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27543         ret_ref = (uintptr_t)ret_var.inner;
27544         if (ret_var.is_owned) {
27545                 ret_ref |= 1;
27546         }
27547         return ret_ref;
27548 }
27549
27550 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) {
27551         LDKKeysManager this_arg_conv;
27552         this_arg_conv.inner = (void*)(this_arg & (~1));
27553         this_arg_conv.is_owned = false;
27554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27555         unsigned char params_arr[32];
27556         CHECK((*env)->GetArrayLength(env, params) == 32);
27557         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
27558         unsigned char (*params_ref)[32] = &params_arr;
27559         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
27560         int64_t ret_ref = 0;
27561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27564         ret_ref = (uintptr_t)ret_var.inner;
27565         if (ret_var.is_owned) {
27566                 ret_ref |= 1;
27567         }
27568         return ret_ref;
27569 }
27570
27571 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) {
27572         LDKKeysManager this_arg_conv;
27573         this_arg_conv.inner = (void*)(this_arg & (~1));
27574         this_arg_conv.is_owned = false;
27575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27576         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
27577         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
27578         if (descriptors_constr.datalen > 0)
27579                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
27580         else
27581                 descriptors_constr.data = NULL;
27582         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
27583         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
27584                 int64_t descriptors_conv_27 = descriptors_vals[b];
27585                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
27586                 CHECK_ACCESS(descriptors_conv_27_ptr);
27587                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
27588                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
27589                 descriptors_constr.data[b] = descriptors_conv_27_conv;
27590         }
27591         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
27592         LDKCVec_TxOutZ outputs_constr;
27593         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
27594         if (outputs_constr.datalen > 0)
27595                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
27596         else
27597                 outputs_constr.data = NULL;
27598         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
27599         for (size_t h = 0; h < outputs_constr.datalen; h++) {
27600                 int64_t outputs_conv_7 = outputs_vals[h];
27601                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
27602                 CHECK_ACCESS(outputs_conv_7_ptr);
27603                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
27604                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
27605                 outputs_constr.data[h] = outputs_conv_7_conv;
27606         }
27607         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
27608         LDKCVec_u8Z change_destination_script_ref;
27609         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
27610         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
27611         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
27612         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
27613         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
27614         return (int64_t)ret_conv;
27615 }
27616
27617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
27618         LDKKeysManager this_arg_conv;
27619         this_arg_conv.inner = (void*)(this_arg & (~1));
27620         this_arg_conv.is_owned = false;
27621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27622         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
27623         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
27624         return (int64_t)ret_ret;
27625 }
27626
27627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27628         LDKPhantomKeysManager this_obj_conv;
27629         this_obj_conv.inner = (void*)(this_obj & (~1));
27630         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27632         PhantomKeysManager_free(this_obj_conv);
27633 }
27634
27635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
27636         LDKPhantomKeysManager this_arg_conv;
27637         this_arg_conv.inner = (void*)(this_arg & (~1));
27638         this_arg_conv.is_owned = false;
27639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27640         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
27641         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
27642         return (int64_t)ret_ret;
27643 }
27644
27645 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) {
27646         unsigned char seed_arr[32];
27647         CHECK((*env)->GetArrayLength(env, seed) == 32);
27648         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
27649         unsigned char (*seed_ref)[32] = &seed_arr;
27650         unsigned char cross_node_seed_arr[32];
27651         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
27652         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
27653         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
27654         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
27655         int64_t ret_ref = 0;
27656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27659         ret_ref = (uintptr_t)ret_var.inner;
27660         if (ret_var.is_owned) {
27661                 ret_ref |= 1;
27662         }
27663         return ret_ref;
27664 }
27665
27666 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) {
27667         LDKPhantomKeysManager this_arg_conv;
27668         this_arg_conv.inner = (void*)(this_arg & (~1));
27669         this_arg_conv.is_owned = false;
27670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27671         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
27672         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
27673         if (descriptors_constr.datalen > 0)
27674                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
27675         else
27676                 descriptors_constr.data = NULL;
27677         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
27678         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
27679                 int64_t descriptors_conv_27 = descriptors_vals[b];
27680                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
27681                 CHECK_ACCESS(descriptors_conv_27_ptr);
27682                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
27683                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
27684                 descriptors_constr.data[b] = descriptors_conv_27_conv;
27685         }
27686         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
27687         LDKCVec_TxOutZ outputs_constr;
27688         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
27689         if (outputs_constr.datalen > 0)
27690                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
27691         else
27692                 outputs_constr.data = NULL;
27693         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
27694         for (size_t h = 0; h < outputs_constr.datalen; h++) {
27695                 int64_t outputs_conv_7 = outputs_vals[h];
27696                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
27697                 CHECK_ACCESS(outputs_conv_7_ptr);
27698                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
27699                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
27700                 outputs_constr.data[h] = outputs_conv_7_conv;
27701         }
27702         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
27703         LDKCVec_u8Z change_destination_script_ref;
27704         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
27705         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
27706         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
27707         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
27708         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
27709         return (int64_t)ret_conv;
27710 }
27711
27712 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) {
27713         LDKPhantomKeysManager this_arg_conv;
27714         this_arg_conv.inner = (void*)(this_arg & (~1));
27715         this_arg_conv.is_owned = false;
27716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27717         unsigned char params_arr[32];
27718         CHECK((*env)->GetArrayLength(env, params) == 32);
27719         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
27720         unsigned char (*params_ref)[32] = &params_arr;
27721         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
27722         int64_t ret_ref = 0;
27723         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27724         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27726         ret_ref = (uintptr_t)ret_var.inner;
27727         if (ret_var.is_owned) {
27728                 ret_ref |= 1;
27729         }
27730         return ret_ref;
27731 }
27732
27733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27734         LDKChannelManager this_obj_conv;
27735         this_obj_conv.inner = (void*)(this_obj & (~1));
27736         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27738         ChannelManager_free(this_obj_conv);
27739 }
27740
27741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27742         LDKChainParameters this_obj_conv;
27743         this_obj_conv.inner = (void*)(this_obj & (~1));
27744         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27746         ChainParameters_free(this_obj_conv);
27747 }
27748
27749 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
27750         LDKChainParameters this_ptr_conv;
27751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27752         this_ptr_conv.is_owned = false;
27753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27754         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
27755         return ret_conv;
27756 }
27757
27758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
27759         LDKChainParameters this_ptr_conv;
27760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27761         this_ptr_conv.is_owned = false;
27762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27763         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
27764         ChainParameters_set_network(&this_ptr_conv, val_conv);
27765 }
27766
27767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
27768         LDKChainParameters this_ptr_conv;
27769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27770         this_ptr_conv.is_owned = false;
27771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27772         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
27773         int64_t ret_ref = 0;
27774         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27775         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27777         ret_ref = (uintptr_t)ret_var.inner;
27778         if (ret_var.is_owned) {
27779                 ret_ref |= 1;
27780         }
27781         return ret_ref;
27782 }
27783
27784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27785         LDKChainParameters this_ptr_conv;
27786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27787         this_ptr_conv.is_owned = false;
27788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27789         LDKBestBlock val_conv;
27790         val_conv.inner = (void*)(val & (~1));
27791         val_conv.is_owned = (val & 1) || (val == 0);
27792         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27793         val_conv = BestBlock_clone(&val_conv);
27794         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
27795 }
27796
27797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
27798         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
27799         LDKBestBlock best_block_arg_conv;
27800         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
27801         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
27802         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
27803         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
27804         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
27805         int64_t ret_ref = 0;
27806         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27807         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27809         ret_ref = (uintptr_t)ret_var.inner;
27810         if (ret_var.is_owned) {
27811                 ret_ref |= 1;
27812         }
27813         return ret_ref;
27814 }
27815
27816 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
27817         LDKChainParameters ret_var = ChainParameters_clone(arg);
27818 int64_t ret_ref = 0;
27819 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27820 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27821 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27822 ret_ref = (uintptr_t)ret_var.inner;
27823 if (ret_var.is_owned) {
27824         ret_ref |= 1;
27825 }
27826         return ret_ref;
27827 }
27828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27829         LDKChainParameters arg_conv;
27830         arg_conv.inner = (void*)(arg & (~1));
27831         arg_conv.is_owned = false;
27832         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27833         int64_t ret_val = ChainParameters_clone_ptr(&arg_conv);
27834         return ret_val;
27835 }
27836
27837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27838         LDKChainParameters orig_conv;
27839         orig_conv.inner = (void*)(orig & (~1));
27840         orig_conv.is_owned = false;
27841         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27842         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
27843         int64_t ret_ref = 0;
27844         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27845         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27847         ret_ref = (uintptr_t)ret_var.inner;
27848         if (ret_var.is_owned) {
27849                 ret_ref |= 1;
27850         }
27851         return ret_ref;
27852 }
27853
27854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27855         LDKCounterpartyForwardingInfo this_obj_conv;
27856         this_obj_conv.inner = (void*)(this_obj & (~1));
27857         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27859         CounterpartyForwardingInfo_free(this_obj_conv);
27860 }
27861
27862 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27863         LDKCounterpartyForwardingInfo this_ptr_conv;
27864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27865         this_ptr_conv.is_owned = false;
27866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27867         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
27868         return ret_val;
27869 }
27870
27871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27872         LDKCounterpartyForwardingInfo this_ptr_conv;
27873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27874         this_ptr_conv.is_owned = false;
27875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27876         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
27877 }
27878
27879 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
27880         LDKCounterpartyForwardingInfo this_ptr_conv;
27881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27882         this_ptr_conv.is_owned = false;
27883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27884         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
27885         return ret_val;
27886 }
27887
27888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27889         LDKCounterpartyForwardingInfo this_ptr_conv;
27890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27891         this_ptr_conv.is_owned = false;
27892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27893         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
27894 }
27895
27896 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
27897         LDKCounterpartyForwardingInfo this_ptr_conv;
27898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27899         this_ptr_conv.is_owned = false;
27900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27901         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
27902         return ret_val;
27903 }
27904
27905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27906         LDKCounterpartyForwardingInfo this_ptr_conv;
27907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27908         this_ptr_conv.is_owned = false;
27909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27910         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
27911 }
27912
27913 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) {
27914         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
27915         int64_t ret_ref = 0;
27916         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27917         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27918         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27919         ret_ref = (uintptr_t)ret_var.inner;
27920         if (ret_var.is_owned) {
27921                 ret_ref |= 1;
27922         }
27923         return ret_ref;
27924 }
27925
27926 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
27927         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
27928 int64_t ret_ref = 0;
27929 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27930 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27931 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27932 ret_ref = (uintptr_t)ret_var.inner;
27933 if (ret_var.is_owned) {
27934         ret_ref |= 1;
27935 }
27936         return ret_ref;
27937 }
27938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27939         LDKCounterpartyForwardingInfo arg_conv;
27940         arg_conv.inner = (void*)(arg & (~1));
27941         arg_conv.is_owned = false;
27942         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27943         int64_t ret_val = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
27944         return ret_val;
27945 }
27946
27947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27948         LDKCounterpartyForwardingInfo orig_conv;
27949         orig_conv.inner = (void*)(orig & (~1));
27950         orig_conv.is_owned = false;
27951         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27952         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
27953         int64_t ret_ref = 0;
27954         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27955         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27957         ret_ref = (uintptr_t)ret_var.inner;
27958         if (ret_var.is_owned) {
27959                 ret_ref |= 1;
27960         }
27961         return ret_ref;
27962 }
27963
27964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27965         LDKChannelCounterparty this_obj_conv;
27966         this_obj_conv.inner = (void*)(this_obj & (~1));
27967         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27969         ChannelCounterparty_free(this_obj_conv);
27970 }
27971
27972 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27973         LDKChannelCounterparty this_ptr_conv;
27974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27975         this_ptr_conv.is_owned = false;
27976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27977         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27978         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
27979         return ret_arr;
27980 }
27981
27982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27983         LDKChannelCounterparty this_ptr_conv;
27984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27985         this_ptr_conv.is_owned = false;
27986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27987         LDKPublicKey val_ref;
27988         CHECK((*env)->GetArrayLength(env, val) == 33);
27989         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27990         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
27991 }
27992
27993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
27994         LDKChannelCounterparty this_ptr_conv;
27995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27996         this_ptr_conv.is_owned = false;
27997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27998         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
27999         int64_t ret_ref = 0;
28000         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28001         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28003         ret_ref = (uintptr_t)ret_var.inner;
28004         if (ret_var.is_owned) {
28005                 ret_ref |= 1;
28006         }
28007         return ret_ref;
28008 }
28009
28010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28011         LDKChannelCounterparty this_ptr_conv;
28012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28013         this_ptr_conv.is_owned = false;
28014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28015         LDKInitFeatures val_conv;
28016         val_conv.inner = (void*)(val & (~1));
28017         val_conv.is_owned = (val & 1) || (val == 0);
28018         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28019         val_conv = InitFeatures_clone(&val_conv);
28020         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
28021 }
28022
28023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
28024         LDKChannelCounterparty this_ptr_conv;
28025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28026         this_ptr_conv.is_owned = false;
28027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28028         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
28029         return ret_val;
28030 }
28031
28032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28033         LDKChannelCounterparty this_ptr_conv;
28034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28035         this_ptr_conv.is_owned = false;
28036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28037         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
28038 }
28039
28040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
28041         LDKChannelCounterparty this_ptr_conv;
28042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28043         this_ptr_conv.is_owned = false;
28044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28045         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
28046         int64_t ret_ref = 0;
28047         if ((uintptr_t)ret_var.inner > 4096) {
28048                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28049                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28050         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28051                 ret_ref = (uintptr_t)ret_var.inner;
28052                 if (ret_var.is_owned) {
28053                         ret_ref |= 1;
28054                 }
28055         }
28056         return ret_ref;
28057 }
28058
28059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28060         LDKChannelCounterparty this_ptr_conv;
28061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28062         this_ptr_conv.is_owned = false;
28063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28064         LDKCounterpartyForwardingInfo val_conv;
28065         val_conv.inner = (void*)(val & (~1));
28066         val_conv.is_owned = (val & 1) || (val == 0);
28067         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28068         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
28069         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
28070 }
28071
28072 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) {
28073         LDKPublicKey node_id_arg_ref;
28074         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
28075         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
28076         LDKInitFeatures features_arg_conv;
28077         features_arg_conv.inner = (void*)(features_arg & (~1));
28078         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
28079         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
28080         features_arg_conv = InitFeatures_clone(&features_arg_conv);
28081         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
28082         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
28083         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
28084         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
28085         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
28086         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
28087         int64_t ret_ref = 0;
28088         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28089         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28091         ret_ref = (uintptr_t)ret_var.inner;
28092         if (ret_var.is_owned) {
28093                 ret_ref |= 1;
28094         }
28095         return ret_ref;
28096 }
28097
28098 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
28099         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
28100 int64_t ret_ref = 0;
28101 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28102 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28103 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28104 ret_ref = (uintptr_t)ret_var.inner;
28105 if (ret_var.is_owned) {
28106         ret_ref |= 1;
28107 }
28108         return ret_ref;
28109 }
28110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28111         LDKChannelCounterparty arg_conv;
28112         arg_conv.inner = (void*)(arg & (~1));
28113         arg_conv.is_owned = false;
28114         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28115         int64_t ret_val = ChannelCounterparty_clone_ptr(&arg_conv);
28116         return ret_val;
28117 }
28118
28119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28120         LDKChannelCounterparty orig_conv;
28121         orig_conv.inner = (void*)(orig & (~1));
28122         orig_conv.is_owned = false;
28123         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28124         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
28125         int64_t ret_ref = 0;
28126         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28127         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28128         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28129         ret_ref = (uintptr_t)ret_var.inner;
28130         if (ret_var.is_owned) {
28131                 ret_ref |= 1;
28132         }
28133         return ret_ref;
28134 }
28135
28136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28137         LDKChannelDetails this_obj_conv;
28138         this_obj_conv.inner = (void*)(this_obj & (~1));
28139         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28141         ChannelDetails_free(this_obj_conv);
28142 }
28143
28144 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28145         LDKChannelDetails this_ptr_conv;
28146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28147         this_ptr_conv.is_owned = false;
28148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28149         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28150         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
28151         return ret_arr;
28152 }
28153
28154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28155         LDKChannelDetails this_ptr_conv;
28156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28157         this_ptr_conv.is_owned = false;
28158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28159         LDKThirtyTwoBytes val_ref;
28160         CHECK((*env)->GetArrayLength(env, val) == 32);
28161         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28162         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
28163 }
28164
28165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
28166         LDKChannelDetails this_ptr_conv;
28167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28168         this_ptr_conv.is_owned = false;
28169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28170         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
28171         int64_t ret_ref = 0;
28172         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28173         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28175         ret_ref = (uintptr_t)ret_var.inner;
28176         if (ret_var.is_owned) {
28177                 ret_ref |= 1;
28178         }
28179         return ret_ref;
28180 }
28181
28182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28183         LDKChannelDetails 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         LDKChannelCounterparty val_conv;
28188         val_conv.inner = (void*)(val & (~1));
28189         val_conv.is_owned = (val & 1) || (val == 0);
28190         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28191         val_conv = ChannelCounterparty_clone(&val_conv);
28192         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
28193 }
28194
28195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
28196         LDKChannelDetails this_ptr_conv;
28197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28198         this_ptr_conv.is_owned = false;
28199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28200         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
28201         int64_t ret_ref = 0;
28202         if ((uintptr_t)ret_var.inner > 4096) {
28203                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28204                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28206                 ret_ref = (uintptr_t)ret_var.inner;
28207                 if (ret_var.is_owned) {
28208                         ret_ref |= 1;
28209                 }
28210         }
28211         return ret_ref;
28212 }
28213
28214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28215         LDKChannelDetails this_ptr_conv;
28216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28217         this_ptr_conv.is_owned = false;
28218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28219         LDKOutPoint val_conv;
28220         val_conv.inner = (void*)(val & (~1));
28221         val_conv.is_owned = (val & 1) || (val == 0);
28222         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28223         val_conv = OutPoint_clone(&val_conv);
28224         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
28225 }
28226
28227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
28228         LDKChannelDetails this_ptr_conv;
28229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28230         this_ptr_conv.is_owned = false;
28231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28232         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
28233         int64_t ret_ref = 0;
28234         if ((uintptr_t)ret_var.inner > 4096) {
28235                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28236                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28238                 ret_ref = (uintptr_t)ret_var.inner;
28239                 if (ret_var.is_owned) {
28240                         ret_ref |= 1;
28241                 }
28242         }
28243         return ret_ref;
28244 }
28245
28246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28247         LDKChannelDetails this_ptr_conv;
28248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28249         this_ptr_conv.is_owned = false;
28250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28251         LDKChannelTypeFeatures val_conv;
28252         val_conv.inner = (void*)(val & (~1));
28253         val_conv.is_owned = (val & 1) || (val == 0);
28254         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28255         val_conv = ChannelTypeFeatures_clone(&val_conv);
28256         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
28257 }
28258
28259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28260         LDKChannelDetails this_ptr_conv;
28261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28262         this_ptr_conv.is_owned = false;
28263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28264         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28265         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
28266         int64_t ret_ref = (uintptr_t)ret_copy;
28267         return ret_ref;
28268 }
28269
28270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28271         LDKChannelDetails this_ptr_conv;
28272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28273         this_ptr_conv.is_owned = false;
28274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28275         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28276         CHECK_ACCESS(val_ptr);
28277         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28278         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
28279         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
28280 }
28281
28282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
28283         LDKChannelDetails this_ptr_conv;
28284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28285         this_ptr_conv.is_owned = false;
28286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28287         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28288         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
28289         int64_t ret_ref = (uintptr_t)ret_copy;
28290         return ret_ref;
28291 }
28292
28293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28294         LDKChannelDetails this_ptr_conv;
28295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28296         this_ptr_conv.is_owned = false;
28297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28298         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28299         CHECK_ACCESS(val_ptr);
28300         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28301         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
28302         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
28303 }
28304
28305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28306         LDKChannelDetails this_ptr_conv;
28307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28308         this_ptr_conv.is_owned = false;
28309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28310         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
28311         return ret_val;
28312 }
28313
28314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28315         LDKChannelDetails this_ptr_conv;
28316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28317         this_ptr_conv.is_owned = false;
28318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28319         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
28320 }
28321
28322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
28323         LDKChannelDetails this_ptr_conv;
28324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28325         this_ptr_conv.is_owned = false;
28326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28327         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28328         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
28329         int64_t ret_ref = (uintptr_t)ret_copy;
28330         return ret_ref;
28331 }
28332
28333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28334         LDKChannelDetails this_ptr_conv;
28335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28336         this_ptr_conv.is_owned = false;
28337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28338         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28339         CHECK_ACCESS(val_ptr);
28340         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28341         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
28342         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
28343 }
28344
28345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28346         LDKChannelDetails this_ptr_conv;
28347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28348         this_ptr_conv.is_owned = false;
28349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28350         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
28351         return ret_val;
28352 }
28353
28354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28355         LDKChannelDetails this_ptr_conv;
28356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28357         this_ptr_conv.is_owned = false;
28358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28359         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
28360 }
28361
28362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28363         LDKChannelDetails this_ptr_conv;
28364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28365         this_ptr_conv.is_owned = false;
28366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28367         int64_t ret_val = ChannelDetails_get_balance_msat(&this_ptr_conv);
28368         return ret_val;
28369 }
28370
28371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28372         LDKChannelDetails this_ptr_conv;
28373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28374         this_ptr_conv.is_owned = false;
28375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28376         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
28377 }
28378
28379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28380         LDKChannelDetails this_ptr_conv;
28381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28382         this_ptr_conv.is_owned = false;
28383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28384         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
28385         return ret_val;
28386 }
28387
28388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28389         LDKChannelDetails this_ptr_conv;
28390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28391         this_ptr_conv.is_owned = false;
28392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28393         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
28394 }
28395
28396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28397         LDKChannelDetails this_ptr_conv;
28398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28399         this_ptr_conv.is_owned = false;
28400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28401         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
28402         return ret_val;
28403 }
28404
28405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28406         LDKChannelDetails this_ptr_conv;
28407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28408         this_ptr_conv.is_owned = false;
28409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28410         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
28411 }
28412
28413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
28414         LDKChannelDetails this_ptr_conv;
28415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28416         this_ptr_conv.is_owned = false;
28417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28418         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
28419         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
28420         int64_t ret_ref = (uintptr_t)ret_copy;
28421         return ret_ref;
28422 }
28423
28424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28425         LDKChannelDetails this_ptr_conv;
28426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28427         this_ptr_conv.is_owned = false;
28428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28429         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28430         CHECK_ACCESS(val_ptr);
28431         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
28432         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
28433         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
28434 }
28435
28436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
28437         LDKChannelDetails this_ptr_conv;
28438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28439         this_ptr_conv.is_owned = false;
28440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28441         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
28442         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
28443         int64_t ret_ref = (uintptr_t)ret_copy;
28444         return ret_ref;
28445 }
28446
28447 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) {
28448         LDKChannelDetails this_ptr_conv;
28449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28450         this_ptr_conv.is_owned = false;
28451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28452         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28453         CHECK_ACCESS(val_ptr);
28454         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
28455         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
28456         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
28457 }
28458
28459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
28460         LDKChannelDetails this_ptr_conv;
28461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28462         this_ptr_conv.is_owned = false;
28463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28464         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
28465         return ret_val;
28466 }
28467
28468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28469         LDKChannelDetails this_ptr_conv;
28470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28471         this_ptr_conv.is_owned = false;
28472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28473         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
28474 }
28475
28476 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
28477         LDKChannelDetails this_ptr_conv;
28478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28479         this_ptr_conv.is_owned = false;
28480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28481         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
28482         return ret_val;
28483 }
28484
28485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28486         LDKChannelDetails this_ptr_conv;
28487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28488         this_ptr_conv.is_owned = false;
28489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28490         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
28491 }
28492
28493 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
28494         LDKChannelDetails this_ptr_conv;
28495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28496         this_ptr_conv.is_owned = false;
28497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28498         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
28499         return ret_val;
28500 }
28501
28502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28503         LDKChannelDetails this_ptr_conv;
28504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28505         this_ptr_conv.is_owned = false;
28506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28507         ChannelDetails_set_is_usable(&this_ptr_conv, val);
28508 }
28509
28510 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
28511         LDKChannelDetails this_ptr_conv;
28512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28513         this_ptr_conv.is_owned = false;
28514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28515         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
28516         return ret_val;
28517 }
28518
28519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28520         LDKChannelDetails this_ptr_conv;
28521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28522         this_ptr_conv.is_owned = false;
28523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28524         ChannelDetails_set_is_public(&this_ptr_conv, val);
28525 }
28526
28527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t channel_type_arg, int64_t short_channel_id_arg, int64_t inbound_scid_alias_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t balance_msat_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
28528         LDKThirtyTwoBytes channel_id_arg_ref;
28529         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
28530         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
28531         LDKChannelCounterparty counterparty_arg_conv;
28532         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
28533         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
28534         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
28535         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
28536         LDKOutPoint funding_txo_arg_conv;
28537         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
28538         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
28539         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
28540         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
28541         LDKChannelTypeFeatures channel_type_arg_conv;
28542         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
28543         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
28544         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
28545         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
28546         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
28547         CHECK_ACCESS(short_channel_id_arg_ptr);
28548         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
28549         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
28550         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
28551         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
28552         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
28553         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
28554         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
28555         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
28556         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
28557         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
28558         CHECK_ACCESS(confirmations_required_arg_ptr);
28559         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
28560         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
28561         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
28562         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
28563         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
28564         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
28565         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, channel_type_arg_conv, short_channel_id_arg_conv, inbound_scid_alias_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, balance_msat_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
28566         int64_t ret_ref = 0;
28567         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28568         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28570         ret_ref = (uintptr_t)ret_var.inner;
28571         if (ret_var.is_owned) {
28572                 ret_ref |= 1;
28573         }
28574         return ret_ref;
28575 }
28576
28577 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
28578         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
28579 int64_t ret_ref = 0;
28580 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28581 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28582 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28583 ret_ref = (uintptr_t)ret_var.inner;
28584 if (ret_var.is_owned) {
28585         ret_ref |= 1;
28586 }
28587         return ret_ref;
28588 }
28589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28590         LDKChannelDetails arg_conv;
28591         arg_conv.inner = (void*)(arg & (~1));
28592         arg_conv.is_owned = false;
28593         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28594         int64_t ret_val = ChannelDetails_clone_ptr(&arg_conv);
28595         return ret_val;
28596 }
28597
28598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28599         LDKChannelDetails orig_conv;
28600         orig_conv.inner = (void*)(orig & (~1));
28601         orig_conv.is_owned = false;
28602         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28603         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
28604         int64_t ret_ref = 0;
28605         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28606         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28608         ret_ref = (uintptr_t)ret_var.inner;
28609         if (ret_var.is_owned) {
28610                 ret_ref |= 1;
28611         }
28612         return ret_ref;
28613 }
28614
28615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
28616         LDKChannelDetails this_arg_conv;
28617         this_arg_conv.inner = (void*)(this_arg & (~1));
28618         this_arg_conv.is_owned = false;
28619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28620         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28621         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
28622         int64_t ret_ref = (uintptr_t)ret_copy;
28623         return ret_ref;
28624 }
28625
28626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28627         if ((this_ptr & 1) != 0) return;
28628         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28629         CHECK_ACCESS(this_ptr_ptr);
28630         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
28631         FREE((void*)this_ptr);
28632         PaymentSendFailure_free(this_ptr_conv);
28633 }
28634
28635 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
28636         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28637         *ret_copy = PaymentSendFailure_clone(arg);
28638 int64_t ret_ref = (uintptr_t)ret_copy;
28639         return ret_ref;
28640 }
28641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28642         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
28643         int64_t ret_val = PaymentSendFailure_clone_ptr(arg_conv);
28644         return ret_val;
28645 }
28646
28647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28648         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
28649         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28650         *ret_copy = PaymentSendFailure_clone(orig_conv);
28651         int64_t ret_ref = (uintptr_t)ret_copy;
28652         return ret_ref;
28653 }
28654
28655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
28656         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
28657         CHECK_ACCESS(a_ptr);
28658         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
28659         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
28660         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28661         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
28662         int64_t ret_ref = (uintptr_t)ret_copy;
28663         return ret_ref;
28664 }
28665
28666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
28667         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
28668         a_constr.datalen = (*env)->GetArrayLength(env, a);
28669         if (a_constr.datalen > 0)
28670                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
28671         else
28672                 a_constr.data = NULL;
28673         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
28674         for (size_t w = 0; w < a_constr.datalen; w++) {
28675                 int64_t a_conv_22 = a_vals[w];
28676                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
28677                 CHECK_ACCESS(a_conv_22_ptr);
28678                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
28679                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
28680                 a_constr.data[w] = a_conv_22_conv;
28681         }
28682         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
28683         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28684         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
28685         int64_t ret_ref = (uintptr_t)ret_copy;
28686         return ret_ref;
28687 }
28688
28689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
28690         LDKCVec_APIErrorZ a_constr;
28691         a_constr.datalen = (*env)->GetArrayLength(env, a);
28692         if (a_constr.datalen > 0)
28693                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
28694         else
28695                 a_constr.data = NULL;
28696         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
28697         for (size_t k = 0; k < a_constr.datalen; k++) {
28698                 int64_t a_conv_10 = a_vals[k];
28699                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
28700                 CHECK_ACCESS(a_conv_10_ptr);
28701                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
28702                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
28703                 a_constr.data[k] = a_conv_10_conv;
28704         }
28705         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
28706         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28707         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
28708         int64_t ret_ref = (uintptr_t)ret_copy;
28709         return ret_ref;
28710 }
28711
28712 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) {
28713         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
28714         results_constr.datalen = (*env)->GetArrayLength(env, results);
28715         if (results_constr.datalen > 0)
28716                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
28717         else
28718                 results_constr.data = NULL;
28719         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
28720         for (size_t w = 0; w < results_constr.datalen; w++) {
28721                 int64_t results_conv_22 = results_vals[w];
28722                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
28723                 CHECK_ACCESS(results_conv_22_ptr);
28724                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
28725                 results_constr.data[w] = results_conv_22_conv;
28726         }
28727         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
28728         LDKRouteParameters failed_paths_retry_conv;
28729         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
28730         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
28731         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
28732         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
28733         LDKThirtyTwoBytes payment_id_ref;
28734         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
28735         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
28736         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28737         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
28738         int64_t ret_ref = (uintptr_t)ret_copy;
28739         return ret_ref;
28740 }
28741
28742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28743         LDKPhantomRouteHints this_obj_conv;
28744         this_obj_conv.inner = (void*)(this_obj & (~1));
28745         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28747         PhantomRouteHints_free(this_obj_conv);
28748 }
28749
28750 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28751         LDKPhantomRouteHints this_ptr_conv;
28752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28753         this_ptr_conv.is_owned = false;
28754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28755         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
28756         int64_tArray ret_arr = NULL;
28757         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28758         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28759         for (size_t q = 0; q < ret_var.datalen; q++) {
28760                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
28761                 int64_t ret_conv_16_ref = 0;
28762                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28763                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28764                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
28765                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
28766                 if (ret_conv_16_var.is_owned) {
28767                         ret_conv_16_ref |= 1;
28768                 }
28769                 ret_arr_ptr[q] = ret_conv_16_ref;
28770         }
28771         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28772         FREE(ret_var.data);
28773         return ret_arr;
28774 }
28775
28776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
28777         LDKPhantomRouteHints this_ptr_conv;
28778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28779         this_ptr_conv.is_owned = false;
28780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28781         LDKCVec_ChannelDetailsZ val_constr;
28782         val_constr.datalen = (*env)->GetArrayLength(env, val);
28783         if (val_constr.datalen > 0)
28784                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
28785         else
28786                 val_constr.data = NULL;
28787         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
28788         for (size_t q = 0; q < val_constr.datalen; q++) {
28789                 int64_t val_conv_16 = val_vals[q];
28790                 LDKChannelDetails val_conv_16_conv;
28791                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
28792                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
28793                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
28794                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
28795                 val_constr.data[q] = val_conv_16_conv;
28796         }
28797         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
28798         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
28799 }
28800
28801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
28802         LDKPhantomRouteHints this_ptr_conv;
28803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28804         this_ptr_conv.is_owned = false;
28805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28806         int64_t ret_val = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
28807         return ret_val;
28808 }
28809
28810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28811         LDKPhantomRouteHints this_ptr_conv;
28812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28813         this_ptr_conv.is_owned = false;
28814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28815         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
28816 }
28817
28818 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28819         LDKPhantomRouteHints this_ptr_conv;
28820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28821         this_ptr_conv.is_owned = false;
28822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28823         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28824         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
28825         return ret_arr;
28826 }
28827
28828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28829         LDKPhantomRouteHints this_ptr_conv;
28830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28831         this_ptr_conv.is_owned = false;
28832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28833         LDKPublicKey val_ref;
28834         CHECK((*env)->GetArrayLength(env, val) == 33);
28835         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28836         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
28837 }
28838
28839 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) {
28840         LDKCVec_ChannelDetailsZ channels_arg_constr;
28841         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
28842         if (channels_arg_constr.datalen > 0)
28843                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
28844         else
28845                 channels_arg_constr.data = NULL;
28846         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
28847         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
28848                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
28849                 LDKChannelDetails channels_arg_conv_16_conv;
28850                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
28851                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
28852                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
28853                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
28854                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
28855         }
28856         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
28857         LDKPublicKey real_node_pubkey_arg_ref;
28858         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
28859         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
28860         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
28861         int64_t ret_ref = 0;
28862         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28863         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28865         ret_ref = (uintptr_t)ret_var.inner;
28866         if (ret_var.is_owned) {
28867                 ret_ref |= 1;
28868         }
28869         return ret_ref;
28870 }
28871
28872 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
28873         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
28874 int64_t ret_ref = 0;
28875 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28876 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28877 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28878 ret_ref = (uintptr_t)ret_var.inner;
28879 if (ret_var.is_owned) {
28880         ret_ref |= 1;
28881 }
28882         return ret_ref;
28883 }
28884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28885         LDKPhantomRouteHints arg_conv;
28886         arg_conv.inner = (void*)(arg & (~1));
28887         arg_conv.is_owned = false;
28888         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28889         int64_t ret_val = PhantomRouteHints_clone_ptr(&arg_conv);
28890         return ret_val;
28891 }
28892
28893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28894         LDKPhantomRouteHints orig_conv;
28895         orig_conv.inner = (void*)(orig & (~1));
28896         orig_conv.is_owned = false;
28897         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28898         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
28899         int64_t ret_ref = 0;
28900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28903         ret_ref = (uintptr_t)ret_var.inner;
28904         if (ret_var.is_owned) {
28905                 ret_ref |= 1;
28906         }
28907         return ret_ref;
28908 }
28909
28910 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) {
28911         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
28912         CHECK_ACCESS(fee_est_ptr);
28913         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
28914         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
28915                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28916                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
28917         }
28918         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
28919         CHECK_ACCESS(chain_monitor_ptr);
28920         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
28921         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
28922                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28923                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
28924         }
28925         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
28926         CHECK_ACCESS(tx_broadcaster_ptr);
28927         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
28928         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28929                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28930                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
28931         }
28932         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
28933         CHECK_ACCESS(logger_ptr);
28934         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28935         if (logger_conv.free == LDKLogger_JCalls_free) {
28936                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28937                 LDKLogger_JCalls_cloned(&logger_conv);
28938         }
28939         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
28940         CHECK_ACCESS(keys_manager_ptr);
28941         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
28942         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
28943                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28944                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
28945         }
28946         LDKUserConfig config_conv;
28947         config_conv.inner = (void*)(config & (~1));
28948         config_conv.is_owned = (config & 1) || (config == 0);
28949         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
28950         config_conv = UserConfig_clone(&config_conv);
28951         LDKChainParameters params_conv;
28952         params_conv.inner = (void*)(params & (~1));
28953         params_conv.is_owned = (params & 1) || (params == 0);
28954         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
28955         params_conv = ChainParameters_clone(&params_conv);
28956         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
28957         int64_t ret_ref = 0;
28958         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28959         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28961         ret_ref = (uintptr_t)ret_var.inner;
28962         if (ret_var.is_owned) {
28963                 ret_ref |= 1;
28964         }
28965         return ret_ref;
28966 }
28967
28968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
28969         LDKChannelManager this_arg_conv;
28970         this_arg_conv.inner = (void*)(this_arg & (~1));
28971         this_arg_conv.is_owned = false;
28972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28973         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
28974         int64_t ret_ref = 0;
28975         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28976         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28978         ret_ref = (uintptr_t)ret_var.inner;
28979         if (ret_var.is_owned) {
28980                 ret_ref |= 1;
28981         }
28982         return ret_ref;
28983 }
28984
28985 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) {
28986         LDKChannelManager this_arg_conv;
28987         this_arg_conv.inner = (void*)(this_arg & (~1));
28988         this_arg_conv.is_owned = false;
28989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28990         LDKPublicKey their_network_key_ref;
28991         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
28992         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
28993         LDKUserConfig override_config_conv;
28994         override_config_conv.inner = (void*)(override_config & (~1));
28995         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
28996         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
28997         override_config_conv = UserConfig_clone(&override_config_conv);
28998         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
28999         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
29000         return (int64_t)ret_conv;
29001 }
29002
29003 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
29004         LDKChannelManager this_arg_conv;
29005         this_arg_conv.inner = (void*)(this_arg & (~1));
29006         this_arg_conv.is_owned = false;
29007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29008         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
29009         int64_tArray ret_arr = NULL;
29010         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29011         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29012         for (size_t q = 0; q < ret_var.datalen; q++) {
29013                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
29014                 int64_t ret_conv_16_ref = 0;
29015                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29016                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29017                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
29018                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
29019                 if (ret_conv_16_var.is_owned) {
29020                         ret_conv_16_ref |= 1;
29021                 }
29022                 ret_arr_ptr[q] = ret_conv_16_ref;
29023         }
29024         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29025         FREE(ret_var.data);
29026         return ret_arr;
29027 }
29028
29029 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
29030         LDKChannelManager this_arg_conv;
29031         this_arg_conv.inner = (void*)(this_arg & (~1));
29032         this_arg_conv.is_owned = false;
29033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29034         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
29035         int64_tArray ret_arr = NULL;
29036         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29037         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29038         for (size_t q = 0; q < ret_var.datalen; q++) {
29039                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
29040                 int64_t ret_conv_16_ref = 0;
29041                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29042                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29043                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
29044                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
29045                 if (ret_conv_16_var.is_owned) {
29046                         ret_conv_16_ref |= 1;
29047                 }
29048                 ret_arr_ptr[q] = ret_conv_16_ref;
29049         }
29050         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29051         FREE(ret_var.data);
29052         return ret_arr;
29053 }
29054
29055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
29056         LDKChannelManager this_arg_conv;
29057         this_arg_conv.inner = (void*)(this_arg & (~1));
29058         this_arg_conv.is_owned = false;
29059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29060         unsigned char channel_id_arr[32];
29061         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
29062         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
29063         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
29064         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29065         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
29066         return (int64_t)ret_conv;
29067 }
29068
29069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel_1with_1target_1feerate(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int32_t target_feerate_sats_per_1000_weight) {
29070         LDKChannelManager this_arg_conv;
29071         this_arg_conv.inner = (void*)(this_arg & (~1));
29072         this_arg_conv.is_owned = false;
29073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29074         unsigned char channel_id_arr[32];
29075         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
29076         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
29077         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
29078         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29079         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
29080         return (int64_t)ret_conv;
29081 }
29082
29083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
29084         LDKChannelManager this_arg_conv;
29085         this_arg_conv.inner = (void*)(this_arg & (~1));
29086         this_arg_conv.is_owned = false;
29087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29088         unsigned char channel_id_arr[32];
29089         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
29090         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
29091         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
29092         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29093         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
29094         return (int64_t)ret_conv;
29095 }
29096
29097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
29098         LDKChannelManager this_arg_conv;
29099         this_arg_conv.inner = (void*)(this_arg & (~1));
29100         this_arg_conv.is_owned = false;
29101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29102         ChannelManager_force_close_all_channels(&this_arg_conv);
29103 }
29104
29105 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) {
29106         LDKChannelManager this_arg_conv;
29107         this_arg_conv.inner = (void*)(this_arg & (~1));
29108         this_arg_conv.is_owned = false;
29109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29110         LDKRoute route_conv;
29111         route_conv.inner = (void*)(route & (~1));
29112         route_conv.is_owned = false;
29113         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
29114         LDKThirtyTwoBytes payment_hash_ref;
29115         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29116         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
29117         LDKThirtyTwoBytes payment_secret_ref;
29118         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
29119         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
29120         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
29121         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
29122         return (int64_t)ret_conv;
29123 }
29124
29125 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) {
29126         LDKChannelManager this_arg_conv;
29127         this_arg_conv.inner = (void*)(this_arg & (~1));
29128         this_arg_conv.is_owned = false;
29129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29130         LDKRoute route_conv;
29131         route_conv.inner = (void*)(route & (~1));
29132         route_conv.is_owned = false;
29133         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
29134         LDKThirtyTwoBytes payment_id_ref;
29135         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
29136         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
29137         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
29138         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
29139         return (int64_t)ret_conv;
29140 }
29141
29142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
29143         LDKChannelManager this_arg_conv;
29144         this_arg_conv.inner = (void*)(this_arg & (~1));
29145         this_arg_conv.is_owned = false;
29146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29147         LDKThirtyTwoBytes payment_id_ref;
29148         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
29149         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
29150         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
29151 }
29152
29153 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) {
29154         LDKChannelManager this_arg_conv;
29155         this_arg_conv.inner = (void*)(this_arg & (~1));
29156         this_arg_conv.is_owned = false;
29157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29158         LDKRoute route_conv;
29159         route_conv.inner = (void*)(route & (~1));
29160         route_conv.is_owned = false;
29161         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
29162         LDKThirtyTwoBytes payment_preimage_ref;
29163         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
29164         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
29165         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
29166         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
29167         return (int64_t)ret_conv;
29168 }
29169
29170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1funding_1transaction_1generated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
29171         LDKChannelManager this_arg_conv;
29172         this_arg_conv.inner = (void*)(this_arg & (~1));
29173         this_arg_conv.is_owned = false;
29174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29175         unsigned char temporary_channel_id_arr[32];
29176         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
29177         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
29178         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
29179         LDKTransaction funding_transaction_ref;
29180         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
29181         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
29182         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
29183         funding_transaction_ref.data_is_owned = true;
29184         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29185         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
29186         return (int64_t)ret_conv;
29187 }
29188
29189 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) {
29190         LDKChannelManager this_arg_conv;
29191         this_arg_conv.inner = (void*)(this_arg & (~1));
29192         this_arg_conv.is_owned = false;
29193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29194         LDKThreeBytes rgb_ref;
29195         CHECK((*env)->GetArrayLength(env, rgb) == 3);
29196         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
29197         LDKThirtyTwoBytes alias_ref;
29198         CHECK((*env)->GetArrayLength(env, alias) == 32);
29199         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
29200         LDKCVec_NetAddressZ addresses_constr;
29201         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
29202         if (addresses_constr.datalen > 0)
29203                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
29204         else
29205                 addresses_constr.data = NULL;
29206         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
29207         for (size_t m = 0; m < addresses_constr.datalen; m++) {
29208                 int64_t addresses_conv_12 = addresses_vals[m];
29209                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
29210                 CHECK_ACCESS(addresses_conv_12_ptr);
29211                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
29212                 addresses_constr.data[m] = addresses_conv_12_conv;
29213         }
29214         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
29215         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
29216 }
29217
29218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
29219         LDKChannelManager this_arg_conv;
29220         this_arg_conv.inner = (void*)(this_arg & (~1));
29221         this_arg_conv.is_owned = false;
29222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29223         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
29224 }
29225
29226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
29227         LDKChannelManager this_arg_conv;
29228         this_arg_conv.inner = (void*)(this_arg & (~1));
29229         this_arg_conv.is_owned = false;
29230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29231         ChannelManager_timer_tick_occurred(&this_arg_conv);
29232 }
29233
29234 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
29235         LDKChannelManager this_arg_conv;
29236         this_arg_conv.inner = (void*)(this_arg & (~1));
29237         this_arg_conv.is_owned = false;
29238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29239         unsigned char payment_hash_arr[32];
29240         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29241         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
29242         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
29243         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
29244         return ret_val;
29245 }
29246
29247 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
29248         LDKChannelManager this_arg_conv;
29249         this_arg_conv.inner = (void*)(this_arg & (~1));
29250         this_arg_conv.is_owned = false;
29251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29252         LDKThirtyTwoBytes payment_preimage_ref;
29253         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
29254         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
29255         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
29256         return ret_val;
29257 }
29258
29259 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29260         LDKChannelManager this_arg_conv;
29261         this_arg_conv.inner = (void*)(this_arg & (~1));
29262         this_arg_conv.is_owned = false;
29263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29264         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29265         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
29266         return ret_arr;
29267 }
29268
29269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1accept_1inbound_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int64_t user_channel_id) {
29270         LDKChannelManager this_arg_conv;
29271         this_arg_conv.inner = (void*)(this_arg & (~1));
29272         this_arg_conv.is_owned = false;
29273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29274         unsigned char temporary_channel_id_arr[32];
29275         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
29276         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
29277         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
29278         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29279         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, user_channel_id);
29280         return (int64_t)ret_conv;
29281 }
29282
29283 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) {
29284         LDKChannelManager this_arg_conv;
29285         this_arg_conv.inner = (void*)(this_arg & (~1));
29286         this_arg_conv.is_owned = false;
29287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29288         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
29289         CHECK_ACCESS(min_value_msat_ptr);
29290         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
29291         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
29292         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
29293         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
29294         return (int64_t)ret_conv;
29295 }
29296
29297 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) {
29298         LDKChannelManager this_arg_conv;
29299         this_arg_conv.inner = (void*)(this_arg & (~1));
29300         this_arg_conv.is_owned = false;
29301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29302         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
29303         CHECK_ACCESS(min_value_msat_ptr);
29304         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
29305         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
29306         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
29307         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
29308         return (int64_t)ret_conv;
29309 }
29310
29311 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) {
29312         LDKChannelManager this_arg_conv;
29313         this_arg_conv.inner = (void*)(this_arg & (~1));
29314         this_arg_conv.is_owned = false;
29315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29316         LDKThirtyTwoBytes payment_hash_ref;
29317         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29318         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
29319         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
29320         CHECK_ACCESS(min_value_msat_ptr);
29321         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
29322         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
29323         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
29324         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
29325         return (int64_t)ret_conv;
29326 }
29327
29328 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) {
29329         LDKChannelManager this_arg_conv;
29330         this_arg_conv.inner = (void*)(this_arg & (~1));
29331         this_arg_conv.is_owned = false;
29332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29333         LDKThirtyTwoBytes payment_hash_ref;
29334         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29335         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
29336         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
29337         CHECK_ACCESS(min_value_msat_ptr);
29338         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
29339         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
29340         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
29341         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
29342         return (int64_t)ret_conv;
29343 }
29344
29345 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) {
29346         LDKChannelManager this_arg_conv;
29347         this_arg_conv.inner = (void*)(this_arg & (~1));
29348         this_arg_conv.is_owned = false;
29349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29350         LDKThirtyTwoBytes payment_hash_ref;
29351         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29352         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
29353         LDKThirtyTwoBytes payment_secret_ref;
29354         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
29355         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
29356         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
29357         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
29358         return (int64_t)ret_conv;
29359 }
29360
29361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
29362         LDKChannelManager this_arg_conv;
29363         this_arg_conv.inner = (void*)(this_arg & (~1));
29364         this_arg_conv.is_owned = false;
29365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29366         int64_t ret_val = ChannelManager_get_phantom_scid(&this_arg_conv);
29367         return ret_val;
29368 }
29369
29370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
29371         LDKChannelManager this_arg_conv;
29372         this_arg_conv.inner = (void*)(this_arg & (~1));
29373         this_arg_conv.is_owned = false;
29374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29375         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
29376         int64_t ret_ref = 0;
29377         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29378         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29379         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29380         ret_ref = (uintptr_t)ret_var.inner;
29381         if (ret_var.is_owned) {
29382                 ret_ref |= 1;
29383         }
29384         return ret_ref;
29385 }
29386
29387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
29388         LDKChannelManager this_arg_conv;
29389         this_arg_conv.inner = (void*)(this_arg & (~1));
29390         this_arg_conv.is_owned = false;
29391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29392         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
29393         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
29394         return (int64_t)ret_ret;
29395 }
29396
29397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
29398         LDKChannelManager this_arg_conv;
29399         this_arg_conv.inner = (void*)(this_arg & (~1));
29400         this_arg_conv.is_owned = false;
29401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29402         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
29403         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
29404         return (int64_t)ret_ret;
29405 }
29406
29407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
29408         LDKChannelManager this_arg_conv;
29409         this_arg_conv.inner = (void*)(this_arg & (~1));
29410         this_arg_conv.is_owned = false;
29411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29412         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
29413         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
29414         return (int64_t)ret_ret;
29415 }
29416
29417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
29418         LDKChannelManager this_arg_conv;
29419         this_arg_conv.inner = (void*)(this_arg & (~1));
29420         this_arg_conv.is_owned = false;
29421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29422         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
29423         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
29424         return (int64_t)ret_ret;
29425 }
29426
29427 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) {
29428         LDKChannelManager this_arg_conv;
29429         this_arg_conv.inner = (void*)(this_arg & (~1));
29430         this_arg_conv.is_owned = false;
29431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29432         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
29433         return ret_val;
29434 }
29435
29436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
29437         LDKChannelManager this_arg_conv;
29438         this_arg_conv.inner = (void*)(this_arg & (~1));
29439         this_arg_conv.is_owned = false;
29440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29441         ChannelManager_await_persistable_update(&this_arg_conv);
29442 }
29443
29444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
29445         LDKChannelManager this_arg_conv;
29446         this_arg_conv.inner = (void*)(this_arg & (~1));
29447         this_arg_conv.is_owned = false;
29448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29449         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
29450         int64_t ret_ref = 0;
29451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29454         ret_ref = (uintptr_t)ret_var.inner;
29455         if (ret_var.is_owned) {
29456                 ret_ref |= 1;
29457         }
29458         return ret_ref;
29459 }
29460
29461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
29462         LDKChannelManager this_arg_conv;
29463         this_arg_conv.inner = (void*)(this_arg & (~1));
29464         this_arg_conv.is_owned = false;
29465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29466         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
29467         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
29468         return (int64_t)ret_ret;
29469 }
29470
29471 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
29472         LDKCounterpartyForwardingInfo obj_conv;
29473         obj_conv.inner = (void*)(obj & (~1));
29474         obj_conv.is_owned = false;
29475         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29476         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
29477         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29478         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29479         CVec_u8Z_free(ret_var);
29480         return ret_arr;
29481 }
29482
29483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29484         LDKu8slice ser_ref;
29485         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29486         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29487         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
29488         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
29489         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29490         return (int64_t)ret_conv;
29491 }
29492
29493 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
29494         LDKChannelCounterparty obj_conv;
29495         obj_conv.inner = (void*)(obj & (~1));
29496         obj_conv.is_owned = false;
29497         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29498         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
29499         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29500         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29501         CVec_u8Z_free(ret_var);
29502         return ret_arr;
29503 }
29504
29505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29506         LDKu8slice ser_ref;
29507         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29508         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29509         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
29510         *ret_conv = ChannelCounterparty_read(ser_ref);
29511         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29512         return (int64_t)ret_conv;
29513 }
29514
29515 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
29516         LDKChannelDetails obj_conv;
29517         obj_conv.inner = (void*)(obj & (~1));
29518         obj_conv.is_owned = false;
29519         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29520         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
29521         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29522         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29523         CVec_u8Z_free(ret_var);
29524         return ret_arr;
29525 }
29526
29527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29528         LDKu8slice ser_ref;
29529         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29530         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29531         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
29532         *ret_conv = ChannelDetails_read(ser_ref);
29533         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29534         return (int64_t)ret_conv;
29535 }
29536
29537 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
29538         LDKPhantomRouteHints obj_conv;
29539         obj_conv.inner = (void*)(obj & (~1));
29540         obj_conv.is_owned = false;
29541         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29542         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
29543         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29544         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29545         CVec_u8Z_free(ret_var);
29546         return ret_arr;
29547 }
29548
29549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29550         LDKu8slice ser_ref;
29551         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29552         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29553         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
29554         *ret_conv = PhantomRouteHints_read(ser_ref);
29555         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29556         return (int64_t)ret_conv;
29557 }
29558
29559 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
29560         LDKChannelManager obj_conv;
29561         obj_conv.inner = (void*)(obj & (~1));
29562         obj_conv.is_owned = false;
29563         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29564         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
29565         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29566         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29567         CVec_u8Z_free(ret_var);
29568         return ret_arr;
29569 }
29570
29571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29572         LDKChannelManagerReadArgs this_obj_conv;
29573         this_obj_conv.inner = (void*)(this_obj & (~1));
29574         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29576         ChannelManagerReadArgs_free(this_obj_conv);
29577 }
29578
29579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
29580         LDKChannelManagerReadArgs this_ptr_conv;
29581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29582         this_ptr_conv.is_owned = false;
29583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29584         // WARNING: This object doesn't live past this scope, needs clone!
29585         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
29586         return ret_ret;
29587 }
29588
29589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29590         LDKChannelManagerReadArgs 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         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
29597         if (val_conv.free == LDKKeysInterface_JCalls_free) {
29598                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29599                 LDKKeysInterface_JCalls_cloned(&val_conv);
29600         }
29601         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
29602 }
29603
29604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
29605         LDKChannelManagerReadArgs this_ptr_conv;
29606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29607         this_ptr_conv.is_owned = false;
29608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29609         // WARNING: This object doesn't live past this scope, needs clone!
29610         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
29611         return ret_ret;
29612 }
29613
29614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29615         LDKChannelManagerReadArgs this_ptr_conv;
29616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29617         this_ptr_conv.is_owned = false;
29618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29619         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29620         CHECK_ACCESS(val_ptr);
29621         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
29622         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
29623                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29624                 LDKFeeEstimator_JCalls_cloned(&val_conv);
29625         }
29626         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
29627 }
29628
29629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
29630         LDKChannelManagerReadArgs this_ptr_conv;
29631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29632         this_ptr_conv.is_owned = false;
29633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29634         // WARNING: This object doesn't live past this scope, needs clone!
29635         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
29636         return ret_ret;
29637 }
29638
29639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29640         LDKChannelManagerReadArgs this_ptr_conv;
29641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29642         this_ptr_conv.is_owned = false;
29643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29644         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29645         CHECK_ACCESS(val_ptr);
29646         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
29647         if (val_conv.free == LDKWatch_JCalls_free) {
29648                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29649                 LDKWatch_JCalls_cloned(&val_conv);
29650         }
29651         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
29652 }
29653
29654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
29655         LDKChannelManagerReadArgs this_ptr_conv;
29656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29657         this_ptr_conv.is_owned = false;
29658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29659         // WARNING: This object doesn't live past this scope, needs clone!
29660         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
29661         return ret_ret;
29662 }
29663
29664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29665         LDKChannelManagerReadArgs this_ptr_conv;
29666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29667         this_ptr_conv.is_owned = false;
29668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29669         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29670         CHECK_ACCESS(val_ptr);
29671         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
29672         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
29673                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29674                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
29675         }
29676         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
29677 }
29678
29679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
29680         LDKChannelManagerReadArgs this_ptr_conv;
29681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29682         this_ptr_conv.is_owned = false;
29683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29684         // WARNING: This object doesn't live past this scope, needs clone!
29685         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
29686         return ret_ret;
29687 }
29688
29689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29690         LDKChannelManagerReadArgs this_ptr_conv;
29691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29692         this_ptr_conv.is_owned = false;
29693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29694         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29695         CHECK_ACCESS(val_ptr);
29696         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
29697         if (val_conv.free == LDKLogger_JCalls_free) {
29698                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29699                 LDKLogger_JCalls_cloned(&val_conv);
29700         }
29701         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
29702 }
29703
29704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
29705         LDKChannelManagerReadArgs this_ptr_conv;
29706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29707         this_ptr_conv.is_owned = false;
29708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29709         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
29710         int64_t ret_ref = 0;
29711         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29712         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29714         ret_ref = (uintptr_t)ret_var.inner;
29715         if (ret_var.is_owned) {
29716                 ret_ref |= 1;
29717         }
29718         return ret_ref;
29719 }
29720
29721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29722         LDKChannelManagerReadArgs this_ptr_conv;
29723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29724         this_ptr_conv.is_owned = false;
29725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29726         LDKUserConfig val_conv;
29727         val_conv.inner = (void*)(val & (~1));
29728         val_conv.is_owned = (val & 1) || (val == 0);
29729         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29730         val_conv = UserConfig_clone(&val_conv);
29731         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
29732 }
29733
29734 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) {
29735         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
29736         CHECK_ACCESS(keys_manager_ptr);
29737         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
29738         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
29739                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29740                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
29741         }
29742         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
29743         CHECK_ACCESS(fee_estimator_ptr);
29744         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29745         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29746                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29747                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29748         }
29749         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
29750         CHECK_ACCESS(chain_monitor_ptr);
29751         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
29752         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
29753                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29754                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
29755         }
29756         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
29757         CHECK_ACCESS(tx_broadcaster_ptr);
29758         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
29759         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29760                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29761                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
29762         }
29763         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
29764         CHECK_ACCESS(logger_ptr);
29765         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29766         if (logger_conv.free == LDKLogger_JCalls_free) {
29767                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29768                 LDKLogger_JCalls_cloned(&logger_conv);
29769         }
29770         LDKUserConfig default_config_conv;
29771         default_config_conv.inner = (void*)(default_config & (~1));
29772         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
29773         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
29774         default_config_conv = UserConfig_clone(&default_config_conv);
29775         LDKCVec_ChannelMonitorZ channel_monitors_constr;
29776         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
29777         if (channel_monitors_constr.datalen > 0)
29778                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
29779         else
29780                 channel_monitors_constr.data = NULL;
29781         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
29782         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
29783                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
29784                 LDKChannelMonitor channel_monitors_conv_16_conv;
29785                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
29786                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
29787                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
29788                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
29789         }
29790         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
29791         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);
29792         int64_t ret_ref = 0;
29793         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29794         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29796         ret_ref = (uintptr_t)ret_var.inner;
29797         if (ret_var.is_owned) {
29798                 ret_ref |= 1;
29799         }
29800         return ret_ref;
29801 }
29802
29803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
29804         LDKu8slice ser_ref;
29805         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29806         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29807         LDKChannelManagerReadArgs arg_conv;
29808         arg_conv.inner = (void*)(arg & (~1));
29809         arg_conv.is_owned = (arg & 1) || (arg == 0);
29810         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29811         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
29812         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
29813         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
29814         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29815         return (int64_t)ret_conv;
29816 }
29817
29818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29819         LDKDecodeError this_obj_conv;
29820         this_obj_conv.inner = (void*)(this_obj & (~1));
29821         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29823         DecodeError_free(this_obj_conv);
29824 }
29825
29826 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
29827         LDKDecodeError ret_var = DecodeError_clone(arg);
29828 int64_t ret_ref = 0;
29829 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29830 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29831 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29832 ret_ref = (uintptr_t)ret_var.inner;
29833 if (ret_var.is_owned) {
29834         ret_ref |= 1;
29835 }
29836         return ret_ref;
29837 }
29838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29839         LDKDecodeError arg_conv;
29840         arg_conv.inner = (void*)(arg & (~1));
29841         arg_conv.is_owned = false;
29842         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29843         int64_t ret_val = DecodeError_clone_ptr(&arg_conv);
29844         return ret_val;
29845 }
29846
29847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29848         LDKDecodeError orig_conv;
29849         orig_conv.inner = (void*)(orig & (~1));
29850         orig_conv.is_owned = false;
29851         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29852         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
29853         int64_t ret_ref = 0;
29854         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29855         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29857         ret_ref = (uintptr_t)ret_var.inner;
29858         if (ret_var.is_owned) {
29859                 ret_ref |= 1;
29860         }
29861         return ret_ref;
29862 }
29863
29864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29865         LDKInit this_obj_conv;
29866         this_obj_conv.inner = (void*)(this_obj & (~1));
29867         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29869         Init_free(this_obj_conv);
29870 }
29871
29872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
29873         LDKInit this_ptr_conv;
29874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29875         this_ptr_conv.is_owned = false;
29876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29877         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
29878         int64_t ret_ref = 0;
29879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29882         ret_ref = (uintptr_t)ret_var.inner;
29883         if (ret_var.is_owned) {
29884                 ret_ref |= 1;
29885         }
29886         return ret_ref;
29887 }
29888
29889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29890         LDKInit this_ptr_conv;
29891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29892         this_ptr_conv.is_owned = false;
29893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29894         LDKInitFeatures val_conv;
29895         val_conv.inner = (void*)(val & (~1));
29896         val_conv.is_owned = (val & 1) || (val == 0);
29897         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29898         val_conv = InitFeatures_clone(&val_conv);
29899         Init_set_features(&this_ptr_conv, val_conv);
29900 }
29901
29902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
29903         LDKInit this_ptr_conv;
29904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29905         this_ptr_conv.is_owned = false;
29906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29907         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
29908         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
29909         int64_t ret_ref = (uintptr_t)ret_copy;
29910         return ret_ref;
29911 }
29912
29913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29914         LDKInit this_ptr_conv;
29915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29916         this_ptr_conv.is_owned = false;
29917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29918         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29919         CHECK_ACCESS(val_ptr);
29920         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
29921         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
29922         Init_set_remote_network_address(&this_ptr_conv, val_conv);
29923 }
29924
29925 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) {
29926         LDKInitFeatures features_arg_conv;
29927         features_arg_conv.inner = (void*)(features_arg & (~1));
29928         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
29929         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
29930         features_arg_conv = InitFeatures_clone(&features_arg_conv);
29931         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
29932         CHECK_ACCESS(remote_network_address_arg_ptr);
29933         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
29934         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
29935         int64_t ret_ref = 0;
29936         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29937         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29939         ret_ref = (uintptr_t)ret_var.inner;
29940         if (ret_var.is_owned) {
29941                 ret_ref |= 1;
29942         }
29943         return ret_ref;
29944 }
29945
29946 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
29947         LDKInit ret_var = Init_clone(arg);
29948 int64_t ret_ref = 0;
29949 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29950 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29951 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29952 ret_ref = (uintptr_t)ret_var.inner;
29953 if (ret_var.is_owned) {
29954         ret_ref |= 1;
29955 }
29956         return ret_ref;
29957 }
29958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29959         LDKInit arg_conv;
29960         arg_conv.inner = (void*)(arg & (~1));
29961         arg_conv.is_owned = false;
29962         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29963         int64_t ret_val = Init_clone_ptr(&arg_conv);
29964         return ret_val;
29965 }
29966
29967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29968         LDKInit orig_conv;
29969         orig_conv.inner = (void*)(orig & (~1));
29970         orig_conv.is_owned = false;
29971         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29972         LDKInit ret_var = Init_clone(&orig_conv);
29973         int64_t ret_ref = 0;
29974         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29975         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29976         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29977         ret_ref = (uintptr_t)ret_var.inner;
29978         if (ret_var.is_owned) {
29979                 ret_ref |= 1;
29980         }
29981         return ret_ref;
29982 }
29983
29984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29985         LDKErrorMessage this_obj_conv;
29986         this_obj_conv.inner = (void*)(this_obj & (~1));
29987         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29989         ErrorMessage_free(this_obj_conv);
29990 }
29991
29992 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29993         LDKErrorMessage this_ptr_conv;
29994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29995         this_ptr_conv.is_owned = false;
29996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29997         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29998         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
29999         return ret_arr;
30000 }
30001
30002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30003         LDKErrorMessage this_ptr_conv;
30004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30005         this_ptr_conv.is_owned = false;
30006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30007         LDKThirtyTwoBytes val_ref;
30008         CHECK((*env)->GetArrayLength(env, val) == 32);
30009         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30010         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
30011 }
30012
30013 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
30014         LDKErrorMessage this_ptr_conv;
30015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30016         this_ptr_conv.is_owned = false;
30017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30018         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
30019         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30020         Str_free(ret_str);
30021         return ret_conv;
30022 }
30023
30024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
30025         LDKErrorMessage this_ptr_conv;
30026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30027         this_ptr_conv.is_owned = false;
30028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30029         LDKStr val_conv = java_to_owned_str(env, val);
30030         ErrorMessage_set_data(&this_ptr_conv, val_conv);
30031 }
30032
30033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
30034         LDKThirtyTwoBytes channel_id_arg_ref;
30035         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30036         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30037         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
30038         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
30039         int64_t ret_ref = 0;
30040         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30041         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30042         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30043         ret_ref = (uintptr_t)ret_var.inner;
30044         if (ret_var.is_owned) {
30045                 ret_ref |= 1;
30046         }
30047         return ret_ref;
30048 }
30049
30050 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
30051         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
30052 int64_t ret_ref = 0;
30053 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30054 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30055 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30056 ret_ref = (uintptr_t)ret_var.inner;
30057 if (ret_var.is_owned) {
30058         ret_ref |= 1;
30059 }
30060         return ret_ref;
30061 }
30062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30063         LDKErrorMessage arg_conv;
30064         arg_conv.inner = (void*)(arg & (~1));
30065         arg_conv.is_owned = false;
30066         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30067         int64_t ret_val = ErrorMessage_clone_ptr(&arg_conv);
30068         return ret_val;
30069 }
30070
30071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30072         LDKErrorMessage orig_conv;
30073         orig_conv.inner = (void*)(orig & (~1));
30074         orig_conv.is_owned = false;
30075         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30076         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
30077         int64_t ret_ref = 0;
30078         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30079         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30081         ret_ref = (uintptr_t)ret_var.inner;
30082         if (ret_var.is_owned) {
30083                 ret_ref |= 1;
30084         }
30085         return ret_ref;
30086 }
30087
30088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30089         LDKWarningMessage this_obj_conv;
30090         this_obj_conv.inner = (void*)(this_obj & (~1));
30091         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30093         WarningMessage_free(this_obj_conv);
30094 }
30095
30096 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30097         LDKWarningMessage this_ptr_conv;
30098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30099         this_ptr_conv.is_owned = false;
30100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30101         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30102         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
30103         return ret_arr;
30104 }
30105
30106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30107         LDKWarningMessage this_ptr_conv;
30108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30109         this_ptr_conv.is_owned = false;
30110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30111         LDKThirtyTwoBytes val_ref;
30112         CHECK((*env)->GetArrayLength(env, val) == 32);
30113         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30114         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
30115 }
30116
30117 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
30118         LDKWarningMessage this_ptr_conv;
30119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30120         this_ptr_conv.is_owned = false;
30121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30122         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
30123         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30124         Str_free(ret_str);
30125         return ret_conv;
30126 }
30127
30128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
30129         LDKWarningMessage this_ptr_conv;
30130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30131         this_ptr_conv.is_owned = false;
30132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30133         LDKStr val_conv = java_to_owned_str(env, val);
30134         WarningMessage_set_data(&this_ptr_conv, val_conv);
30135 }
30136
30137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
30138         LDKThirtyTwoBytes channel_id_arg_ref;
30139         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30140         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30141         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
30142         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
30143         int64_t ret_ref = 0;
30144         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30145         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30147         ret_ref = (uintptr_t)ret_var.inner;
30148         if (ret_var.is_owned) {
30149                 ret_ref |= 1;
30150         }
30151         return ret_ref;
30152 }
30153
30154 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
30155         LDKWarningMessage ret_var = WarningMessage_clone(arg);
30156 int64_t ret_ref = 0;
30157 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30158 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30159 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30160 ret_ref = (uintptr_t)ret_var.inner;
30161 if (ret_var.is_owned) {
30162         ret_ref |= 1;
30163 }
30164         return ret_ref;
30165 }
30166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30167         LDKWarningMessage arg_conv;
30168         arg_conv.inner = (void*)(arg & (~1));
30169         arg_conv.is_owned = false;
30170         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30171         int64_t ret_val = WarningMessage_clone_ptr(&arg_conv);
30172         return ret_val;
30173 }
30174
30175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30176         LDKWarningMessage orig_conv;
30177         orig_conv.inner = (void*)(orig & (~1));
30178         orig_conv.is_owned = false;
30179         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30180         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
30181         int64_t ret_ref = 0;
30182         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30183         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30185         ret_ref = (uintptr_t)ret_var.inner;
30186         if (ret_var.is_owned) {
30187                 ret_ref |= 1;
30188         }
30189         return ret_ref;
30190 }
30191
30192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30193         LDKPing this_obj_conv;
30194         this_obj_conv.inner = (void*)(this_obj & (~1));
30195         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30197         Ping_free(this_obj_conv);
30198 }
30199
30200 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
30201         LDKPing this_ptr_conv;
30202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30203         this_ptr_conv.is_owned = false;
30204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30205         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
30206         return ret_val;
30207 }
30208
30209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30210         LDKPing this_ptr_conv;
30211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30212         this_ptr_conv.is_owned = false;
30213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30214         Ping_set_ponglen(&this_ptr_conv, val);
30215 }
30216
30217 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
30218         LDKPing this_ptr_conv;
30219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30220         this_ptr_conv.is_owned = false;
30221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30222         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
30223         return ret_val;
30224 }
30225
30226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30227         LDKPing this_ptr_conv;
30228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30229         this_ptr_conv.is_owned = false;
30230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30231         Ping_set_byteslen(&this_ptr_conv, val);
30232 }
30233
30234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
30235         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
30236         int64_t ret_ref = 0;
30237         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30238         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30240         ret_ref = (uintptr_t)ret_var.inner;
30241         if (ret_var.is_owned) {
30242                 ret_ref |= 1;
30243         }
30244         return ret_ref;
30245 }
30246
30247 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
30248         LDKPing ret_var = Ping_clone(arg);
30249 int64_t ret_ref = 0;
30250 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30251 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30252 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30253 ret_ref = (uintptr_t)ret_var.inner;
30254 if (ret_var.is_owned) {
30255         ret_ref |= 1;
30256 }
30257         return ret_ref;
30258 }
30259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30260         LDKPing arg_conv;
30261         arg_conv.inner = (void*)(arg & (~1));
30262         arg_conv.is_owned = false;
30263         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30264         int64_t ret_val = Ping_clone_ptr(&arg_conv);
30265         return ret_val;
30266 }
30267
30268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30269         LDKPing orig_conv;
30270         orig_conv.inner = (void*)(orig & (~1));
30271         orig_conv.is_owned = false;
30272         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30273         LDKPing ret_var = Ping_clone(&orig_conv);
30274         int64_t ret_ref = 0;
30275         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30276         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30278         ret_ref = (uintptr_t)ret_var.inner;
30279         if (ret_var.is_owned) {
30280                 ret_ref |= 1;
30281         }
30282         return ret_ref;
30283 }
30284
30285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30286         LDKPong this_obj_conv;
30287         this_obj_conv.inner = (void*)(this_obj & (~1));
30288         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30290         Pong_free(this_obj_conv);
30291 }
30292
30293 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
30294         LDKPong this_ptr_conv;
30295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30296         this_ptr_conv.is_owned = false;
30297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30298         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
30299         return ret_val;
30300 }
30301
30302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30303         LDKPong this_ptr_conv;
30304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30305         this_ptr_conv.is_owned = false;
30306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30307         Pong_set_byteslen(&this_ptr_conv, val);
30308 }
30309
30310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
30311         LDKPong ret_var = Pong_new(byteslen_arg);
30312         int64_t ret_ref = 0;
30313         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30314         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30316         ret_ref = (uintptr_t)ret_var.inner;
30317         if (ret_var.is_owned) {
30318                 ret_ref |= 1;
30319         }
30320         return ret_ref;
30321 }
30322
30323 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
30324         LDKPong ret_var = Pong_clone(arg);
30325 int64_t ret_ref = 0;
30326 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30327 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30328 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30329 ret_ref = (uintptr_t)ret_var.inner;
30330 if (ret_var.is_owned) {
30331         ret_ref |= 1;
30332 }
30333         return ret_ref;
30334 }
30335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30336         LDKPong arg_conv;
30337         arg_conv.inner = (void*)(arg & (~1));
30338         arg_conv.is_owned = false;
30339         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30340         int64_t ret_val = Pong_clone_ptr(&arg_conv);
30341         return ret_val;
30342 }
30343
30344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30345         LDKPong orig_conv;
30346         orig_conv.inner = (void*)(orig & (~1));
30347         orig_conv.is_owned = false;
30348         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30349         LDKPong ret_var = Pong_clone(&orig_conv);
30350         int64_t ret_ref = 0;
30351         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30352         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30354         ret_ref = (uintptr_t)ret_var.inner;
30355         if (ret_var.is_owned) {
30356                 ret_ref |= 1;
30357         }
30358         return ret_ref;
30359 }
30360
30361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30362         LDKOpenChannel this_obj_conv;
30363         this_obj_conv.inner = (void*)(this_obj & (~1));
30364         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30366         OpenChannel_free(this_obj_conv);
30367 }
30368
30369 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
30370         LDKOpenChannel this_ptr_conv;
30371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30372         this_ptr_conv.is_owned = false;
30373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30374         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30375         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
30376         return ret_arr;
30377 }
30378
30379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30380         LDKOpenChannel this_ptr_conv;
30381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30382         this_ptr_conv.is_owned = false;
30383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30384         LDKThirtyTwoBytes val_ref;
30385         CHECK((*env)->GetArrayLength(env, val) == 32);
30386         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30387         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
30388 }
30389
30390 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30391         LDKOpenChannel this_ptr_conv;
30392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30393         this_ptr_conv.is_owned = false;
30394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30395         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30396         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
30397         return ret_arr;
30398 }
30399
30400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30401         LDKOpenChannel this_ptr_conv;
30402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30403         this_ptr_conv.is_owned = false;
30404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30405         LDKThirtyTwoBytes val_ref;
30406         CHECK((*env)->GetArrayLength(env, val) == 32);
30407         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30408         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
30409 }
30410
30411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30412         LDKOpenChannel this_ptr_conv;
30413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30414         this_ptr_conv.is_owned = false;
30415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30416         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
30417         return ret_val;
30418 }
30419
30420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30421         LDKOpenChannel this_ptr_conv;
30422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30423         this_ptr_conv.is_owned = false;
30424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30425         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
30426 }
30427
30428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30429         LDKOpenChannel this_ptr_conv;
30430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30431         this_ptr_conv.is_owned = false;
30432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30433         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
30434         return ret_val;
30435 }
30436
30437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30438         LDKOpenChannel this_ptr_conv;
30439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30440         this_ptr_conv.is_owned = false;
30441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30442         OpenChannel_set_push_msat(&this_ptr_conv, val);
30443 }
30444
30445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30446         LDKOpenChannel this_ptr_conv;
30447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30448         this_ptr_conv.is_owned = false;
30449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30450         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
30451         return ret_val;
30452 }
30453
30454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30455         LDKOpenChannel this_ptr_conv;
30456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30457         this_ptr_conv.is_owned = false;
30458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30459         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
30460 }
30461
30462 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) {
30463         LDKOpenChannel this_ptr_conv;
30464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30465         this_ptr_conv.is_owned = false;
30466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30467         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
30468         return ret_val;
30469 }
30470
30471 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) {
30472         LDKOpenChannel this_ptr_conv;
30473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30474         this_ptr_conv.is_owned = false;
30475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30476         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
30477 }
30478
30479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30480         LDKOpenChannel this_ptr_conv;
30481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30482         this_ptr_conv.is_owned = false;
30483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30484         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
30485         return ret_val;
30486 }
30487
30488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30489         LDKOpenChannel this_ptr_conv;
30490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30491         this_ptr_conv.is_owned = false;
30492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30493         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
30494 }
30495
30496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30497         LDKOpenChannel this_ptr_conv;
30498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30499         this_ptr_conv.is_owned = false;
30500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30501         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
30502         return ret_val;
30503 }
30504
30505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30506         LDKOpenChannel this_ptr_conv;
30507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30508         this_ptr_conv.is_owned = false;
30509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30510         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
30511 }
30512
30513 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
30514         LDKOpenChannel this_ptr_conv;
30515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30516         this_ptr_conv.is_owned = false;
30517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30518         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
30519         return ret_val;
30520 }
30521
30522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30523         LDKOpenChannel this_ptr_conv;
30524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30525         this_ptr_conv.is_owned = false;
30526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30527         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
30528 }
30529
30530 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30531         LDKOpenChannel this_ptr_conv;
30532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30533         this_ptr_conv.is_owned = false;
30534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30535         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
30536         return ret_val;
30537 }
30538
30539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30540         LDKOpenChannel this_ptr_conv;
30541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30542         this_ptr_conv.is_owned = false;
30543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30544         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
30545 }
30546
30547 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
30548         LDKOpenChannel this_ptr_conv;
30549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30550         this_ptr_conv.is_owned = false;
30551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30552         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
30553         return ret_val;
30554 }
30555
30556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30557         LDKOpenChannel this_ptr_conv;
30558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30559         this_ptr_conv.is_owned = false;
30560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30561         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
30562 }
30563
30564 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30565         LDKOpenChannel this_ptr_conv;
30566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30567         this_ptr_conv.is_owned = false;
30568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30569         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30570         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
30571         return ret_arr;
30572 }
30573
30574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30575         LDKOpenChannel this_ptr_conv;
30576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30577         this_ptr_conv.is_owned = false;
30578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30579         LDKPublicKey val_ref;
30580         CHECK((*env)->GetArrayLength(env, val) == 33);
30581         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30582         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
30583 }
30584
30585 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30586         LDKOpenChannel this_ptr_conv;
30587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30588         this_ptr_conv.is_owned = false;
30589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30590         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30591         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
30592         return ret_arr;
30593 }
30594
30595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30596         LDKOpenChannel this_ptr_conv;
30597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30598         this_ptr_conv.is_owned = false;
30599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30600         LDKPublicKey val_ref;
30601         CHECK((*env)->GetArrayLength(env, val) == 33);
30602         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30603         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
30604 }
30605
30606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30607         LDKOpenChannel this_ptr_conv;
30608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30609         this_ptr_conv.is_owned = false;
30610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30611         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30612         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
30613         return ret_arr;
30614 }
30615
30616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30617         LDKOpenChannel this_ptr_conv;
30618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30619         this_ptr_conv.is_owned = false;
30620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30621         LDKPublicKey val_ref;
30622         CHECK((*env)->GetArrayLength(env, val) == 33);
30623         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30624         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
30625 }
30626
30627 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30628         LDKOpenChannel this_ptr_conv;
30629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30630         this_ptr_conv.is_owned = false;
30631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30632         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30633         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
30634         return ret_arr;
30635 }
30636
30637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30638         LDKOpenChannel this_ptr_conv;
30639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30640         this_ptr_conv.is_owned = false;
30641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30642         LDKPublicKey val_ref;
30643         CHECK((*env)->GetArrayLength(env, val) == 33);
30644         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30645         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
30646 }
30647
30648 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30649         LDKOpenChannel this_ptr_conv;
30650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30651         this_ptr_conv.is_owned = false;
30652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30653         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30654         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
30655         return ret_arr;
30656 }
30657
30658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30659         LDKOpenChannel this_ptr_conv;
30660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30661         this_ptr_conv.is_owned = false;
30662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30663         LDKPublicKey val_ref;
30664         CHECK((*env)->GetArrayLength(env, val) == 33);
30665         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30666         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
30667 }
30668
30669 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30670         LDKOpenChannel this_ptr_conv;
30671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30672         this_ptr_conv.is_owned = false;
30673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30674         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30675         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
30676         return ret_arr;
30677 }
30678
30679 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) {
30680         LDKOpenChannel this_ptr_conv;
30681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30682         this_ptr_conv.is_owned = false;
30683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30684         LDKPublicKey val_ref;
30685         CHECK((*env)->GetArrayLength(env, val) == 33);
30686         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30687         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
30688 }
30689
30690 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
30691         LDKOpenChannel this_ptr_conv;
30692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30693         this_ptr_conv.is_owned = false;
30694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30695         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
30696         return ret_val;
30697 }
30698
30699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
30700         LDKOpenChannel this_ptr_conv;
30701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30702         this_ptr_conv.is_owned = false;
30703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30704         OpenChannel_set_channel_flags(&this_ptr_conv, val);
30705 }
30706
30707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
30708         LDKOpenChannel this_ptr_conv;
30709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30710         this_ptr_conv.is_owned = false;
30711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30712         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
30713         int64_t ret_ref = 0;
30714         if ((uintptr_t)ret_var.inner > 4096) {
30715                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30716                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30718                 ret_ref = (uintptr_t)ret_var.inner;
30719                 if (ret_var.is_owned) {
30720                         ret_ref |= 1;
30721                 }
30722         }
30723         return ret_ref;
30724 }
30725
30726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30727         LDKOpenChannel this_ptr_conv;
30728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30729         this_ptr_conv.is_owned = false;
30730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30731         LDKChannelTypeFeatures val_conv;
30732         val_conv.inner = (void*)(val & (~1));
30733         val_conv.is_owned = (val & 1) || (val == 0);
30734         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30735         val_conv = ChannelTypeFeatures_clone(&val_conv);
30736         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
30737 }
30738
30739 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
30740         LDKOpenChannel ret_var = OpenChannel_clone(arg);
30741 int64_t ret_ref = 0;
30742 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30743 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30744 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30745 ret_ref = (uintptr_t)ret_var.inner;
30746 if (ret_var.is_owned) {
30747         ret_ref |= 1;
30748 }
30749         return ret_ref;
30750 }
30751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30752         LDKOpenChannel arg_conv;
30753         arg_conv.inner = (void*)(arg & (~1));
30754         arg_conv.is_owned = false;
30755         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30756         int64_t ret_val = OpenChannel_clone_ptr(&arg_conv);
30757         return ret_val;
30758 }
30759
30760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30761         LDKOpenChannel orig_conv;
30762         orig_conv.inner = (void*)(orig & (~1));
30763         orig_conv.is_owned = false;
30764         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30765         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
30766         int64_t ret_ref = 0;
30767         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30768         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30770         ret_ref = (uintptr_t)ret_var.inner;
30771         if (ret_var.is_owned) {
30772                 ret_ref |= 1;
30773         }
30774         return ret_ref;
30775 }
30776
30777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30778         LDKAcceptChannel this_obj_conv;
30779         this_obj_conv.inner = (void*)(this_obj & (~1));
30780         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30782         AcceptChannel_free(this_obj_conv);
30783 }
30784
30785 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30786         LDKAcceptChannel this_ptr_conv;
30787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30788         this_ptr_conv.is_owned = false;
30789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30790         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30791         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
30792         return ret_arr;
30793 }
30794
30795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30796         LDKAcceptChannel this_ptr_conv;
30797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30798         this_ptr_conv.is_owned = false;
30799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30800         LDKThirtyTwoBytes val_ref;
30801         CHECK((*env)->GetArrayLength(env, val) == 32);
30802         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30803         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
30804 }
30805
30806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30807         LDKAcceptChannel this_ptr_conv;
30808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30809         this_ptr_conv.is_owned = false;
30810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30811         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
30812         return ret_val;
30813 }
30814
30815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30816         LDKAcceptChannel this_ptr_conv;
30817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30818         this_ptr_conv.is_owned = false;
30819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30820         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
30821 }
30822
30823 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) {
30824         LDKAcceptChannel 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         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
30829         return ret_val;
30830 }
30831
30832 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) {
30833         LDKAcceptChannel this_ptr_conv;
30834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30835         this_ptr_conv.is_owned = false;
30836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30837         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
30838 }
30839
30840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30841         LDKAcceptChannel this_ptr_conv;
30842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30843         this_ptr_conv.is_owned = false;
30844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30845         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
30846         return ret_val;
30847 }
30848
30849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30850         LDKAcceptChannel this_ptr_conv;
30851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30852         this_ptr_conv.is_owned = false;
30853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30854         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
30855 }
30856
30857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30858         LDKAcceptChannel this_ptr_conv;
30859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30860         this_ptr_conv.is_owned = false;
30861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30862         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
30863         return ret_val;
30864 }
30865
30866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30867         LDKAcceptChannel this_ptr_conv;
30868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30869         this_ptr_conv.is_owned = false;
30870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30871         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
30872 }
30873
30874 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
30875         LDKAcceptChannel this_ptr_conv;
30876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30877         this_ptr_conv.is_owned = false;
30878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30879         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
30880         return ret_val;
30881 }
30882
30883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30884         LDKAcceptChannel 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         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
30889 }
30890
30891 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30892         LDKAcceptChannel this_ptr_conv;
30893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30894         this_ptr_conv.is_owned = false;
30895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30896         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
30897         return ret_val;
30898 }
30899
30900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30901         LDKAcceptChannel this_ptr_conv;
30902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30903         this_ptr_conv.is_owned = false;
30904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30905         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
30906 }
30907
30908 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
30909         LDKAcceptChannel 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         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
30914         return ret_val;
30915 }
30916
30917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30918         LDKAcceptChannel this_ptr_conv;
30919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30920         this_ptr_conv.is_owned = false;
30921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30922         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
30923 }
30924
30925 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30926         LDKAcceptChannel this_ptr_conv;
30927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30928         this_ptr_conv.is_owned = false;
30929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30930         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30931         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
30932         return ret_arr;
30933 }
30934
30935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30936         LDKAcceptChannel this_ptr_conv;
30937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30938         this_ptr_conv.is_owned = false;
30939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30940         LDKPublicKey val_ref;
30941         CHECK((*env)->GetArrayLength(env, val) == 33);
30942         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30943         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
30944 }
30945
30946 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30947         LDKAcceptChannel this_ptr_conv;
30948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30949         this_ptr_conv.is_owned = false;
30950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30951         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30952         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
30953         return ret_arr;
30954 }
30955
30956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30957         LDKAcceptChannel this_ptr_conv;
30958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30959         this_ptr_conv.is_owned = false;
30960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30961         LDKPublicKey val_ref;
30962         CHECK((*env)->GetArrayLength(env, val) == 33);
30963         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30964         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
30965 }
30966
30967 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30968         LDKAcceptChannel this_ptr_conv;
30969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30970         this_ptr_conv.is_owned = false;
30971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30972         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30973         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
30974         return ret_arr;
30975 }
30976
30977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30978         LDKAcceptChannel this_ptr_conv;
30979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30980         this_ptr_conv.is_owned = false;
30981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30982         LDKPublicKey val_ref;
30983         CHECK((*env)->GetArrayLength(env, val) == 33);
30984         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30985         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
30986 }
30987
30988 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30989         LDKAcceptChannel this_ptr_conv;
30990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30991         this_ptr_conv.is_owned = false;
30992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30993         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30994         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
30995         return ret_arr;
30996 }
30997
30998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30999         LDKAcceptChannel this_ptr_conv;
31000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31001         this_ptr_conv.is_owned = false;
31002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31003         LDKPublicKey val_ref;
31004         CHECK((*env)->GetArrayLength(env, val) == 33);
31005         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31006         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
31007 }
31008
31009 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31010         LDKAcceptChannel this_ptr_conv;
31011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31012         this_ptr_conv.is_owned = false;
31013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31014         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31015         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
31016         return ret_arr;
31017 }
31018
31019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31020         LDKAcceptChannel this_ptr_conv;
31021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31022         this_ptr_conv.is_owned = false;
31023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31024         LDKPublicKey val_ref;
31025         CHECK((*env)->GetArrayLength(env, val) == 33);
31026         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31027         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
31028 }
31029
31030 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31031         LDKAcceptChannel this_ptr_conv;
31032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31033         this_ptr_conv.is_owned = false;
31034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31035         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31036         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
31037         return ret_arr;
31038 }
31039
31040 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) {
31041         LDKAcceptChannel this_ptr_conv;
31042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31043         this_ptr_conv.is_owned = false;
31044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31045         LDKPublicKey val_ref;
31046         CHECK((*env)->GetArrayLength(env, val) == 33);
31047         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31048         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
31049 }
31050
31051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
31052         LDKAcceptChannel this_ptr_conv;
31053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31054         this_ptr_conv.is_owned = false;
31055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31056         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
31057         int64_t ret_ref = 0;
31058         if ((uintptr_t)ret_var.inner > 4096) {
31059                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31060                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31062                 ret_ref = (uintptr_t)ret_var.inner;
31063                 if (ret_var.is_owned) {
31064                         ret_ref |= 1;
31065                 }
31066         }
31067         return ret_ref;
31068 }
31069
31070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31071         LDKAcceptChannel this_ptr_conv;
31072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31073         this_ptr_conv.is_owned = false;
31074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31075         LDKChannelTypeFeatures val_conv;
31076         val_conv.inner = (void*)(val & (~1));
31077         val_conv.is_owned = (val & 1) || (val == 0);
31078         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31079         val_conv = ChannelTypeFeatures_clone(&val_conv);
31080         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
31081 }
31082
31083 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
31084         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
31085 int64_t ret_ref = 0;
31086 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31087 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31088 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31089 ret_ref = (uintptr_t)ret_var.inner;
31090 if (ret_var.is_owned) {
31091         ret_ref |= 1;
31092 }
31093         return ret_ref;
31094 }
31095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31096         LDKAcceptChannel arg_conv;
31097         arg_conv.inner = (void*)(arg & (~1));
31098         arg_conv.is_owned = false;
31099         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31100         int64_t ret_val = AcceptChannel_clone_ptr(&arg_conv);
31101         return ret_val;
31102 }
31103
31104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31105         LDKAcceptChannel orig_conv;
31106         orig_conv.inner = (void*)(orig & (~1));
31107         orig_conv.is_owned = false;
31108         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31109         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
31110         int64_t ret_ref = 0;
31111         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31112         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31114         ret_ref = (uintptr_t)ret_var.inner;
31115         if (ret_var.is_owned) {
31116                 ret_ref |= 1;
31117         }
31118         return ret_ref;
31119 }
31120
31121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31122         LDKFundingCreated this_obj_conv;
31123         this_obj_conv.inner = (void*)(this_obj & (~1));
31124         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31126         FundingCreated_free(this_obj_conv);
31127 }
31128
31129 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31130         LDKFundingCreated this_ptr_conv;
31131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31132         this_ptr_conv.is_owned = false;
31133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31134         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31135         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
31136         return ret_arr;
31137 }
31138
31139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31140         LDKFundingCreated this_ptr_conv;
31141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31142         this_ptr_conv.is_owned = false;
31143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31144         LDKThirtyTwoBytes val_ref;
31145         CHECK((*env)->GetArrayLength(env, val) == 32);
31146         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31147         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
31148 }
31149
31150 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
31151         LDKFundingCreated 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31156         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
31157         return ret_arr;
31158 }
31159
31160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31161         LDKFundingCreated this_ptr_conv;
31162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31163         this_ptr_conv.is_owned = false;
31164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31165         LDKThirtyTwoBytes val_ref;
31166         CHECK((*env)->GetArrayLength(env, val) == 32);
31167         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31168         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
31169 }
31170
31171 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
31172         LDKFundingCreated this_ptr_conv;
31173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31174         this_ptr_conv.is_owned = false;
31175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31176         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
31177         return ret_val;
31178 }
31179
31180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31181         LDKFundingCreated 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         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
31186 }
31187
31188 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
31189         LDKFundingCreated this_ptr_conv;
31190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31191         this_ptr_conv.is_owned = false;
31192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31193         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31194         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
31195         return ret_arr;
31196 }
31197
31198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31199         LDKFundingCreated this_ptr_conv;
31200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31201         this_ptr_conv.is_owned = false;
31202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31203         LDKSignature val_ref;
31204         CHECK((*env)->GetArrayLength(env, val) == 64);
31205         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31206         FundingCreated_set_signature(&this_ptr_conv, val_ref);
31207 }
31208
31209 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) {
31210         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
31211         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
31212         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
31213         LDKThirtyTwoBytes funding_txid_arg_ref;
31214         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
31215         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
31216         LDKSignature signature_arg_ref;
31217         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
31218         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
31219         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
31220         int64_t ret_ref = 0;
31221         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31222         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31224         ret_ref = (uintptr_t)ret_var.inner;
31225         if (ret_var.is_owned) {
31226                 ret_ref |= 1;
31227         }
31228         return ret_ref;
31229 }
31230
31231 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
31232         LDKFundingCreated ret_var = FundingCreated_clone(arg);
31233 int64_t ret_ref = 0;
31234 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31235 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31236 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31237 ret_ref = (uintptr_t)ret_var.inner;
31238 if (ret_var.is_owned) {
31239         ret_ref |= 1;
31240 }
31241         return ret_ref;
31242 }
31243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31244         LDKFundingCreated arg_conv;
31245         arg_conv.inner = (void*)(arg & (~1));
31246         arg_conv.is_owned = false;
31247         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31248         int64_t ret_val = FundingCreated_clone_ptr(&arg_conv);
31249         return ret_val;
31250 }
31251
31252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31253         LDKFundingCreated orig_conv;
31254         orig_conv.inner = (void*)(orig & (~1));
31255         orig_conv.is_owned = false;
31256         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31257         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
31258         int64_t ret_ref = 0;
31259         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31260         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31262         ret_ref = (uintptr_t)ret_var.inner;
31263         if (ret_var.is_owned) {
31264                 ret_ref |= 1;
31265         }
31266         return ret_ref;
31267 }
31268
31269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31270         LDKFundingSigned this_obj_conv;
31271         this_obj_conv.inner = (void*)(this_obj & (~1));
31272         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31274         FundingSigned_free(this_obj_conv);
31275 }
31276
31277 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31278         LDKFundingSigned this_ptr_conv;
31279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31280         this_ptr_conv.is_owned = false;
31281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31282         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31283         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
31284         return ret_arr;
31285 }
31286
31287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31288         LDKFundingSigned this_ptr_conv;
31289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31290         this_ptr_conv.is_owned = false;
31291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31292         LDKThirtyTwoBytes val_ref;
31293         CHECK((*env)->GetArrayLength(env, val) == 32);
31294         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31295         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
31296 }
31297
31298 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
31299         LDKFundingSigned this_ptr_conv;
31300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31301         this_ptr_conv.is_owned = false;
31302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31303         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31304         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
31305         return ret_arr;
31306 }
31307
31308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31309         LDKFundingSigned this_ptr_conv;
31310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31311         this_ptr_conv.is_owned = false;
31312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31313         LDKSignature val_ref;
31314         CHECK((*env)->GetArrayLength(env, val) == 64);
31315         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31316         FundingSigned_set_signature(&this_ptr_conv, val_ref);
31317 }
31318
31319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
31320         LDKThirtyTwoBytes channel_id_arg_ref;
31321         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31322         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31323         LDKSignature signature_arg_ref;
31324         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
31325         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
31326         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
31327         int64_t ret_ref = 0;
31328         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31329         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31331         ret_ref = (uintptr_t)ret_var.inner;
31332         if (ret_var.is_owned) {
31333                 ret_ref |= 1;
31334         }
31335         return ret_ref;
31336 }
31337
31338 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
31339         LDKFundingSigned ret_var = FundingSigned_clone(arg);
31340 int64_t ret_ref = 0;
31341 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31342 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31343 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31344 ret_ref = (uintptr_t)ret_var.inner;
31345 if (ret_var.is_owned) {
31346         ret_ref |= 1;
31347 }
31348         return ret_ref;
31349 }
31350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31351         LDKFundingSigned arg_conv;
31352         arg_conv.inner = (void*)(arg & (~1));
31353         arg_conv.is_owned = false;
31354         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31355         int64_t ret_val = FundingSigned_clone_ptr(&arg_conv);
31356         return ret_val;
31357 }
31358
31359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31360         LDKFundingSigned orig_conv;
31361         orig_conv.inner = (void*)(orig & (~1));
31362         orig_conv.is_owned = false;
31363         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31364         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
31365         int64_t ret_ref = 0;
31366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31369         ret_ref = (uintptr_t)ret_var.inner;
31370         if (ret_var.is_owned) {
31371                 ret_ref |= 1;
31372         }
31373         return ret_ref;
31374 }
31375
31376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31377         LDKFundingLocked this_obj_conv;
31378         this_obj_conv.inner = (void*)(this_obj & (~1));
31379         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31381         FundingLocked_free(this_obj_conv);
31382 }
31383
31384 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31385         LDKFundingLocked 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31390         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
31391         return ret_arr;
31392 }
31393
31394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31395         LDKFundingLocked this_ptr_conv;
31396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31397         this_ptr_conv.is_owned = false;
31398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31399         LDKThirtyTwoBytes val_ref;
31400         CHECK((*env)->GetArrayLength(env, val) == 32);
31401         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31402         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
31403 }
31404
31405 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31406         LDKFundingLocked this_ptr_conv;
31407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31408         this_ptr_conv.is_owned = false;
31409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31410         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31411         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
31412         return ret_arr;
31413 }
31414
31415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31416         LDKFundingLocked this_ptr_conv;
31417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31418         this_ptr_conv.is_owned = false;
31419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31420         LDKPublicKey val_ref;
31421         CHECK((*env)->GetArrayLength(env, val) == 33);
31422         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31423         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
31424 }
31425
31426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
31427         LDKFundingLocked this_ptr_conv;
31428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31429         this_ptr_conv.is_owned = false;
31430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31431         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31432         *ret_copy = FundingLocked_get_short_channel_id_alias(&this_ptr_conv);
31433         int64_t ret_ref = (uintptr_t)ret_copy;
31434         return ret_ref;
31435 }
31436
31437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31438         LDKFundingLocked this_ptr_conv;
31439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31440         this_ptr_conv.is_owned = false;
31441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31442         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31443         CHECK_ACCESS(val_ptr);
31444         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31445         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
31446         FundingLocked_set_short_channel_id_alias(&this_ptr_conv, val_conv);
31447 }
31448
31449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg, int64_t short_channel_id_alias_arg) {
31450         LDKThirtyTwoBytes channel_id_arg_ref;
31451         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31452         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31453         LDKPublicKey next_per_commitment_point_arg_ref;
31454         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
31455         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
31456         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
31457         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
31458         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
31459         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
31460         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
31461         int64_t ret_ref = 0;
31462         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31463         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31465         ret_ref = (uintptr_t)ret_var.inner;
31466         if (ret_var.is_owned) {
31467                 ret_ref |= 1;
31468         }
31469         return ret_ref;
31470 }
31471
31472 static inline uintptr_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
31473         LDKFundingLocked ret_var = FundingLocked_clone(arg);
31474 int64_t ret_ref = 0;
31475 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31476 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31477 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31478 ret_ref = (uintptr_t)ret_var.inner;
31479 if (ret_var.is_owned) {
31480         ret_ref |= 1;
31481 }
31482         return ret_ref;
31483 }
31484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31485         LDKFundingLocked arg_conv;
31486         arg_conv.inner = (void*)(arg & (~1));
31487         arg_conv.is_owned = false;
31488         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31489         int64_t ret_val = FundingLocked_clone_ptr(&arg_conv);
31490         return ret_val;
31491 }
31492
31493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31494         LDKFundingLocked orig_conv;
31495         orig_conv.inner = (void*)(orig & (~1));
31496         orig_conv.is_owned = false;
31497         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31498         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
31499         int64_t ret_ref = 0;
31500         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31501         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31503         ret_ref = (uintptr_t)ret_var.inner;
31504         if (ret_var.is_owned) {
31505                 ret_ref |= 1;
31506         }
31507         return ret_ref;
31508 }
31509
31510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31511         LDKShutdown this_obj_conv;
31512         this_obj_conv.inner = (void*)(this_obj & (~1));
31513         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31515         Shutdown_free(this_obj_conv);
31516 }
31517
31518 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31519         LDKShutdown this_ptr_conv;
31520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31521         this_ptr_conv.is_owned = false;
31522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31523         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31524         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
31525         return ret_arr;
31526 }
31527
31528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31529         LDKShutdown this_ptr_conv;
31530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31531         this_ptr_conv.is_owned = false;
31532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31533         LDKThirtyTwoBytes val_ref;
31534         CHECK((*env)->GetArrayLength(env, val) == 32);
31535         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31536         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
31537 }
31538
31539 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
31540         LDKShutdown this_ptr_conv;
31541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31542         this_ptr_conv.is_owned = false;
31543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31544         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
31545         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31546         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31547         return ret_arr;
31548 }
31549
31550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31551         LDKShutdown this_ptr_conv;
31552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31553         this_ptr_conv.is_owned = false;
31554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31555         LDKCVec_u8Z val_ref;
31556         val_ref.datalen = (*env)->GetArrayLength(env, val);
31557         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
31558         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
31559         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
31560 }
31561
31562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
31563         LDKThirtyTwoBytes channel_id_arg_ref;
31564         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31565         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31566         LDKCVec_u8Z scriptpubkey_arg_ref;
31567         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
31568         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
31569         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
31570         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
31571         int64_t ret_ref = 0;
31572         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31573         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31575         ret_ref = (uintptr_t)ret_var.inner;
31576         if (ret_var.is_owned) {
31577                 ret_ref |= 1;
31578         }
31579         return ret_ref;
31580 }
31581
31582 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
31583         LDKShutdown ret_var = Shutdown_clone(arg);
31584 int64_t ret_ref = 0;
31585 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31586 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31587 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31588 ret_ref = (uintptr_t)ret_var.inner;
31589 if (ret_var.is_owned) {
31590         ret_ref |= 1;
31591 }
31592         return ret_ref;
31593 }
31594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31595         LDKShutdown arg_conv;
31596         arg_conv.inner = (void*)(arg & (~1));
31597         arg_conv.is_owned = false;
31598         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31599         int64_t ret_val = Shutdown_clone_ptr(&arg_conv);
31600         return ret_val;
31601 }
31602
31603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31604         LDKShutdown orig_conv;
31605         orig_conv.inner = (void*)(orig & (~1));
31606         orig_conv.is_owned = false;
31607         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31608         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
31609         int64_t ret_ref = 0;
31610         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31611         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31613         ret_ref = (uintptr_t)ret_var.inner;
31614         if (ret_var.is_owned) {
31615                 ret_ref |= 1;
31616         }
31617         return ret_ref;
31618 }
31619
31620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31621         LDKClosingSignedFeeRange this_obj_conv;
31622         this_obj_conv.inner = (void*)(this_obj & (~1));
31623         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31625         ClosingSignedFeeRange_free(this_obj_conv);
31626 }
31627
31628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31629         LDKClosingSignedFeeRange this_ptr_conv;
31630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31631         this_ptr_conv.is_owned = false;
31632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31633         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
31634         return ret_val;
31635 }
31636
31637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31638         LDKClosingSignedFeeRange this_ptr_conv;
31639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31640         this_ptr_conv.is_owned = false;
31641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31642         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
31643 }
31644
31645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31646         LDKClosingSignedFeeRange this_ptr_conv;
31647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31648         this_ptr_conv.is_owned = false;
31649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31650         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
31651         return ret_val;
31652 }
31653
31654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31655         LDKClosingSignedFeeRange this_ptr_conv;
31656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31657         this_ptr_conv.is_owned = false;
31658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31659         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
31660 }
31661
31662 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) {
31663         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
31664         int64_t ret_ref = 0;
31665         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31666         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31668         ret_ref = (uintptr_t)ret_var.inner;
31669         if (ret_var.is_owned) {
31670                 ret_ref |= 1;
31671         }
31672         return ret_ref;
31673 }
31674
31675 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
31676         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
31677 int64_t ret_ref = 0;
31678 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31679 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31680 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31681 ret_ref = (uintptr_t)ret_var.inner;
31682 if (ret_var.is_owned) {
31683         ret_ref |= 1;
31684 }
31685         return ret_ref;
31686 }
31687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31688         LDKClosingSignedFeeRange arg_conv;
31689         arg_conv.inner = (void*)(arg & (~1));
31690         arg_conv.is_owned = false;
31691         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31692         int64_t ret_val = ClosingSignedFeeRange_clone_ptr(&arg_conv);
31693         return ret_val;
31694 }
31695
31696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31697         LDKClosingSignedFeeRange orig_conv;
31698         orig_conv.inner = (void*)(orig & (~1));
31699         orig_conv.is_owned = false;
31700         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31701         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
31702         int64_t ret_ref = 0;
31703         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31704         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31706         ret_ref = (uintptr_t)ret_var.inner;
31707         if (ret_var.is_owned) {
31708                 ret_ref |= 1;
31709         }
31710         return ret_ref;
31711 }
31712
31713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31714         LDKClosingSigned this_obj_conv;
31715         this_obj_conv.inner = (void*)(this_obj & (~1));
31716         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31718         ClosingSigned_free(this_obj_conv);
31719 }
31720
31721 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31722         LDKClosingSigned this_ptr_conv;
31723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31724         this_ptr_conv.is_owned = false;
31725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31726         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31727         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
31728         return ret_arr;
31729 }
31730
31731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31732         LDKClosingSigned this_ptr_conv;
31733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31734         this_ptr_conv.is_owned = false;
31735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31736         LDKThirtyTwoBytes val_ref;
31737         CHECK((*env)->GetArrayLength(env, val) == 32);
31738         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31739         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
31740 }
31741
31742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31743         LDKClosingSigned this_ptr_conv;
31744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31745         this_ptr_conv.is_owned = false;
31746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31747         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
31748         return ret_val;
31749 }
31750
31751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31752         LDKClosingSigned this_ptr_conv;
31753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31754         this_ptr_conv.is_owned = false;
31755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31756         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
31757 }
31758
31759 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
31760         LDKClosingSigned this_ptr_conv;
31761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31762         this_ptr_conv.is_owned = false;
31763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31764         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31765         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
31766         return ret_arr;
31767 }
31768
31769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31770         LDKClosingSigned this_ptr_conv;
31771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31772         this_ptr_conv.is_owned = false;
31773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31774         LDKSignature val_ref;
31775         CHECK((*env)->GetArrayLength(env, val) == 64);
31776         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31777         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
31778 }
31779
31780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
31781         LDKClosingSigned this_ptr_conv;
31782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31783         this_ptr_conv.is_owned = false;
31784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31785         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
31786         int64_t ret_ref = 0;
31787         if ((uintptr_t)ret_var.inner > 4096) {
31788                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31789                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31791                 ret_ref = (uintptr_t)ret_var.inner;
31792                 if (ret_var.is_owned) {
31793                         ret_ref |= 1;
31794                 }
31795         }
31796         return ret_ref;
31797 }
31798
31799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31800         LDKClosingSigned this_ptr_conv;
31801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31802         this_ptr_conv.is_owned = false;
31803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31804         LDKClosingSignedFeeRange val_conv;
31805         val_conv.inner = (void*)(val & (~1));
31806         val_conv.is_owned = (val & 1) || (val == 0);
31807         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31808         val_conv = ClosingSignedFeeRange_clone(&val_conv);
31809         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
31810 }
31811
31812 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) {
31813         LDKThirtyTwoBytes channel_id_arg_ref;
31814         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31815         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31816         LDKSignature signature_arg_ref;
31817         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
31818         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
31819         LDKClosingSignedFeeRange fee_range_arg_conv;
31820         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
31821         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
31822         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
31823         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
31824         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
31825         int64_t ret_ref = 0;
31826         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31827         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31829         ret_ref = (uintptr_t)ret_var.inner;
31830         if (ret_var.is_owned) {
31831                 ret_ref |= 1;
31832         }
31833         return ret_ref;
31834 }
31835
31836 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
31837         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
31838 int64_t ret_ref = 0;
31839 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31840 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31841 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31842 ret_ref = (uintptr_t)ret_var.inner;
31843 if (ret_var.is_owned) {
31844         ret_ref |= 1;
31845 }
31846         return ret_ref;
31847 }
31848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31849         LDKClosingSigned arg_conv;
31850         arg_conv.inner = (void*)(arg & (~1));
31851         arg_conv.is_owned = false;
31852         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31853         int64_t ret_val = ClosingSigned_clone_ptr(&arg_conv);
31854         return ret_val;
31855 }
31856
31857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31858         LDKClosingSigned orig_conv;
31859         orig_conv.inner = (void*)(orig & (~1));
31860         orig_conv.is_owned = false;
31861         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31862         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
31863         int64_t ret_ref = 0;
31864         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31865         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31867         ret_ref = (uintptr_t)ret_var.inner;
31868         if (ret_var.is_owned) {
31869                 ret_ref |= 1;
31870         }
31871         return ret_ref;
31872 }
31873
31874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31875         LDKUpdateAddHTLC this_obj_conv;
31876         this_obj_conv.inner = (void*)(this_obj & (~1));
31877         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31879         UpdateAddHTLC_free(this_obj_conv);
31880 }
31881
31882 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31883         LDKUpdateAddHTLC this_ptr_conv;
31884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31885         this_ptr_conv.is_owned = false;
31886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31887         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31888         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
31889         return ret_arr;
31890 }
31891
31892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31893         LDKUpdateAddHTLC this_ptr_conv;
31894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31895         this_ptr_conv.is_owned = false;
31896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31897         LDKThirtyTwoBytes val_ref;
31898         CHECK((*env)->GetArrayLength(env, val) == 32);
31899         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31900         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
31901 }
31902
31903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31904         LDKUpdateAddHTLC this_ptr_conv;
31905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31906         this_ptr_conv.is_owned = false;
31907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31908         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
31909         return ret_val;
31910 }
31911
31912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31913         LDKUpdateAddHTLC this_ptr_conv;
31914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31915         this_ptr_conv.is_owned = false;
31916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31917         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
31918 }
31919
31920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31921         LDKUpdateAddHTLC this_ptr_conv;
31922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31923         this_ptr_conv.is_owned = false;
31924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31925         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
31926         return ret_val;
31927 }
31928
31929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31930         LDKUpdateAddHTLC this_ptr_conv;
31931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31932         this_ptr_conv.is_owned = false;
31933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31934         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
31935 }
31936
31937 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
31938         LDKUpdateAddHTLC this_ptr_conv;
31939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31940         this_ptr_conv.is_owned = false;
31941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31942         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31943         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
31944         return ret_arr;
31945 }
31946
31947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31948         LDKUpdateAddHTLC 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         LDKThirtyTwoBytes val_ref;
31953         CHECK((*env)->GetArrayLength(env, val) == 32);
31954         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31955         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
31956 }
31957
31958 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
31959         LDKUpdateAddHTLC this_ptr_conv;
31960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31961         this_ptr_conv.is_owned = false;
31962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31963         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
31964         return ret_val;
31965 }
31966
31967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31968         LDKUpdateAddHTLC this_ptr_conv;
31969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31970         this_ptr_conv.is_owned = false;
31971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31972         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
31973 }
31974
31975 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
31976         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
31977 int64_t ret_ref = 0;
31978 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31979 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31980 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31981 ret_ref = (uintptr_t)ret_var.inner;
31982 if (ret_var.is_owned) {
31983         ret_ref |= 1;
31984 }
31985         return ret_ref;
31986 }
31987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31988         LDKUpdateAddHTLC arg_conv;
31989         arg_conv.inner = (void*)(arg & (~1));
31990         arg_conv.is_owned = false;
31991         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31992         int64_t ret_val = UpdateAddHTLC_clone_ptr(&arg_conv);
31993         return ret_val;
31994 }
31995
31996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31997         LDKUpdateAddHTLC orig_conv;
31998         orig_conv.inner = (void*)(orig & (~1));
31999         orig_conv.is_owned = false;
32000         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32001         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
32002         int64_t ret_ref = 0;
32003         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32004         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32006         ret_ref = (uintptr_t)ret_var.inner;
32007         if (ret_var.is_owned) {
32008                 ret_ref |= 1;
32009         }
32010         return ret_ref;
32011 }
32012
32013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32014         LDKUpdateFulfillHTLC this_obj_conv;
32015         this_obj_conv.inner = (void*)(this_obj & (~1));
32016         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32018         UpdateFulfillHTLC_free(this_obj_conv);
32019 }
32020
32021 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32022         LDKUpdateFulfillHTLC this_ptr_conv;
32023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32024         this_ptr_conv.is_owned = false;
32025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32026         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32027         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
32028         return ret_arr;
32029 }
32030
32031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32032         LDKUpdateFulfillHTLC this_ptr_conv;
32033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32034         this_ptr_conv.is_owned = false;
32035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32036         LDKThirtyTwoBytes val_ref;
32037         CHECK((*env)->GetArrayLength(env, val) == 32);
32038         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32039         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
32040 }
32041
32042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32043         LDKUpdateFulfillHTLC this_ptr_conv;
32044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32045         this_ptr_conv.is_owned = false;
32046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32047         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
32048         return ret_val;
32049 }
32050
32051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32052         LDKUpdateFulfillHTLC this_ptr_conv;
32053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32054         this_ptr_conv.is_owned = false;
32055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32056         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
32057 }
32058
32059 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
32060         LDKUpdateFulfillHTLC this_ptr_conv;
32061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32062         this_ptr_conv.is_owned = false;
32063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32064         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32065         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
32066         return ret_arr;
32067 }
32068
32069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32070         LDKUpdateFulfillHTLC this_ptr_conv;
32071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32072         this_ptr_conv.is_owned = false;
32073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32074         LDKThirtyTwoBytes val_ref;
32075         CHECK((*env)->GetArrayLength(env, val) == 32);
32076         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32077         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
32078 }
32079
32080 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) {
32081         LDKThirtyTwoBytes channel_id_arg_ref;
32082         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32083         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32084         LDKThirtyTwoBytes payment_preimage_arg_ref;
32085         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
32086         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
32087         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
32088         int64_t ret_ref = 0;
32089         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32090         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32092         ret_ref = (uintptr_t)ret_var.inner;
32093         if (ret_var.is_owned) {
32094                 ret_ref |= 1;
32095         }
32096         return ret_ref;
32097 }
32098
32099 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
32100         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
32101 int64_t ret_ref = 0;
32102 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32103 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32104 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32105 ret_ref = (uintptr_t)ret_var.inner;
32106 if (ret_var.is_owned) {
32107         ret_ref |= 1;
32108 }
32109         return ret_ref;
32110 }
32111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32112         LDKUpdateFulfillHTLC arg_conv;
32113         arg_conv.inner = (void*)(arg & (~1));
32114         arg_conv.is_owned = false;
32115         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32116         int64_t ret_val = UpdateFulfillHTLC_clone_ptr(&arg_conv);
32117         return ret_val;
32118 }
32119
32120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32121         LDKUpdateFulfillHTLC orig_conv;
32122         orig_conv.inner = (void*)(orig & (~1));
32123         orig_conv.is_owned = false;
32124         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32125         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
32126         int64_t ret_ref = 0;
32127         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32128         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32129         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32130         ret_ref = (uintptr_t)ret_var.inner;
32131         if (ret_var.is_owned) {
32132                 ret_ref |= 1;
32133         }
32134         return ret_ref;
32135 }
32136
32137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32138         LDKUpdateFailHTLC this_obj_conv;
32139         this_obj_conv.inner = (void*)(this_obj & (~1));
32140         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32142         UpdateFailHTLC_free(this_obj_conv);
32143 }
32144
32145 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32146         LDKUpdateFailHTLC this_ptr_conv;
32147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32148         this_ptr_conv.is_owned = false;
32149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32150         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32151         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
32152         return ret_arr;
32153 }
32154
32155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32156         LDKUpdateFailHTLC this_ptr_conv;
32157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32158         this_ptr_conv.is_owned = false;
32159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32160         LDKThirtyTwoBytes val_ref;
32161         CHECK((*env)->GetArrayLength(env, val) == 32);
32162         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32163         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
32164 }
32165
32166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32167         LDKUpdateFailHTLC this_ptr_conv;
32168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32169         this_ptr_conv.is_owned = false;
32170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32171         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
32172         return ret_val;
32173 }
32174
32175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32176         LDKUpdateFailHTLC this_ptr_conv;
32177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32178         this_ptr_conv.is_owned = false;
32179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32180         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
32181 }
32182
32183 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
32184         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
32185 int64_t ret_ref = 0;
32186 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32187 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32188 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32189 ret_ref = (uintptr_t)ret_var.inner;
32190 if (ret_var.is_owned) {
32191         ret_ref |= 1;
32192 }
32193         return ret_ref;
32194 }
32195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32196         LDKUpdateFailHTLC arg_conv;
32197         arg_conv.inner = (void*)(arg & (~1));
32198         arg_conv.is_owned = false;
32199         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32200         int64_t ret_val = UpdateFailHTLC_clone_ptr(&arg_conv);
32201         return ret_val;
32202 }
32203
32204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32205         LDKUpdateFailHTLC orig_conv;
32206         orig_conv.inner = (void*)(orig & (~1));
32207         orig_conv.is_owned = false;
32208         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32209         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
32210         int64_t ret_ref = 0;
32211         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32212         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32214         ret_ref = (uintptr_t)ret_var.inner;
32215         if (ret_var.is_owned) {
32216                 ret_ref |= 1;
32217         }
32218         return ret_ref;
32219 }
32220
32221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32222         LDKUpdateFailMalformedHTLC this_obj_conv;
32223         this_obj_conv.inner = (void*)(this_obj & (~1));
32224         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32226         UpdateFailMalformedHTLC_free(this_obj_conv);
32227 }
32228
32229 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32230         LDKUpdateFailMalformedHTLC this_ptr_conv;
32231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32232         this_ptr_conv.is_owned = false;
32233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32234         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32235         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
32236         return ret_arr;
32237 }
32238
32239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32240         LDKUpdateFailMalformedHTLC this_ptr_conv;
32241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32242         this_ptr_conv.is_owned = false;
32243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32244         LDKThirtyTwoBytes val_ref;
32245         CHECK((*env)->GetArrayLength(env, val) == 32);
32246         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32247         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
32248 }
32249
32250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32251         LDKUpdateFailMalformedHTLC this_ptr_conv;
32252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32253         this_ptr_conv.is_owned = false;
32254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32255         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
32256         return ret_val;
32257 }
32258
32259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32260         LDKUpdateFailMalformedHTLC this_ptr_conv;
32261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32262         this_ptr_conv.is_owned = false;
32263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32264         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
32265 }
32266
32267 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
32268         LDKUpdateFailMalformedHTLC this_ptr_conv;
32269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32270         this_ptr_conv.is_owned = false;
32271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32272         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
32273         return ret_val;
32274 }
32275
32276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32277         LDKUpdateFailMalformedHTLC 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         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
32282 }
32283
32284 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
32285         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
32286 int64_t ret_ref = 0;
32287 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32288 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32289 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32290 ret_ref = (uintptr_t)ret_var.inner;
32291 if (ret_var.is_owned) {
32292         ret_ref |= 1;
32293 }
32294         return ret_ref;
32295 }
32296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32297         LDKUpdateFailMalformedHTLC arg_conv;
32298         arg_conv.inner = (void*)(arg & (~1));
32299         arg_conv.is_owned = false;
32300         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32301         int64_t ret_val = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
32302         return ret_val;
32303 }
32304
32305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32306         LDKUpdateFailMalformedHTLC orig_conv;
32307         orig_conv.inner = (void*)(orig & (~1));
32308         orig_conv.is_owned = false;
32309         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32310         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
32311         int64_t ret_ref = 0;
32312         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32313         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32315         ret_ref = (uintptr_t)ret_var.inner;
32316         if (ret_var.is_owned) {
32317                 ret_ref |= 1;
32318         }
32319         return ret_ref;
32320 }
32321
32322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32323         LDKCommitmentSigned this_obj_conv;
32324         this_obj_conv.inner = (void*)(this_obj & (~1));
32325         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32327         CommitmentSigned_free(this_obj_conv);
32328 }
32329
32330 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32331         LDKCommitmentSigned this_ptr_conv;
32332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32333         this_ptr_conv.is_owned = false;
32334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32335         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32336         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
32337         return ret_arr;
32338 }
32339
32340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32341         LDKCommitmentSigned this_ptr_conv;
32342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32343         this_ptr_conv.is_owned = false;
32344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32345         LDKThirtyTwoBytes val_ref;
32346         CHECK((*env)->GetArrayLength(env, val) == 32);
32347         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32348         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
32349 }
32350
32351 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32352         LDKCommitmentSigned this_ptr_conv;
32353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32354         this_ptr_conv.is_owned = false;
32355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32356         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32357         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
32358         return ret_arr;
32359 }
32360
32361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32362         LDKCommitmentSigned this_ptr_conv;
32363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32364         this_ptr_conv.is_owned = false;
32365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32366         LDKSignature val_ref;
32367         CHECK((*env)->GetArrayLength(env, val) == 64);
32368         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32369         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
32370 }
32371
32372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
32373         LDKCommitmentSigned this_ptr_conv;
32374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32375         this_ptr_conv.is_owned = false;
32376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32377         LDKCVec_SignatureZ val_constr;
32378         val_constr.datalen = (*env)->GetArrayLength(env, val);
32379         if (val_constr.datalen > 0)
32380                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
32381         else
32382                 val_constr.data = NULL;
32383         for (size_t i = 0; i < val_constr.datalen; i++) {
32384                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
32385                 LDKSignature val_conv_8_ref;
32386                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
32387                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
32388                 val_constr.data[i] = val_conv_8_ref;
32389         }
32390         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
32391 }
32392
32393 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) {
32394         LDKThirtyTwoBytes channel_id_arg_ref;
32395         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32396         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32397         LDKSignature signature_arg_ref;
32398         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
32399         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
32400         LDKCVec_SignatureZ htlc_signatures_arg_constr;
32401         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
32402         if (htlc_signatures_arg_constr.datalen > 0)
32403                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
32404         else
32405                 htlc_signatures_arg_constr.data = NULL;
32406         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
32407                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
32408                 LDKSignature htlc_signatures_arg_conv_8_ref;
32409                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
32410                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
32411                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
32412         }
32413         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
32414         int64_t ret_ref = 0;
32415         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32416         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32418         ret_ref = (uintptr_t)ret_var.inner;
32419         if (ret_var.is_owned) {
32420                 ret_ref |= 1;
32421         }
32422         return ret_ref;
32423 }
32424
32425 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
32426         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
32427 int64_t ret_ref = 0;
32428 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32429 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32430 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32431 ret_ref = (uintptr_t)ret_var.inner;
32432 if (ret_var.is_owned) {
32433         ret_ref |= 1;
32434 }
32435         return ret_ref;
32436 }
32437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32438         LDKCommitmentSigned arg_conv;
32439         arg_conv.inner = (void*)(arg & (~1));
32440         arg_conv.is_owned = false;
32441         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32442         int64_t ret_val = CommitmentSigned_clone_ptr(&arg_conv);
32443         return ret_val;
32444 }
32445
32446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32447         LDKCommitmentSigned orig_conv;
32448         orig_conv.inner = (void*)(orig & (~1));
32449         orig_conv.is_owned = false;
32450         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32451         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
32452         int64_t ret_ref = 0;
32453         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32454         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32455         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32456         ret_ref = (uintptr_t)ret_var.inner;
32457         if (ret_var.is_owned) {
32458                 ret_ref |= 1;
32459         }
32460         return ret_ref;
32461 }
32462
32463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32464         LDKRevokeAndACK this_obj_conv;
32465         this_obj_conv.inner = (void*)(this_obj & (~1));
32466         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32468         RevokeAndACK_free(this_obj_conv);
32469 }
32470
32471 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32472         LDKRevokeAndACK this_ptr_conv;
32473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32474         this_ptr_conv.is_owned = false;
32475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32476         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32477         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
32478         return ret_arr;
32479 }
32480
32481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32482         LDKRevokeAndACK this_ptr_conv;
32483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32484         this_ptr_conv.is_owned = false;
32485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32486         LDKThirtyTwoBytes val_ref;
32487         CHECK((*env)->GetArrayLength(env, val) == 32);
32488         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32489         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
32490 }
32491
32492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
32493         LDKRevokeAndACK this_ptr_conv;
32494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32495         this_ptr_conv.is_owned = false;
32496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32497         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32498         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
32499         return ret_arr;
32500 }
32501
32502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32503         LDKRevokeAndACK this_ptr_conv;
32504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32505         this_ptr_conv.is_owned = false;
32506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32507         LDKThirtyTwoBytes val_ref;
32508         CHECK((*env)->GetArrayLength(env, val) == 32);
32509         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32510         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
32511 }
32512
32513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32514         LDKRevokeAndACK this_ptr_conv;
32515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32516         this_ptr_conv.is_owned = false;
32517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32518         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32519         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
32520         return ret_arr;
32521 }
32522
32523 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) {
32524         LDKRevokeAndACK this_ptr_conv;
32525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32526         this_ptr_conv.is_owned = false;
32527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32528         LDKPublicKey val_ref;
32529         CHECK((*env)->GetArrayLength(env, val) == 33);
32530         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32531         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
32532 }
32533
32534 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) {
32535         LDKThirtyTwoBytes channel_id_arg_ref;
32536         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32537         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32538         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
32539         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
32540         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
32541         LDKPublicKey next_per_commitment_point_arg_ref;
32542         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
32543         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
32544         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
32545         int64_t ret_ref = 0;
32546         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32547         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32549         ret_ref = (uintptr_t)ret_var.inner;
32550         if (ret_var.is_owned) {
32551                 ret_ref |= 1;
32552         }
32553         return ret_ref;
32554 }
32555
32556 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
32557         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
32558 int64_t ret_ref = 0;
32559 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32560 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32561 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32562 ret_ref = (uintptr_t)ret_var.inner;
32563 if (ret_var.is_owned) {
32564         ret_ref |= 1;
32565 }
32566         return ret_ref;
32567 }
32568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32569         LDKRevokeAndACK arg_conv;
32570         arg_conv.inner = (void*)(arg & (~1));
32571         arg_conv.is_owned = false;
32572         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32573         int64_t ret_val = RevokeAndACK_clone_ptr(&arg_conv);
32574         return ret_val;
32575 }
32576
32577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32578         LDKRevokeAndACK orig_conv;
32579         orig_conv.inner = (void*)(orig & (~1));
32580         orig_conv.is_owned = false;
32581         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32582         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
32583         int64_t ret_ref = 0;
32584         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32585         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32587         ret_ref = (uintptr_t)ret_var.inner;
32588         if (ret_var.is_owned) {
32589                 ret_ref |= 1;
32590         }
32591         return ret_ref;
32592 }
32593
32594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32595         LDKUpdateFee this_obj_conv;
32596         this_obj_conv.inner = (void*)(this_obj & (~1));
32597         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32599         UpdateFee_free(this_obj_conv);
32600 }
32601
32602 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32603         LDKUpdateFee this_ptr_conv;
32604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32605         this_ptr_conv.is_owned = false;
32606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32607         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32608         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
32609         return ret_arr;
32610 }
32611
32612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32613         LDKUpdateFee this_ptr_conv;
32614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32615         this_ptr_conv.is_owned = false;
32616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32617         LDKThirtyTwoBytes val_ref;
32618         CHECK((*env)->GetArrayLength(env, val) == 32);
32619         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32620         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
32621 }
32622
32623 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
32624         LDKUpdateFee this_ptr_conv;
32625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32626         this_ptr_conv.is_owned = false;
32627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32628         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
32629         return ret_val;
32630 }
32631
32632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32633         LDKUpdateFee this_ptr_conv;
32634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32635         this_ptr_conv.is_owned = false;
32636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32637         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
32638 }
32639
32640 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) {
32641         LDKThirtyTwoBytes channel_id_arg_ref;
32642         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32643         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32644         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
32645         int64_t ret_ref = 0;
32646         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32647         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32649         ret_ref = (uintptr_t)ret_var.inner;
32650         if (ret_var.is_owned) {
32651                 ret_ref |= 1;
32652         }
32653         return ret_ref;
32654 }
32655
32656 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
32657         LDKUpdateFee ret_var = UpdateFee_clone(arg);
32658 int64_t ret_ref = 0;
32659 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32660 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32661 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32662 ret_ref = (uintptr_t)ret_var.inner;
32663 if (ret_var.is_owned) {
32664         ret_ref |= 1;
32665 }
32666         return ret_ref;
32667 }
32668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32669         LDKUpdateFee arg_conv;
32670         arg_conv.inner = (void*)(arg & (~1));
32671         arg_conv.is_owned = false;
32672         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32673         int64_t ret_val = UpdateFee_clone_ptr(&arg_conv);
32674         return ret_val;
32675 }
32676
32677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32678         LDKUpdateFee orig_conv;
32679         orig_conv.inner = (void*)(orig & (~1));
32680         orig_conv.is_owned = false;
32681         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32682         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
32683         int64_t ret_ref = 0;
32684         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32685         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32687         ret_ref = (uintptr_t)ret_var.inner;
32688         if (ret_var.is_owned) {
32689                 ret_ref |= 1;
32690         }
32691         return ret_ref;
32692 }
32693
32694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32695         LDKDataLossProtect this_obj_conv;
32696         this_obj_conv.inner = (void*)(this_obj & (~1));
32697         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32699         DataLossProtect_free(this_obj_conv);
32700 }
32701
32702 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
32703         LDKDataLossProtect this_ptr_conv;
32704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32705         this_ptr_conv.is_owned = false;
32706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32707         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32708         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
32709         return ret_arr;
32710 }
32711
32712 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) {
32713         LDKDataLossProtect this_ptr_conv;
32714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32715         this_ptr_conv.is_owned = false;
32716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32717         LDKThirtyTwoBytes val_ref;
32718         CHECK((*env)->GetArrayLength(env, val) == 32);
32719         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32720         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
32721 }
32722
32723 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32724         LDKDataLossProtect this_ptr_conv;
32725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32726         this_ptr_conv.is_owned = false;
32727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32728         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32729         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
32730         return ret_arr;
32731 }
32732
32733 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) {
32734         LDKDataLossProtect this_ptr_conv;
32735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32736         this_ptr_conv.is_owned = false;
32737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32738         LDKPublicKey val_ref;
32739         CHECK((*env)->GetArrayLength(env, val) == 33);
32740         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32741         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
32742 }
32743
32744 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) {
32745         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
32746         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
32747         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
32748         LDKPublicKey my_current_per_commitment_point_arg_ref;
32749         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
32750         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
32751         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
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
32763 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
32764         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
32765 int64_t ret_ref = 0;
32766 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32767 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32768 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32769 ret_ref = (uintptr_t)ret_var.inner;
32770 if (ret_var.is_owned) {
32771         ret_ref |= 1;
32772 }
32773         return ret_ref;
32774 }
32775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32776         LDKDataLossProtect arg_conv;
32777         arg_conv.inner = (void*)(arg & (~1));
32778         arg_conv.is_owned = false;
32779         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32780         int64_t ret_val = DataLossProtect_clone_ptr(&arg_conv);
32781         return ret_val;
32782 }
32783
32784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32785         LDKDataLossProtect orig_conv;
32786         orig_conv.inner = (void*)(orig & (~1));
32787         orig_conv.is_owned = false;
32788         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32789         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
32790         int64_t ret_ref = 0;
32791         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32792         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32794         ret_ref = (uintptr_t)ret_var.inner;
32795         if (ret_var.is_owned) {
32796                 ret_ref |= 1;
32797         }
32798         return ret_ref;
32799 }
32800
32801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32802         LDKChannelReestablish this_obj_conv;
32803         this_obj_conv.inner = (void*)(this_obj & (~1));
32804         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32806         ChannelReestablish_free(this_obj_conv);
32807 }
32808
32809 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32810         LDKChannelReestablish this_ptr_conv;
32811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32812         this_ptr_conv.is_owned = false;
32813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32814         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32815         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
32816         return ret_arr;
32817 }
32818
32819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32820         LDKChannelReestablish this_ptr_conv;
32821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32822         this_ptr_conv.is_owned = false;
32823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32824         LDKThirtyTwoBytes val_ref;
32825         CHECK((*env)->GetArrayLength(env, val) == 32);
32826         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32827         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
32828 }
32829
32830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
32831         LDKChannelReestablish this_ptr_conv;
32832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32833         this_ptr_conv.is_owned = false;
32834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32835         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
32836         return ret_val;
32837 }
32838
32839 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) {
32840         LDKChannelReestablish this_ptr_conv;
32841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32842         this_ptr_conv.is_owned = false;
32843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32844         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
32845 }
32846
32847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
32848         LDKChannelReestablish this_ptr_conv;
32849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32850         this_ptr_conv.is_owned = false;
32851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32852         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
32853         return ret_val;
32854 }
32855
32856 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) {
32857         LDKChannelReestablish this_ptr_conv;
32858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32859         this_ptr_conv.is_owned = false;
32860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32861         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
32862 }
32863
32864 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
32865         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
32866 int64_t ret_ref = 0;
32867 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32868 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32869 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32870 ret_ref = (uintptr_t)ret_var.inner;
32871 if (ret_var.is_owned) {
32872         ret_ref |= 1;
32873 }
32874         return ret_ref;
32875 }
32876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32877         LDKChannelReestablish arg_conv;
32878         arg_conv.inner = (void*)(arg & (~1));
32879         arg_conv.is_owned = false;
32880         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32881         int64_t ret_val = ChannelReestablish_clone_ptr(&arg_conv);
32882         return ret_val;
32883 }
32884
32885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32886         LDKChannelReestablish orig_conv;
32887         orig_conv.inner = (void*)(orig & (~1));
32888         orig_conv.is_owned = false;
32889         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32890         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
32891         int64_t ret_ref = 0;
32892         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32893         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32895         ret_ref = (uintptr_t)ret_var.inner;
32896         if (ret_var.is_owned) {
32897                 ret_ref |= 1;
32898         }
32899         return ret_ref;
32900 }
32901
32902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32903         LDKAnnouncementSignatures this_obj_conv;
32904         this_obj_conv.inner = (void*)(this_obj & (~1));
32905         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32907         AnnouncementSignatures_free(this_obj_conv);
32908 }
32909
32910 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32911         LDKAnnouncementSignatures this_ptr_conv;
32912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32913         this_ptr_conv.is_owned = false;
32914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32915         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32916         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
32917         return ret_arr;
32918 }
32919
32920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32921         LDKAnnouncementSignatures this_ptr_conv;
32922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32923         this_ptr_conv.is_owned = false;
32924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32925         LDKThirtyTwoBytes val_ref;
32926         CHECK((*env)->GetArrayLength(env, val) == 32);
32927         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32928         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
32929 }
32930
32931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32932         LDKAnnouncementSignatures this_ptr_conv;
32933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32934         this_ptr_conv.is_owned = false;
32935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32936         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
32937         return ret_val;
32938 }
32939
32940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32941         LDKAnnouncementSignatures this_ptr_conv;
32942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32943         this_ptr_conv.is_owned = false;
32944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32945         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
32946 }
32947
32948 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32949         LDKAnnouncementSignatures this_ptr_conv;
32950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32951         this_ptr_conv.is_owned = false;
32952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32953         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32954         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
32955         return ret_arr;
32956 }
32957
32958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32959         LDKAnnouncementSignatures this_ptr_conv;
32960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32961         this_ptr_conv.is_owned = false;
32962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32963         LDKSignature val_ref;
32964         CHECK((*env)->GetArrayLength(env, val) == 64);
32965         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32966         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
32967 }
32968
32969 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32970         LDKAnnouncementSignatures this_ptr_conv;
32971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32972         this_ptr_conv.is_owned = false;
32973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32974         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32975         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
32976         return ret_arr;
32977 }
32978
32979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32980         LDKAnnouncementSignatures this_ptr_conv;
32981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32982         this_ptr_conv.is_owned = false;
32983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32984         LDKSignature val_ref;
32985         CHECK((*env)->GetArrayLength(env, val) == 64);
32986         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32987         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
32988 }
32989
32990 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) {
32991         LDKThirtyTwoBytes channel_id_arg_ref;
32992         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32993         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32994         LDKSignature node_signature_arg_ref;
32995         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
32996         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
32997         LDKSignature bitcoin_signature_arg_ref;
32998         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
32999         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
33000         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
33001         int64_t ret_ref = 0;
33002         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33003         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33005         ret_ref = (uintptr_t)ret_var.inner;
33006         if (ret_var.is_owned) {
33007                 ret_ref |= 1;
33008         }
33009         return ret_ref;
33010 }
33011
33012 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
33013         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
33014 int64_t ret_ref = 0;
33015 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33016 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33017 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33018 ret_ref = (uintptr_t)ret_var.inner;
33019 if (ret_var.is_owned) {
33020         ret_ref |= 1;
33021 }
33022         return ret_ref;
33023 }
33024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33025         LDKAnnouncementSignatures arg_conv;
33026         arg_conv.inner = (void*)(arg & (~1));
33027         arg_conv.is_owned = false;
33028         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33029         int64_t ret_val = AnnouncementSignatures_clone_ptr(&arg_conv);
33030         return ret_val;
33031 }
33032
33033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33034         LDKAnnouncementSignatures orig_conv;
33035         orig_conv.inner = (void*)(orig & (~1));
33036         orig_conv.is_owned = false;
33037         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33038         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
33039         int64_t ret_ref = 0;
33040         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33041         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33042         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33043         ret_ref = (uintptr_t)ret_var.inner;
33044         if (ret_var.is_owned) {
33045                 ret_ref |= 1;
33046         }
33047         return ret_ref;
33048 }
33049
33050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
33051         if ((this_ptr & 1) != 0) return;
33052         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33053         CHECK_ACCESS(this_ptr_ptr);
33054         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
33055         FREE((void*)this_ptr);
33056         NetAddress_free(this_ptr_conv);
33057 }
33058
33059 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
33060         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33061         *ret_copy = NetAddress_clone(arg);
33062 int64_t ret_ref = (uintptr_t)ret_copy;
33063         return ret_ref;
33064 }
33065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33066         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
33067         int64_t ret_val = NetAddress_clone_ptr(arg_conv);
33068         return ret_val;
33069 }
33070
33071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33072         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
33073         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33074         *ret_copy = NetAddress_clone(orig_conv);
33075         int64_t ret_ref = (uintptr_t)ret_copy;
33076         return ret_ref;
33077 }
33078
33079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
33080         LDKFourBytes addr_ref;
33081         CHECK((*env)->GetArrayLength(env, addr) == 4);
33082         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
33083         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33084         *ret_copy = NetAddress_ipv4(addr_ref, port);
33085         int64_t ret_ref = (uintptr_t)ret_copy;
33086         return ret_ref;
33087 }
33088
33089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
33090         LDKSixteenBytes addr_ref;
33091         CHECK((*env)->GetArrayLength(env, addr) == 16);
33092         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
33093         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33094         *ret_copy = NetAddress_ipv6(addr_ref, port);
33095         int64_t ret_ref = (uintptr_t)ret_copy;
33096         return ret_ref;
33097 }
33098
33099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
33100         LDKTwelveBytes a_ref;
33101         CHECK((*env)->GetArrayLength(env, a) == 12);
33102         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
33103         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33104         *ret_copy = NetAddress_onion_v2(a_ref);
33105         int64_t ret_ref = (uintptr_t)ret_copy;
33106         return ret_ref;
33107 }
33108
33109 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) {
33110         LDKThirtyTwoBytes ed25519_pubkey_ref;
33111         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
33112         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
33113         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33114         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
33115         int64_t ret_ref = (uintptr_t)ret_copy;
33116         return ret_ref;
33117 }
33118
33119 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
33120         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
33121         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
33122         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33123         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33124         CVec_u8Z_free(ret_var);
33125         return ret_arr;
33126 }
33127
33128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33129         LDKu8slice ser_ref;
33130         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33131         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33132         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
33133         *ret_conv = NetAddress_read(ser_ref);
33134         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33135         return (int64_t)ret_conv;
33136 }
33137
33138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33139         LDKUnsignedNodeAnnouncement this_obj_conv;
33140         this_obj_conv.inner = (void*)(this_obj & (~1));
33141         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33143         UnsignedNodeAnnouncement_free(this_obj_conv);
33144 }
33145
33146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
33147         LDKUnsignedNodeAnnouncement this_ptr_conv;
33148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33149         this_ptr_conv.is_owned = false;
33150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33151         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
33152         int64_t ret_ref = 0;
33153         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33154         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33155         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33156         ret_ref = (uintptr_t)ret_var.inner;
33157         if (ret_var.is_owned) {
33158                 ret_ref |= 1;
33159         }
33160         return ret_ref;
33161 }
33162
33163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33164         LDKUnsignedNodeAnnouncement this_ptr_conv;
33165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33166         this_ptr_conv.is_owned = false;
33167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33168         LDKNodeFeatures val_conv;
33169         val_conv.inner = (void*)(val & (~1));
33170         val_conv.is_owned = (val & 1) || (val == 0);
33171         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33172         val_conv = NodeFeatures_clone(&val_conv);
33173         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
33174 }
33175
33176 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
33177         LDKUnsignedNodeAnnouncement this_ptr_conv;
33178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33179         this_ptr_conv.is_owned = false;
33180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33181         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
33182         return ret_val;
33183 }
33184
33185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33186         LDKUnsignedNodeAnnouncement this_ptr_conv;
33187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33188         this_ptr_conv.is_owned = false;
33189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33190         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
33191 }
33192
33193 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33194         LDKUnsignedNodeAnnouncement this_ptr_conv;
33195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33196         this_ptr_conv.is_owned = false;
33197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33198         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33199         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
33200         return ret_arr;
33201 }
33202
33203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33204         LDKUnsignedNodeAnnouncement this_ptr_conv;
33205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33206         this_ptr_conv.is_owned = false;
33207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33208         LDKPublicKey val_ref;
33209         CHECK((*env)->GetArrayLength(env, val) == 33);
33210         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33211         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
33212 }
33213
33214 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
33215         LDKUnsignedNodeAnnouncement this_ptr_conv;
33216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33217         this_ptr_conv.is_owned = false;
33218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33219         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
33220         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
33221         return ret_arr;
33222 }
33223
33224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33225         LDKUnsignedNodeAnnouncement this_ptr_conv;
33226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33227         this_ptr_conv.is_owned = false;
33228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33229         LDKThreeBytes val_ref;
33230         CHECK((*env)->GetArrayLength(env, val) == 3);
33231         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
33232         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
33233 }
33234
33235 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
33236         LDKUnsignedNodeAnnouncement this_ptr_conv;
33237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33238         this_ptr_conv.is_owned = false;
33239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33240         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33241         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
33242         return ret_arr;
33243 }
33244
33245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33246         LDKUnsignedNodeAnnouncement 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         LDKThirtyTwoBytes val_ref;
33251         CHECK((*env)->GetArrayLength(env, val) == 32);
33252         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33253         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
33254 }
33255
33256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
33257         LDKUnsignedNodeAnnouncement this_ptr_conv;
33258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33259         this_ptr_conv.is_owned = false;
33260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33261         LDKCVec_NetAddressZ val_constr;
33262         val_constr.datalen = (*env)->GetArrayLength(env, val);
33263         if (val_constr.datalen > 0)
33264                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
33265         else
33266                 val_constr.data = NULL;
33267         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
33268         for (size_t m = 0; m < val_constr.datalen; m++) {
33269                 int64_t val_conv_12 = val_vals[m];
33270                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
33271                 CHECK_ACCESS(val_conv_12_ptr);
33272                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
33273                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
33274                 val_constr.data[m] = val_conv_12_conv;
33275         }
33276         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
33277         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
33278 }
33279
33280 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
33281         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
33282 int64_t ret_ref = 0;
33283 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33284 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33285 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33286 ret_ref = (uintptr_t)ret_var.inner;
33287 if (ret_var.is_owned) {
33288         ret_ref |= 1;
33289 }
33290         return ret_ref;
33291 }
33292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33293         LDKUnsignedNodeAnnouncement arg_conv;
33294         arg_conv.inner = (void*)(arg & (~1));
33295         arg_conv.is_owned = false;
33296         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33297         int64_t ret_val = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
33298         return ret_val;
33299 }
33300
33301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33302         LDKUnsignedNodeAnnouncement orig_conv;
33303         orig_conv.inner = (void*)(orig & (~1));
33304         orig_conv.is_owned = false;
33305         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33306         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
33307         int64_t ret_ref = 0;
33308         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33309         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33311         ret_ref = (uintptr_t)ret_var.inner;
33312         if (ret_var.is_owned) {
33313                 ret_ref |= 1;
33314         }
33315         return ret_ref;
33316 }
33317
33318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33319         LDKNodeAnnouncement this_obj_conv;
33320         this_obj_conv.inner = (void*)(this_obj & (~1));
33321         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33323         NodeAnnouncement_free(this_obj_conv);
33324 }
33325
33326 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33327         LDKNodeAnnouncement this_ptr_conv;
33328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33329         this_ptr_conv.is_owned = false;
33330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33331         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33332         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
33333         return ret_arr;
33334 }
33335
33336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33337         LDKNodeAnnouncement this_ptr_conv;
33338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33339         this_ptr_conv.is_owned = false;
33340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33341         LDKSignature val_ref;
33342         CHECK((*env)->GetArrayLength(env, val) == 64);
33343         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33344         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
33345 }
33346
33347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
33348         LDKNodeAnnouncement 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         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
33353         int64_t ret_ref = 0;
33354         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33355         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33357         ret_ref = (uintptr_t)ret_var.inner;
33358         if (ret_var.is_owned) {
33359                 ret_ref |= 1;
33360         }
33361         return ret_ref;
33362 }
33363
33364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33365         LDKNodeAnnouncement this_ptr_conv;
33366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33367         this_ptr_conv.is_owned = false;
33368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33369         LDKUnsignedNodeAnnouncement val_conv;
33370         val_conv.inner = (void*)(val & (~1));
33371         val_conv.is_owned = (val & 1) || (val == 0);
33372         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33373         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
33374         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
33375 }
33376
33377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
33378         LDKSignature signature_arg_ref;
33379         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33380         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33381         LDKUnsignedNodeAnnouncement contents_arg_conv;
33382         contents_arg_conv.inner = (void*)(contents_arg & (~1));
33383         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
33384         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
33385         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
33386         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
33387         int64_t ret_ref = 0;
33388         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33389         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33391         ret_ref = (uintptr_t)ret_var.inner;
33392         if (ret_var.is_owned) {
33393                 ret_ref |= 1;
33394         }
33395         return ret_ref;
33396 }
33397
33398 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
33399         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
33400 int64_t ret_ref = 0;
33401 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33402 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33403 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33404 ret_ref = (uintptr_t)ret_var.inner;
33405 if (ret_var.is_owned) {
33406         ret_ref |= 1;
33407 }
33408         return ret_ref;
33409 }
33410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33411         LDKNodeAnnouncement arg_conv;
33412         arg_conv.inner = (void*)(arg & (~1));
33413         arg_conv.is_owned = false;
33414         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33415         int64_t ret_val = NodeAnnouncement_clone_ptr(&arg_conv);
33416         return ret_val;
33417 }
33418
33419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33420         LDKNodeAnnouncement orig_conv;
33421         orig_conv.inner = (void*)(orig & (~1));
33422         orig_conv.is_owned = false;
33423         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33424         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
33425         int64_t ret_ref = 0;
33426         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33427         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33429         ret_ref = (uintptr_t)ret_var.inner;
33430         if (ret_var.is_owned) {
33431                 ret_ref |= 1;
33432         }
33433         return ret_ref;
33434 }
33435
33436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33437         LDKUnsignedChannelAnnouncement this_obj_conv;
33438         this_obj_conv.inner = (void*)(this_obj & (~1));
33439         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33441         UnsignedChannelAnnouncement_free(this_obj_conv);
33442 }
33443
33444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
33445         LDKUnsignedChannelAnnouncement 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         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
33450         int64_t ret_ref = 0;
33451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33454         ret_ref = (uintptr_t)ret_var.inner;
33455         if (ret_var.is_owned) {
33456                 ret_ref |= 1;
33457         }
33458         return ret_ref;
33459 }
33460
33461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33462         LDKUnsignedChannelAnnouncement this_ptr_conv;
33463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33464         this_ptr_conv.is_owned = false;
33465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33466         LDKChannelFeatures val_conv;
33467         val_conv.inner = (void*)(val & (~1));
33468         val_conv.is_owned = (val & 1) || (val == 0);
33469         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33470         val_conv = ChannelFeatures_clone(&val_conv);
33471         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
33472 }
33473
33474 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33475         LDKUnsignedChannelAnnouncement this_ptr_conv;
33476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33477         this_ptr_conv.is_owned = false;
33478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33479         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33480         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
33481         return ret_arr;
33482 }
33483
33484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33485         LDKUnsignedChannelAnnouncement this_ptr_conv;
33486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33487         this_ptr_conv.is_owned = false;
33488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33489         LDKThirtyTwoBytes val_ref;
33490         CHECK((*env)->GetArrayLength(env, val) == 32);
33491         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33492         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
33493 }
33494
33495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33496         LDKUnsignedChannelAnnouncement this_ptr_conv;
33497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33498         this_ptr_conv.is_owned = false;
33499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33500         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
33501         return ret_val;
33502 }
33503
33504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33505         LDKUnsignedChannelAnnouncement this_ptr_conv;
33506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33507         this_ptr_conv.is_owned = false;
33508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33509         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
33510 }
33511
33512 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33513         LDKUnsignedChannelAnnouncement this_ptr_conv;
33514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33515         this_ptr_conv.is_owned = false;
33516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33517         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33518         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
33519         return ret_arr;
33520 }
33521
33522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33523         LDKUnsignedChannelAnnouncement this_ptr_conv;
33524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33525         this_ptr_conv.is_owned = false;
33526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33527         LDKPublicKey val_ref;
33528         CHECK((*env)->GetArrayLength(env, val) == 33);
33529         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33530         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
33531 }
33532
33533 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33534         LDKUnsignedChannelAnnouncement this_ptr_conv;
33535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33536         this_ptr_conv.is_owned = false;
33537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33538         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33539         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
33540         return ret_arr;
33541 }
33542
33543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33544         LDKUnsignedChannelAnnouncement this_ptr_conv;
33545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33546         this_ptr_conv.is_owned = false;
33547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33548         LDKPublicKey val_ref;
33549         CHECK((*env)->GetArrayLength(env, val) == 33);
33550         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33551         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
33552 }
33553
33554 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33555         LDKUnsignedChannelAnnouncement 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33560         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
33561         return ret_arr;
33562 }
33563
33564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33565         LDKUnsignedChannelAnnouncement this_ptr_conv;
33566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33567         this_ptr_conv.is_owned = false;
33568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33569         LDKPublicKey val_ref;
33570         CHECK((*env)->GetArrayLength(env, val) == 33);
33571         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33572         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
33573 }
33574
33575 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33576         LDKUnsignedChannelAnnouncement this_ptr_conv;
33577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33578         this_ptr_conv.is_owned = false;
33579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33580         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33581         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
33582         return ret_arr;
33583 }
33584
33585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33586         LDKUnsignedChannelAnnouncement this_ptr_conv;
33587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33588         this_ptr_conv.is_owned = false;
33589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33590         LDKPublicKey val_ref;
33591         CHECK((*env)->GetArrayLength(env, val) == 33);
33592         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33593         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
33594 }
33595
33596 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
33597         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
33598 int64_t ret_ref = 0;
33599 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33600 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33601 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33602 ret_ref = (uintptr_t)ret_var.inner;
33603 if (ret_var.is_owned) {
33604         ret_ref |= 1;
33605 }
33606         return ret_ref;
33607 }
33608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33609         LDKUnsignedChannelAnnouncement arg_conv;
33610         arg_conv.inner = (void*)(arg & (~1));
33611         arg_conv.is_owned = false;
33612         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33613         int64_t ret_val = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
33614         return ret_val;
33615 }
33616
33617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33618         LDKUnsignedChannelAnnouncement orig_conv;
33619         orig_conv.inner = (void*)(orig & (~1));
33620         orig_conv.is_owned = false;
33621         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33622         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
33623         int64_t ret_ref = 0;
33624         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33625         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33627         ret_ref = (uintptr_t)ret_var.inner;
33628         if (ret_var.is_owned) {
33629                 ret_ref |= 1;
33630         }
33631         return ret_ref;
33632 }
33633
33634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33635         LDKChannelAnnouncement this_obj_conv;
33636         this_obj_conv.inner = (void*)(this_obj & (~1));
33637         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33639         ChannelAnnouncement_free(this_obj_conv);
33640 }
33641
33642 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33643         LDKChannelAnnouncement this_ptr_conv;
33644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33645         this_ptr_conv.is_owned = false;
33646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33647         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33648         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
33649         return ret_arr;
33650 }
33651
33652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33653         LDKChannelAnnouncement this_ptr_conv;
33654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33655         this_ptr_conv.is_owned = false;
33656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33657         LDKSignature val_ref;
33658         CHECK((*env)->GetArrayLength(env, val) == 64);
33659         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33660         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
33661 }
33662
33663 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33664         LDKChannelAnnouncement this_ptr_conv;
33665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33666         this_ptr_conv.is_owned = false;
33667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33668         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33669         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
33670         return ret_arr;
33671 }
33672
33673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33674         LDKChannelAnnouncement this_ptr_conv;
33675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33676         this_ptr_conv.is_owned = false;
33677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33678         LDKSignature val_ref;
33679         CHECK((*env)->GetArrayLength(env, val) == 64);
33680         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33681         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
33682 }
33683
33684 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33685         LDKChannelAnnouncement this_ptr_conv;
33686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33687         this_ptr_conv.is_owned = false;
33688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33689         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33690         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
33691         return ret_arr;
33692 }
33693
33694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33695         LDKChannelAnnouncement this_ptr_conv;
33696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33697         this_ptr_conv.is_owned = false;
33698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33699         LDKSignature val_ref;
33700         CHECK((*env)->GetArrayLength(env, val) == 64);
33701         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33702         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
33703 }
33704
33705 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33706         LDKChannelAnnouncement this_ptr_conv;
33707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33708         this_ptr_conv.is_owned = false;
33709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33710         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33711         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
33712         return ret_arr;
33713 }
33714
33715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33716         LDKChannelAnnouncement this_ptr_conv;
33717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33718         this_ptr_conv.is_owned = false;
33719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33720         LDKSignature val_ref;
33721         CHECK((*env)->GetArrayLength(env, val) == 64);
33722         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33723         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
33724 }
33725
33726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
33727         LDKChannelAnnouncement this_ptr_conv;
33728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33729         this_ptr_conv.is_owned = false;
33730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33731         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
33732         int64_t ret_ref = 0;
33733         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33734         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33736         ret_ref = (uintptr_t)ret_var.inner;
33737         if (ret_var.is_owned) {
33738                 ret_ref |= 1;
33739         }
33740         return ret_ref;
33741 }
33742
33743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33744         LDKChannelAnnouncement this_ptr_conv;
33745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33746         this_ptr_conv.is_owned = false;
33747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33748         LDKUnsignedChannelAnnouncement val_conv;
33749         val_conv.inner = (void*)(val & (~1));
33750         val_conv.is_owned = (val & 1) || (val == 0);
33751         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33752         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
33753         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
33754 }
33755
33756 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) {
33757         LDKSignature node_signature_1_arg_ref;
33758         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
33759         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
33760         LDKSignature node_signature_2_arg_ref;
33761         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
33762         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
33763         LDKSignature bitcoin_signature_1_arg_ref;
33764         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
33765         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
33766         LDKSignature bitcoin_signature_2_arg_ref;
33767         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
33768         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
33769         LDKUnsignedChannelAnnouncement contents_arg_conv;
33770         contents_arg_conv.inner = (void*)(contents_arg & (~1));
33771         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
33772         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
33773         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
33774         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);
33775         int64_t ret_ref = 0;
33776         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33777         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33779         ret_ref = (uintptr_t)ret_var.inner;
33780         if (ret_var.is_owned) {
33781                 ret_ref |= 1;
33782         }
33783         return ret_ref;
33784 }
33785
33786 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
33787         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
33788 int64_t ret_ref = 0;
33789 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33790 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33791 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33792 ret_ref = (uintptr_t)ret_var.inner;
33793 if (ret_var.is_owned) {
33794         ret_ref |= 1;
33795 }
33796         return ret_ref;
33797 }
33798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33799         LDKChannelAnnouncement arg_conv;
33800         arg_conv.inner = (void*)(arg & (~1));
33801         arg_conv.is_owned = false;
33802         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33803         int64_t ret_val = ChannelAnnouncement_clone_ptr(&arg_conv);
33804         return ret_val;
33805 }
33806
33807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33808         LDKChannelAnnouncement orig_conv;
33809         orig_conv.inner = (void*)(orig & (~1));
33810         orig_conv.is_owned = false;
33811         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33812         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
33813         int64_t ret_ref = 0;
33814         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33815         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33817         ret_ref = (uintptr_t)ret_var.inner;
33818         if (ret_var.is_owned) {
33819                 ret_ref |= 1;
33820         }
33821         return ret_ref;
33822 }
33823
33824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33825         LDKUnsignedChannelUpdate this_obj_conv;
33826         this_obj_conv.inner = (void*)(this_obj & (~1));
33827         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33829         UnsignedChannelUpdate_free(this_obj_conv);
33830 }
33831
33832 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33833         LDKUnsignedChannelUpdate this_ptr_conv;
33834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33835         this_ptr_conv.is_owned = false;
33836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33837         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33838         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
33839         return ret_arr;
33840 }
33841
33842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33843         LDKUnsignedChannelUpdate this_ptr_conv;
33844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33845         this_ptr_conv.is_owned = false;
33846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33847         LDKThirtyTwoBytes val_ref;
33848         CHECK((*env)->GetArrayLength(env, val) == 32);
33849         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33850         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
33851 }
33852
33853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33854         LDKUnsignedChannelUpdate this_ptr_conv;
33855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33856         this_ptr_conv.is_owned = false;
33857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33858         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
33859         return ret_val;
33860 }
33861
33862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33863         LDKUnsignedChannelUpdate this_ptr_conv;
33864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33865         this_ptr_conv.is_owned = false;
33866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33867         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
33868 }
33869
33870 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
33871         LDKUnsignedChannelUpdate this_ptr_conv;
33872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33873         this_ptr_conv.is_owned = false;
33874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33875         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
33876         return ret_val;
33877 }
33878
33879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33880         LDKUnsignedChannelUpdate this_ptr_conv;
33881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33882         this_ptr_conv.is_owned = false;
33883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33884         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
33885 }
33886
33887 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
33888         LDKUnsignedChannelUpdate this_ptr_conv;
33889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33890         this_ptr_conv.is_owned = false;
33891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33892         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
33893         return ret_val;
33894 }
33895
33896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
33897         LDKUnsignedChannelUpdate this_ptr_conv;
33898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33899         this_ptr_conv.is_owned = false;
33900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33901         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
33902 }
33903
33904 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
33905         LDKUnsignedChannelUpdate this_ptr_conv;
33906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33907         this_ptr_conv.is_owned = false;
33908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33909         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
33910         return ret_val;
33911 }
33912
33913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33914         LDKUnsignedChannelUpdate this_ptr_conv;
33915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33916         this_ptr_conv.is_owned = false;
33917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33918         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
33919 }
33920
33921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33922         LDKUnsignedChannelUpdate this_ptr_conv;
33923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33924         this_ptr_conv.is_owned = false;
33925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33926         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
33927         return ret_val;
33928 }
33929
33930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33931         LDKUnsignedChannelUpdate this_ptr_conv;
33932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33933         this_ptr_conv.is_owned = false;
33934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33935         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
33936 }
33937
33938 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33939         LDKUnsignedChannelUpdate this_ptr_conv;
33940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33941         this_ptr_conv.is_owned = false;
33942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33943         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
33944         return ret_val;
33945 }
33946
33947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33948         LDKUnsignedChannelUpdate this_ptr_conv;
33949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33950         this_ptr_conv.is_owned = false;
33951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33952         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
33953 }
33954
33955 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
33956         LDKUnsignedChannelUpdate this_ptr_conv;
33957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33958         this_ptr_conv.is_owned = false;
33959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33960         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
33961         return ret_val;
33962 }
33963
33964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33965         LDKUnsignedChannelUpdate this_ptr_conv;
33966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33967         this_ptr_conv.is_owned = false;
33968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33969         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
33970 }
33971
33972 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
33973         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
33974 int64_t ret_ref = 0;
33975 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33976 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33977 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33978 ret_ref = (uintptr_t)ret_var.inner;
33979 if (ret_var.is_owned) {
33980         ret_ref |= 1;
33981 }
33982         return ret_ref;
33983 }
33984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33985         LDKUnsignedChannelUpdate arg_conv;
33986         arg_conv.inner = (void*)(arg & (~1));
33987         arg_conv.is_owned = false;
33988         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33989         int64_t ret_val = UnsignedChannelUpdate_clone_ptr(&arg_conv);
33990         return ret_val;
33991 }
33992
33993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33994         LDKUnsignedChannelUpdate orig_conv;
33995         orig_conv.inner = (void*)(orig & (~1));
33996         orig_conv.is_owned = false;
33997         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33998         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
33999         int64_t ret_ref = 0;
34000         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34001         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34003         ret_ref = (uintptr_t)ret_var.inner;
34004         if (ret_var.is_owned) {
34005                 ret_ref |= 1;
34006         }
34007         return ret_ref;
34008 }
34009
34010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34011         LDKChannelUpdate this_obj_conv;
34012         this_obj_conv.inner = (void*)(this_obj & (~1));
34013         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34015         ChannelUpdate_free(this_obj_conv);
34016 }
34017
34018 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34019         LDKChannelUpdate this_ptr_conv;
34020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34021         this_ptr_conv.is_owned = false;
34022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34023         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34024         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
34025         return ret_arr;
34026 }
34027
34028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34029         LDKChannelUpdate this_ptr_conv;
34030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34031         this_ptr_conv.is_owned = false;
34032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34033         LDKSignature val_ref;
34034         CHECK((*env)->GetArrayLength(env, val) == 64);
34035         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34036         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
34037 }
34038
34039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
34040         LDKChannelUpdate this_ptr_conv;
34041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34042         this_ptr_conv.is_owned = false;
34043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34044         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
34045         int64_t ret_ref = 0;
34046         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34047         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34049         ret_ref = (uintptr_t)ret_var.inner;
34050         if (ret_var.is_owned) {
34051                 ret_ref |= 1;
34052         }
34053         return ret_ref;
34054 }
34055
34056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34057         LDKChannelUpdate this_ptr_conv;
34058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34059         this_ptr_conv.is_owned = false;
34060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34061         LDKUnsignedChannelUpdate val_conv;
34062         val_conv.inner = (void*)(val & (~1));
34063         val_conv.is_owned = (val & 1) || (val == 0);
34064         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34065         val_conv = UnsignedChannelUpdate_clone(&val_conv);
34066         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
34067 }
34068
34069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
34070         LDKSignature signature_arg_ref;
34071         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34072         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34073         LDKUnsignedChannelUpdate contents_arg_conv;
34074         contents_arg_conv.inner = (void*)(contents_arg & (~1));
34075         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
34076         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
34077         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
34078         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
34079         int64_t ret_ref = 0;
34080         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34081         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34083         ret_ref = (uintptr_t)ret_var.inner;
34084         if (ret_var.is_owned) {
34085                 ret_ref |= 1;
34086         }
34087         return ret_ref;
34088 }
34089
34090 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
34091         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
34092 int64_t ret_ref = 0;
34093 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34094 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34095 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34096 ret_ref = (uintptr_t)ret_var.inner;
34097 if (ret_var.is_owned) {
34098         ret_ref |= 1;
34099 }
34100         return ret_ref;
34101 }
34102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34103         LDKChannelUpdate arg_conv;
34104         arg_conv.inner = (void*)(arg & (~1));
34105         arg_conv.is_owned = false;
34106         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34107         int64_t ret_val = ChannelUpdate_clone_ptr(&arg_conv);
34108         return ret_val;
34109 }
34110
34111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34112         LDKChannelUpdate orig_conv;
34113         orig_conv.inner = (void*)(orig & (~1));
34114         orig_conv.is_owned = false;
34115         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34116         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
34117         int64_t ret_ref = 0;
34118         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34119         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34121         ret_ref = (uintptr_t)ret_var.inner;
34122         if (ret_var.is_owned) {
34123                 ret_ref |= 1;
34124         }
34125         return ret_ref;
34126 }
34127
34128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34129         LDKQueryChannelRange this_obj_conv;
34130         this_obj_conv.inner = (void*)(this_obj & (~1));
34131         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34133         QueryChannelRange_free(this_obj_conv);
34134 }
34135
34136 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34137         LDKQueryChannelRange this_ptr_conv;
34138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34139         this_ptr_conv.is_owned = false;
34140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34141         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34142         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
34143         return ret_arr;
34144 }
34145
34146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34147         LDKQueryChannelRange this_ptr_conv;
34148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34149         this_ptr_conv.is_owned = false;
34150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34151         LDKThirtyTwoBytes val_ref;
34152         CHECK((*env)->GetArrayLength(env, val) == 32);
34153         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34154         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
34155 }
34156
34157 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
34158         LDKQueryChannelRange this_ptr_conv;
34159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34160         this_ptr_conv.is_owned = false;
34161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34162         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
34163         return ret_val;
34164 }
34165
34166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34167         LDKQueryChannelRange this_ptr_conv;
34168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34169         this_ptr_conv.is_owned = false;
34170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34171         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
34172 }
34173
34174 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
34175         LDKQueryChannelRange this_ptr_conv;
34176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34177         this_ptr_conv.is_owned = false;
34178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34179         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
34180         return ret_val;
34181 }
34182
34183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34184         LDKQueryChannelRange this_ptr_conv;
34185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34186         this_ptr_conv.is_owned = false;
34187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34188         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
34189 }
34190
34191 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) {
34192         LDKThirtyTwoBytes chain_hash_arg_ref;
34193         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34194         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34195         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
34196         int64_t ret_ref = 0;
34197         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34198         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34200         ret_ref = (uintptr_t)ret_var.inner;
34201         if (ret_var.is_owned) {
34202                 ret_ref |= 1;
34203         }
34204         return ret_ref;
34205 }
34206
34207 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
34208         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
34209 int64_t ret_ref = 0;
34210 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34211 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34212 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34213 ret_ref = (uintptr_t)ret_var.inner;
34214 if (ret_var.is_owned) {
34215         ret_ref |= 1;
34216 }
34217         return ret_ref;
34218 }
34219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34220         LDKQueryChannelRange arg_conv;
34221         arg_conv.inner = (void*)(arg & (~1));
34222         arg_conv.is_owned = false;
34223         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34224         int64_t ret_val = QueryChannelRange_clone_ptr(&arg_conv);
34225         return ret_val;
34226 }
34227
34228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34229         LDKQueryChannelRange orig_conv;
34230         orig_conv.inner = (void*)(orig & (~1));
34231         orig_conv.is_owned = false;
34232         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34233         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
34234         int64_t ret_ref = 0;
34235         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34236         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34238         ret_ref = (uintptr_t)ret_var.inner;
34239         if (ret_var.is_owned) {
34240                 ret_ref |= 1;
34241         }
34242         return ret_ref;
34243 }
34244
34245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34246         LDKReplyChannelRange this_obj_conv;
34247         this_obj_conv.inner = (void*)(this_obj & (~1));
34248         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34250         ReplyChannelRange_free(this_obj_conv);
34251 }
34252
34253 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34254         LDKReplyChannelRange this_ptr_conv;
34255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34256         this_ptr_conv.is_owned = false;
34257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34258         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34259         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
34260         return ret_arr;
34261 }
34262
34263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34264         LDKReplyChannelRange this_ptr_conv;
34265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34266         this_ptr_conv.is_owned = false;
34267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34268         LDKThirtyTwoBytes val_ref;
34269         CHECK((*env)->GetArrayLength(env, val) == 32);
34270         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34271         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
34272 }
34273
34274 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
34275         LDKReplyChannelRange this_ptr_conv;
34276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34277         this_ptr_conv.is_owned = false;
34278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34279         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
34280         return ret_val;
34281 }
34282
34283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34284         LDKReplyChannelRange this_ptr_conv;
34285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34286         this_ptr_conv.is_owned = false;
34287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34288         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
34289 }
34290
34291 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
34292         LDKReplyChannelRange this_ptr_conv;
34293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34294         this_ptr_conv.is_owned = false;
34295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34296         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
34297         return ret_val;
34298 }
34299
34300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34301         LDKReplyChannelRange this_ptr_conv;
34302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34303         this_ptr_conv.is_owned = false;
34304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34305         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
34306 }
34307
34308 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
34309         LDKReplyChannelRange this_ptr_conv;
34310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34311         this_ptr_conv.is_owned = false;
34312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34313         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
34314         return ret_val;
34315 }
34316
34317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
34318         LDKReplyChannelRange this_ptr_conv;
34319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34320         this_ptr_conv.is_owned = false;
34321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34322         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
34323 }
34324
34325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
34326         LDKReplyChannelRange this_ptr_conv;
34327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34328         this_ptr_conv.is_owned = false;
34329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34330         LDKCVec_u64Z val_constr;
34331         val_constr.datalen = (*env)->GetArrayLength(env, val);
34332         if (val_constr.datalen > 0)
34333                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
34334         else
34335                 val_constr.data = NULL;
34336         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34337         for (size_t g = 0; g < val_constr.datalen; g++) {
34338                 int64_t val_conv_6 = val_vals[g];
34339                 val_constr.data[g] = val_conv_6;
34340         }
34341         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34342         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
34343 }
34344
34345 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) {
34346         LDKThirtyTwoBytes chain_hash_arg_ref;
34347         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34348         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34349         LDKCVec_u64Z short_channel_ids_arg_constr;
34350         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
34351         if (short_channel_ids_arg_constr.datalen > 0)
34352                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
34353         else
34354                 short_channel_ids_arg_constr.data = NULL;
34355         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
34356         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
34357                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
34358                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
34359         }
34360         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
34361         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
34362         int64_t ret_ref = 0;
34363         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34364         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34366         ret_ref = (uintptr_t)ret_var.inner;
34367         if (ret_var.is_owned) {
34368                 ret_ref |= 1;
34369         }
34370         return ret_ref;
34371 }
34372
34373 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
34374         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
34375 int64_t ret_ref = 0;
34376 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34377 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34378 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34379 ret_ref = (uintptr_t)ret_var.inner;
34380 if (ret_var.is_owned) {
34381         ret_ref |= 1;
34382 }
34383         return ret_ref;
34384 }
34385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34386         LDKReplyChannelRange arg_conv;
34387         arg_conv.inner = (void*)(arg & (~1));
34388         arg_conv.is_owned = false;
34389         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34390         int64_t ret_val = ReplyChannelRange_clone_ptr(&arg_conv);
34391         return ret_val;
34392 }
34393
34394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34395         LDKReplyChannelRange orig_conv;
34396         orig_conv.inner = (void*)(orig & (~1));
34397         orig_conv.is_owned = false;
34398         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34399         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
34400         int64_t ret_ref = 0;
34401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34404         ret_ref = (uintptr_t)ret_var.inner;
34405         if (ret_var.is_owned) {
34406                 ret_ref |= 1;
34407         }
34408         return ret_ref;
34409 }
34410
34411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34412         LDKQueryShortChannelIds this_obj_conv;
34413         this_obj_conv.inner = (void*)(this_obj & (~1));
34414         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34416         QueryShortChannelIds_free(this_obj_conv);
34417 }
34418
34419 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34420         LDKQueryShortChannelIds this_ptr_conv;
34421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34422         this_ptr_conv.is_owned = false;
34423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34424         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34425         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
34426         return ret_arr;
34427 }
34428
34429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34430         LDKQueryShortChannelIds this_ptr_conv;
34431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34432         this_ptr_conv.is_owned = false;
34433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34434         LDKThirtyTwoBytes val_ref;
34435         CHECK((*env)->GetArrayLength(env, val) == 32);
34436         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34437         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
34438 }
34439
34440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
34441         LDKQueryShortChannelIds this_ptr_conv;
34442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34443         this_ptr_conv.is_owned = false;
34444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34445         LDKCVec_u64Z val_constr;
34446         val_constr.datalen = (*env)->GetArrayLength(env, val);
34447         if (val_constr.datalen > 0)
34448                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
34449         else
34450                 val_constr.data = NULL;
34451         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34452         for (size_t g = 0; g < val_constr.datalen; g++) {
34453                 int64_t val_conv_6 = val_vals[g];
34454                 val_constr.data[g] = val_conv_6;
34455         }
34456         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34457         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
34458 }
34459
34460 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) {
34461         LDKThirtyTwoBytes chain_hash_arg_ref;
34462         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34463         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34464         LDKCVec_u64Z short_channel_ids_arg_constr;
34465         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
34466         if (short_channel_ids_arg_constr.datalen > 0)
34467                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
34468         else
34469                 short_channel_ids_arg_constr.data = NULL;
34470         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
34471         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
34472                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
34473                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
34474         }
34475         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
34476         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
34477         int64_t ret_ref = 0;
34478         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34479         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34481         ret_ref = (uintptr_t)ret_var.inner;
34482         if (ret_var.is_owned) {
34483                 ret_ref |= 1;
34484         }
34485         return ret_ref;
34486 }
34487
34488 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
34489         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
34490 int64_t ret_ref = 0;
34491 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34492 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34493 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34494 ret_ref = (uintptr_t)ret_var.inner;
34495 if (ret_var.is_owned) {
34496         ret_ref |= 1;
34497 }
34498         return ret_ref;
34499 }
34500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34501         LDKQueryShortChannelIds arg_conv;
34502         arg_conv.inner = (void*)(arg & (~1));
34503         arg_conv.is_owned = false;
34504         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34505         int64_t ret_val = QueryShortChannelIds_clone_ptr(&arg_conv);
34506         return ret_val;
34507 }
34508
34509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34510         LDKQueryShortChannelIds orig_conv;
34511         orig_conv.inner = (void*)(orig & (~1));
34512         orig_conv.is_owned = false;
34513         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34514         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
34515         int64_t ret_ref = 0;
34516         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34517         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34519         ret_ref = (uintptr_t)ret_var.inner;
34520         if (ret_var.is_owned) {
34521                 ret_ref |= 1;
34522         }
34523         return ret_ref;
34524 }
34525
34526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34527         LDKReplyShortChannelIdsEnd this_obj_conv;
34528         this_obj_conv.inner = (void*)(this_obj & (~1));
34529         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34531         ReplyShortChannelIdsEnd_free(this_obj_conv);
34532 }
34533
34534 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34535         LDKReplyShortChannelIdsEnd 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34540         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
34541         return ret_arr;
34542 }
34543
34544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34545         LDKReplyShortChannelIdsEnd this_ptr_conv;
34546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34547         this_ptr_conv.is_owned = false;
34548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34549         LDKThirtyTwoBytes val_ref;
34550         CHECK((*env)->GetArrayLength(env, val) == 32);
34551         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34552         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
34553 }
34554
34555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
34556         LDKReplyShortChannelIdsEnd this_ptr_conv;
34557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34558         this_ptr_conv.is_owned = false;
34559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34560         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
34561         return ret_val;
34562 }
34563
34564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
34565         LDKReplyShortChannelIdsEnd this_ptr_conv;
34566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34567         this_ptr_conv.is_owned = false;
34568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34569         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
34570 }
34571
34572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
34573         LDKThirtyTwoBytes chain_hash_arg_ref;
34574         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34575         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34576         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
34577         int64_t ret_ref = 0;
34578         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34579         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34581         ret_ref = (uintptr_t)ret_var.inner;
34582         if (ret_var.is_owned) {
34583                 ret_ref |= 1;
34584         }
34585         return ret_ref;
34586 }
34587
34588 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
34589         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
34590 int64_t ret_ref = 0;
34591 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34592 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34593 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34594 ret_ref = (uintptr_t)ret_var.inner;
34595 if (ret_var.is_owned) {
34596         ret_ref |= 1;
34597 }
34598         return ret_ref;
34599 }
34600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34601         LDKReplyShortChannelIdsEnd arg_conv;
34602         arg_conv.inner = (void*)(arg & (~1));
34603         arg_conv.is_owned = false;
34604         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34605         int64_t ret_val = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
34606         return ret_val;
34607 }
34608
34609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34610         LDKReplyShortChannelIdsEnd orig_conv;
34611         orig_conv.inner = (void*)(orig & (~1));
34612         orig_conv.is_owned = false;
34613         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34614         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
34615         int64_t ret_ref = 0;
34616         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34617         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34619         ret_ref = (uintptr_t)ret_var.inner;
34620         if (ret_var.is_owned) {
34621                 ret_ref |= 1;
34622         }
34623         return ret_ref;
34624 }
34625
34626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34627         LDKGossipTimestampFilter this_obj_conv;
34628         this_obj_conv.inner = (void*)(this_obj & (~1));
34629         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34631         GossipTimestampFilter_free(this_obj_conv);
34632 }
34633
34634 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34635         LDKGossipTimestampFilter this_ptr_conv;
34636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34637         this_ptr_conv.is_owned = false;
34638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34639         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34640         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
34641         return ret_arr;
34642 }
34643
34644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34645         LDKGossipTimestampFilter this_ptr_conv;
34646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34647         this_ptr_conv.is_owned = false;
34648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34649         LDKThirtyTwoBytes val_ref;
34650         CHECK((*env)->GetArrayLength(env, val) == 32);
34651         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34652         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
34653 }
34654
34655 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
34656         LDKGossipTimestampFilter this_ptr_conv;
34657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34658         this_ptr_conv.is_owned = false;
34659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34660         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
34661         return ret_val;
34662 }
34663
34664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34665         LDKGossipTimestampFilter this_ptr_conv;
34666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34667         this_ptr_conv.is_owned = false;
34668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34669         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
34670 }
34671
34672 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
34673         LDKGossipTimestampFilter this_ptr_conv;
34674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34675         this_ptr_conv.is_owned = false;
34676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34677         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
34678         return ret_val;
34679 }
34680
34681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34682         LDKGossipTimestampFilter this_ptr_conv;
34683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34684         this_ptr_conv.is_owned = false;
34685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34686         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
34687 }
34688
34689 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) {
34690         LDKThirtyTwoBytes chain_hash_arg_ref;
34691         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34692         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34693         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
34694         int64_t ret_ref = 0;
34695         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34696         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34698         ret_ref = (uintptr_t)ret_var.inner;
34699         if (ret_var.is_owned) {
34700                 ret_ref |= 1;
34701         }
34702         return ret_ref;
34703 }
34704
34705 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
34706         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
34707 int64_t ret_ref = 0;
34708 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34709 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34710 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34711 ret_ref = (uintptr_t)ret_var.inner;
34712 if (ret_var.is_owned) {
34713         ret_ref |= 1;
34714 }
34715         return ret_ref;
34716 }
34717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34718         LDKGossipTimestampFilter arg_conv;
34719         arg_conv.inner = (void*)(arg & (~1));
34720         arg_conv.is_owned = false;
34721         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34722         int64_t ret_val = GossipTimestampFilter_clone_ptr(&arg_conv);
34723         return ret_val;
34724 }
34725
34726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34727         LDKGossipTimestampFilter orig_conv;
34728         orig_conv.inner = (void*)(orig & (~1));
34729         orig_conv.is_owned = false;
34730         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34731         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
34732         int64_t ret_ref = 0;
34733         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34734         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34736         ret_ref = (uintptr_t)ret_var.inner;
34737         if (ret_var.is_owned) {
34738                 ret_ref |= 1;
34739         }
34740         return ret_ref;
34741 }
34742
34743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34744         if ((this_ptr & 1) != 0) return;
34745         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34746         CHECK_ACCESS(this_ptr_ptr);
34747         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
34748         FREE((void*)this_ptr);
34749         ErrorAction_free(this_ptr_conv);
34750 }
34751
34752 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
34753         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34754         *ret_copy = ErrorAction_clone(arg);
34755 int64_t ret_ref = (uintptr_t)ret_copy;
34756         return ret_ref;
34757 }
34758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34759         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
34760         int64_t ret_val = ErrorAction_clone_ptr(arg_conv);
34761         return ret_val;
34762 }
34763
34764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34765         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
34766         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34767         *ret_copy = ErrorAction_clone(orig_conv);
34768         int64_t ret_ref = (uintptr_t)ret_copy;
34769         return ret_ref;
34770 }
34771
34772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
34773         LDKErrorMessage msg_conv;
34774         msg_conv.inner = (void*)(msg & (~1));
34775         msg_conv.is_owned = (msg & 1) || (msg == 0);
34776         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
34777         msg_conv = ErrorMessage_clone(&msg_conv);
34778         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34779         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
34780         int64_t ret_ref = (uintptr_t)ret_copy;
34781         return ret_ref;
34782 }
34783
34784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
34785         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34786         *ret_copy = ErrorAction_ignore_error();
34787         int64_t ret_ref = (uintptr_t)ret_copy;
34788         return ret_ref;
34789 }
34790
34791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
34792         LDKLevel a_conv = LDKLevel_from_java(env, a);
34793         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34794         *ret_copy = ErrorAction_ignore_and_log(a_conv);
34795         int64_t ret_ref = (uintptr_t)ret_copy;
34796         return ret_ref;
34797 }
34798
34799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
34800         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34801         *ret_copy = ErrorAction_ignore_duplicate_gossip();
34802         int64_t ret_ref = (uintptr_t)ret_copy;
34803         return ret_ref;
34804 }
34805
34806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
34807         LDKErrorMessage msg_conv;
34808         msg_conv.inner = (void*)(msg & (~1));
34809         msg_conv.is_owned = (msg & 1) || (msg == 0);
34810         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
34811         msg_conv = ErrorMessage_clone(&msg_conv);
34812         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34813         *ret_copy = ErrorAction_send_error_message(msg_conv);
34814         int64_t ret_ref = (uintptr_t)ret_copy;
34815         return ret_ref;
34816 }
34817
34818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
34819         LDKWarningMessage msg_conv;
34820         msg_conv.inner = (void*)(msg & (~1));
34821         msg_conv.is_owned = (msg & 1) || (msg == 0);
34822         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
34823         msg_conv = WarningMessage_clone(&msg_conv);
34824         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
34825         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34826         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
34827         int64_t ret_ref = (uintptr_t)ret_copy;
34828         return ret_ref;
34829 }
34830
34831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34832         LDKLightningError this_obj_conv;
34833         this_obj_conv.inner = (void*)(this_obj & (~1));
34834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34836         LightningError_free(this_obj_conv);
34837 }
34838
34839 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
34840         LDKLightningError this_ptr_conv;
34841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34842         this_ptr_conv.is_owned = false;
34843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34844         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
34845         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34846         Str_free(ret_str);
34847         return ret_conv;
34848 }
34849
34850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34851         LDKLightningError this_ptr_conv;
34852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34853         this_ptr_conv.is_owned = false;
34854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34855         LDKStr val_conv = java_to_owned_str(env, val);
34856         LightningError_set_err(&this_ptr_conv, val_conv);
34857 }
34858
34859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
34860         LDKLightningError this_ptr_conv;
34861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34862         this_ptr_conv.is_owned = false;
34863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34864         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34865         *ret_copy = LightningError_get_action(&this_ptr_conv);
34866         int64_t ret_ref = (uintptr_t)ret_copy;
34867         return ret_ref;
34868 }
34869
34870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34871         LDKLightningError this_ptr_conv;
34872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34873         this_ptr_conv.is_owned = false;
34874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34875         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34876         CHECK_ACCESS(val_ptr);
34877         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
34878         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
34879         LightningError_set_action(&this_ptr_conv, val_conv);
34880 }
34881
34882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
34883         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
34884         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
34885         CHECK_ACCESS(action_arg_ptr);
34886         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
34887         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
34888         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
34889         int64_t ret_ref = 0;
34890         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34891         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34893         ret_ref = (uintptr_t)ret_var.inner;
34894         if (ret_var.is_owned) {
34895                 ret_ref |= 1;
34896         }
34897         return ret_ref;
34898 }
34899
34900 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
34901         LDKLightningError ret_var = LightningError_clone(arg);
34902 int64_t ret_ref = 0;
34903 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34904 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34905 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34906 ret_ref = (uintptr_t)ret_var.inner;
34907 if (ret_var.is_owned) {
34908         ret_ref |= 1;
34909 }
34910         return ret_ref;
34911 }
34912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34913         LDKLightningError arg_conv;
34914         arg_conv.inner = (void*)(arg & (~1));
34915         arg_conv.is_owned = false;
34916         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34917         int64_t ret_val = LightningError_clone_ptr(&arg_conv);
34918         return ret_val;
34919 }
34920
34921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34922         LDKLightningError orig_conv;
34923         orig_conv.inner = (void*)(orig & (~1));
34924         orig_conv.is_owned = false;
34925         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34926         LDKLightningError ret_var = LightningError_clone(&orig_conv);
34927         int64_t ret_ref = 0;
34928         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34929         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34931         ret_ref = (uintptr_t)ret_var.inner;
34932         if (ret_var.is_owned) {
34933                 ret_ref |= 1;
34934         }
34935         return ret_ref;
34936 }
34937
34938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34939         LDKCommitmentUpdate this_obj_conv;
34940         this_obj_conv.inner = (void*)(this_obj & (~1));
34941         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34943         CommitmentUpdate_free(this_obj_conv);
34944 }
34945
34946 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
34947         LDKCommitmentUpdate this_ptr_conv;
34948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34949         this_ptr_conv.is_owned = false;
34950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34951         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
34952         int64_tArray ret_arr = NULL;
34953         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
34954         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
34955         for (size_t p = 0; p < ret_var.datalen; p++) {
34956                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
34957                 int64_t ret_conv_15_ref = 0;
34958                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34959                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34960                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
34961                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
34962                 if (ret_conv_15_var.is_owned) {
34963                         ret_conv_15_ref |= 1;
34964                 }
34965                 ret_arr_ptr[p] = ret_conv_15_ref;
34966         }
34967         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
34968         FREE(ret_var.data);
34969         return ret_arr;
34970 }
34971
34972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
34973         LDKCommitmentUpdate 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         LDKCVec_UpdateAddHTLCZ val_constr;
34978         val_constr.datalen = (*env)->GetArrayLength(env, val);
34979         if (val_constr.datalen > 0)
34980                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
34981         else
34982                 val_constr.data = NULL;
34983         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34984         for (size_t p = 0; p < val_constr.datalen; p++) {
34985                 int64_t val_conv_15 = val_vals[p];
34986                 LDKUpdateAddHTLC val_conv_15_conv;
34987                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
34988                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
34989                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
34990                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
34991                 val_constr.data[p] = val_conv_15_conv;
34992         }
34993         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34994         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
34995 }
34996
34997 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
34998         LDKCommitmentUpdate this_ptr_conv;
34999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35000         this_ptr_conv.is_owned = false;
35001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35002         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
35003         int64_tArray ret_arr = NULL;
35004         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35005         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35006         for (size_t t = 0; t < ret_var.datalen; t++) {
35007                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
35008                 int64_t ret_conv_19_ref = 0;
35009                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35010                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35011                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
35012                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
35013                 if (ret_conv_19_var.is_owned) {
35014                         ret_conv_19_ref |= 1;
35015                 }
35016                 ret_arr_ptr[t] = ret_conv_19_ref;
35017         }
35018         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35019         FREE(ret_var.data);
35020         return ret_arr;
35021 }
35022
35023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35024         LDKCommitmentUpdate this_ptr_conv;
35025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35026         this_ptr_conv.is_owned = false;
35027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35028         LDKCVec_UpdateFulfillHTLCZ val_constr;
35029         val_constr.datalen = (*env)->GetArrayLength(env, val);
35030         if (val_constr.datalen > 0)
35031                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
35032         else
35033                 val_constr.data = NULL;
35034         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35035         for (size_t t = 0; t < val_constr.datalen; t++) {
35036                 int64_t val_conv_19 = val_vals[t];
35037                 LDKUpdateFulfillHTLC val_conv_19_conv;
35038                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
35039                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
35040                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
35041                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
35042                 val_constr.data[t] = val_conv_19_conv;
35043         }
35044         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35045         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
35046 }
35047
35048 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35049         LDKCommitmentUpdate this_ptr_conv;
35050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35051         this_ptr_conv.is_owned = false;
35052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35053         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
35054         int64_tArray ret_arr = NULL;
35055         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35056         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35057         for (size_t q = 0; q < ret_var.datalen; q++) {
35058                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
35059                 int64_t ret_conv_16_ref = 0;
35060                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35061                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35062                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
35063                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
35064                 if (ret_conv_16_var.is_owned) {
35065                         ret_conv_16_ref |= 1;
35066                 }
35067                 ret_arr_ptr[q] = ret_conv_16_ref;
35068         }
35069         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35070         FREE(ret_var.data);
35071         return ret_arr;
35072 }
35073
35074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35075         LDKCommitmentUpdate this_ptr_conv;
35076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35077         this_ptr_conv.is_owned = false;
35078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35079         LDKCVec_UpdateFailHTLCZ val_constr;
35080         val_constr.datalen = (*env)->GetArrayLength(env, val);
35081         if (val_constr.datalen > 0)
35082                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
35083         else
35084                 val_constr.data = NULL;
35085         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35086         for (size_t q = 0; q < val_constr.datalen; q++) {
35087                 int64_t val_conv_16 = val_vals[q];
35088                 LDKUpdateFailHTLC val_conv_16_conv;
35089                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
35090                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
35091                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
35092                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
35093                 val_constr.data[q] = val_conv_16_conv;
35094         }
35095         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35096         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
35097 }
35098
35099 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35100         LDKCommitmentUpdate this_ptr_conv;
35101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35102         this_ptr_conv.is_owned = false;
35103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35104         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
35105         int64_tArray ret_arr = NULL;
35106         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35107         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35108         for (size_t z = 0; z < ret_var.datalen; z++) {
35109                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
35110                 int64_t ret_conv_25_ref = 0;
35111                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35112                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35113                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
35114                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
35115                 if (ret_conv_25_var.is_owned) {
35116                         ret_conv_25_ref |= 1;
35117                 }
35118                 ret_arr_ptr[z] = ret_conv_25_ref;
35119         }
35120         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35121         FREE(ret_var.data);
35122         return ret_arr;
35123 }
35124
35125 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) {
35126         LDKCommitmentUpdate this_ptr_conv;
35127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35128         this_ptr_conv.is_owned = false;
35129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35130         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
35131         val_constr.datalen = (*env)->GetArrayLength(env, val);
35132         if (val_constr.datalen > 0)
35133                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
35134         else
35135                 val_constr.data = NULL;
35136         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35137         for (size_t z = 0; z < val_constr.datalen; z++) {
35138                 int64_t val_conv_25 = val_vals[z];
35139                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
35140                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
35141                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
35142                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
35143                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
35144                 val_constr.data[z] = val_conv_25_conv;
35145         }
35146         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35147         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
35148 }
35149
35150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
35151         LDKCommitmentUpdate this_ptr_conv;
35152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35153         this_ptr_conv.is_owned = false;
35154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35155         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
35156         int64_t ret_ref = 0;
35157         if ((uintptr_t)ret_var.inner > 4096) {
35158                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35159                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35161                 ret_ref = (uintptr_t)ret_var.inner;
35162                 if (ret_var.is_owned) {
35163                         ret_ref |= 1;
35164                 }
35165         }
35166         return ret_ref;
35167 }
35168
35169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35170         LDKCommitmentUpdate this_ptr_conv;
35171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35172         this_ptr_conv.is_owned = false;
35173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35174         LDKUpdateFee val_conv;
35175         val_conv.inner = (void*)(val & (~1));
35176         val_conv.is_owned = (val & 1) || (val == 0);
35177         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35178         val_conv = UpdateFee_clone(&val_conv);
35179         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
35180 }
35181
35182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
35183         LDKCommitmentUpdate 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         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
35188         int64_t ret_ref = 0;
35189         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35190         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35192         ret_ref = (uintptr_t)ret_var.inner;
35193         if (ret_var.is_owned) {
35194                 ret_ref |= 1;
35195         }
35196         return ret_ref;
35197 }
35198
35199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35200         LDKCommitmentUpdate 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         LDKCommitmentSigned val_conv;
35205         val_conv.inner = (void*)(val & (~1));
35206         val_conv.is_owned = (val & 1) || (val == 0);
35207         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35208         val_conv = CommitmentSigned_clone(&val_conv);
35209         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
35210 }
35211
35212 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) {
35213         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
35214         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
35215         if (update_add_htlcs_arg_constr.datalen > 0)
35216                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
35217         else
35218                 update_add_htlcs_arg_constr.data = NULL;
35219         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
35220         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
35221                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
35222                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
35223                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
35224                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
35225                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
35226                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
35227                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
35228         }
35229         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
35230         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
35231         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
35232         if (update_fulfill_htlcs_arg_constr.datalen > 0)
35233                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
35234         else
35235                 update_fulfill_htlcs_arg_constr.data = NULL;
35236         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
35237         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
35238                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
35239                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
35240                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
35241                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
35242                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
35243                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
35244                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
35245         }
35246         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
35247         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
35248         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
35249         if (update_fail_htlcs_arg_constr.datalen > 0)
35250                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
35251         else
35252                 update_fail_htlcs_arg_constr.data = NULL;
35253         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
35254         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
35255                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
35256                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
35257                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
35258                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
35259                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
35260                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
35261                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
35262         }
35263         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
35264         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
35265         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
35266         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
35267                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
35268         else
35269                 update_fail_malformed_htlcs_arg_constr.data = NULL;
35270         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
35271         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
35272                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
35273                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
35274                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
35275                 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);
35276                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
35277                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
35278                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
35279         }
35280         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
35281         LDKUpdateFee update_fee_arg_conv;
35282         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
35283         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
35284         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
35285         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
35286         LDKCommitmentSigned commitment_signed_arg_conv;
35287         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
35288         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
35289         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
35290         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
35291         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);
35292         int64_t ret_ref = 0;
35293         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35294         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35296         ret_ref = (uintptr_t)ret_var.inner;
35297         if (ret_var.is_owned) {
35298                 ret_ref |= 1;
35299         }
35300         return ret_ref;
35301 }
35302
35303 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
35304         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
35305 int64_t ret_ref = 0;
35306 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35307 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35308 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35309 ret_ref = (uintptr_t)ret_var.inner;
35310 if (ret_var.is_owned) {
35311         ret_ref |= 1;
35312 }
35313         return ret_ref;
35314 }
35315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35316         LDKCommitmentUpdate arg_conv;
35317         arg_conv.inner = (void*)(arg & (~1));
35318         arg_conv.is_owned = false;
35319         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35320         int64_t ret_val = CommitmentUpdate_clone_ptr(&arg_conv);
35321         return ret_val;
35322 }
35323
35324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35325         LDKCommitmentUpdate orig_conv;
35326         orig_conv.inner = (void*)(orig & (~1));
35327         orig_conv.is_owned = false;
35328         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35329         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
35330         int64_t ret_ref = 0;
35331         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35332         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35334         ret_ref = (uintptr_t)ret_var.inner;
35335         if (ret_var.is_owned) {
35336                 ret_ref |= 1;
35337         }
35338         return ret_ref;
35339 }
35340
35341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35342         if ((this_ptr & 1) != 0) return;
35343         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35344         CHECK_ACCESS(this_ptr_ptr);
35345         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
35346         FREE((void*)this_ptr);
35347         ChannelMessageHandler_free(this_ptr_conv);
35348 }
35349
35350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35351         if ((this_ptr & 1) != 0) return;
35352         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35353         CHECK_ACCESS(this_ptr_ptr);
35354         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
35355         FREE((void*)this_ptr);
35356         RoutingMessageHandler_free(this_ptr_conv);
35357 }
35358
35359 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
35360         LDKAcceptChannel obj_conv;
35361         obj_conv.inner = (void*)(obj & (~1));
35362         obj_conv.is_owned = false;
35363         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35364         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
35365         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35366         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35367         CVec_u8Z_free(ret_var);
35368         return ret_arr;
35369 }
35370
35371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35372         LDKu8slice ser_ref;
35373         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35374         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35375         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
35376         *ret_conv = AcceptChannel_read(ser_ref);
35377         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35378         return (int64_t)ret_conv;
35379 }
35380
35381 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
35382         LDKAnnouncementSignatures obj_conv;
35383         obj_conv.inner = (void*)(obj & (~1));
35384         obj_conv.is_owned = false;
35385         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35386         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
35387         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35388         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35389         CVec_u8Z_free(ret_var);
35390         return ret_arr;
35391 }
35392
35393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35394         LDKu8slice ser_ref;
35395         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35396         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35397         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
35398         *ret_conv = AnnouncementSignatures_read(ser_ref);
35399         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35400         return (int64_t)ret_conv;
35401 }
35402
35403 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
35404         LDKChannelReestablish obj_conv;
35405         obj_conv.inner = (void*)(obj & (~1));
35406         obj_conv.is_owned = false;
35407         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35408         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
35409         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35410         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35411         CVec_u8Z_free(ret_var);
35412         return ret_arr;
35413 }
35414
35415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35416         LDKu8slice ser_ref;
35417         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35418         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35419         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
35420         *ret_conv = ChannelReestablish_read(ser_ref);
35421         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35422         return (int64_t)ret_conv;
35423 }
35424
35425 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
35426         LDKClosingSigned obj_conv;
35427         obj_conv.inner = (void*)(obj & (~1));
35428         obj_conv.is_owned = false;
35429         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35430         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
35431         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35432         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35433         CVec_u8Z_free(ret_var);
35434         return ret_arr;
35435 }
35436
35437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35438         LDKu8slice ser_ref;
35439         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35440         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35441         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
35442         *ret_conv = ClosingSigned_read(ser_ref);
35443         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35444         return (int64_t)ret_conv;
35445 }
35446
35447 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
35448         LDKClosingSignedFeeRange obj_conv;
35449         obj_conv.inner = (void*)(obj & (~1));
35450         obj_conv.is_owned = false;
35451         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35452         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
35453         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35454         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35455         CVec_u8Z_free(ret_var);
35456         return ret_arr;
35457 }
35458
35459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35460         LDKu8slice ser_ref;
35461         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35462         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35463         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
35464         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
35465         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35466         return (int64_t)ret_conv;
35467 }
35468
35469 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
35470         LDKCommitmentSigned obj_conv;
35471         obj_conv.inner = (void*)(obj & (~1));
35472         obj_conv.is_owned = false;
35473         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35474         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
35475         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35476         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35477         CVec_u8Z_free(ret_var);
35478         return ret_arr;
35479 }
35480
35481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35482         LDKu8slice ser_ref;
35483         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35484         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35485         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
35486         *ret_conv = CommitmentSigned_read(ser_ref);
35487         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35488         return (int64_t)ret_conv;
35489 }
35490
35491 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
35492         LDKFundingCreated obj_conv;
35493         obj_conv.inner = (void*)(obj & (~1));
35494         obj_conv.is_owned = false;
35495         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35496         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
35497         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35498         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35499         CVec_u8Z_free(ret_var);
35500         return ret_arr;
35501 }
35502
35503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35504         LDKu8slice ser_ref;
35505         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35506         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35507         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
35508         *ret_conv = FundingCreated_read(ser_ref);
35509         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35510         return (int64_t)ret_conv;
35511 }
35512
35513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
35514         LDKFundingSigned obj_conv;
35515         obj_conv.inner = (void*)(obj & (~1));
35516         obj_conv.is_owned = false;
35517         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35518         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
35519         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35520         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35521         CVec_u8Z_free(ret_var);
35522         return ret_arr;
35523 }
35524
35525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35526         LDKu8slice ser_ref;
35527         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35528         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35529         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
35530         *ret_conv = FundingSigned_read(ser_ref);
35531         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35532         return (int64_t)ret_conv;
35533 }
35534
35535 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
35536         LDKFundingLocked obj_conv;
35537         obj_conv.inner = (void*)(obj & (~1));
35538         obj_conv.is_owned = false;
35539         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35540         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
35541         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35542         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35543         CVec_u8Z_free(ret_var);
35544         return ret_arr;
35545 }
35546
35547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35548         LDKu8slice ser_ref;
35549         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35550         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35551         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
35552         *ret_conv = FundingLocked_read(ser_ref);
35553         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35554         return (int64_t)ret_conv;
35555 }
35556
35557 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
35558         LDKInit obj_conv;
35559         obj_conv.inner = (void*)(obj & (~1));
35560         obj_conv.is_owned = false;
35561         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35562         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
35563         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35564         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35565         CVec_u8Z_free(ret_var);
35566         return ret_arr;
35567 }
35568
35569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35570         LDKu8slice ser_ref;
35571         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35572         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35573         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
35574         *ret_conv = Init_read(ser_ref);
35575         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35576         return (int64_t)ret_conv;
35577 }
35578
35579 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
35580         LDKOpenChannel obj_conv;
35581         obj_conv.inner = (void*)(obj & (~1));
35582         obj_conv.is_owned = false;
35583         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35584         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
35585         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35586         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35587         CVec_u8Z_free(ret_var);
35588         return ret_arr;
35589 }
35590
35591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35592         LDKu8slice ser_ref;
35593         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35594         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35595         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
35596         *ret_conv = OpenChannel_read(ser_ref);
35597         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35598         return (int64_t)ret_conv;
35599 }
35600
35601 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
35602         LDKRevokeAndACK obj_conv;
35603         obj_conv.inner = (void*)(obj & (~1));
35604         obj_conv.is_owned = false;
35605         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35606         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
35607         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35608         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35609         CVec_u8Z_free(ret_var);
35610         return ret_arr;
35611 }
35612
35613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35614         LDKu8slice ser_ref;
35615         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35616         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35617         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
35618         *ret_conv = RevokeAndACK_read(ser_ref);
35619         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35620         return (int64_t)ret_conv;
35621 }
35622
35623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
35624         LDKShutdown obj_conv;
35625         obj_conv.inner = (void*)(obj & (~1));
35626         obj_conv.is_owned = false;
35627         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35628         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
35629         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35630         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35631         CVec_u8Z_free(ret_var);
35632         return ret_arr;
35633 }
35634
35635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35636         LDKu8slice ser_ref;
35637         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35638         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35639         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
35640         *ret_conv = Shutdown_read(ser_ref);
35641         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35642         return (int64_t)ret_conv;
35643 }
35644
35645 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35646         LDKUpdateFailHTLC obj_conv;
35647         obj_conv.inner = (void*)(obj & (~1));
35648         obj_conv.is_owned = false;
35649         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35650         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
35651         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35652         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35653         CVec_u8Z_free(ret_var);
35654         return ret_arr;
35655 }
35656
35657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35658         LDKu8slice ser_ref;
35659         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35660         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35661         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
35662         *ret_conv = UpdateFailHTLC_read(ser_ref);
35663         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35664         return (int64_t)ret_conv;
35665 }
35666
35667 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35668         LDKUpdateFailMalformedHTLC obj_conv;
35669         obj_conv.inner = (void*)(obj & (~1));
35670         obj_conv.is_owned = false;
35671         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35672         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
35673         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35674         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35675         CVec_u8Z_free(ret_var);
35676         return ret_arr;
35677 }
35678
35679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35680         LDKu8slice ser_ref;
35681         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35682         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35683         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
35684         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
35685         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35686         return (int64_t)ret_conv;
35687 }
35688
35689 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
35690         LDKUpdateFee obj_conv;
35691         obj_conv.inner = (void*)(obj & (~1));
35692         obj_conv.is_owned = false;
35693         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35694         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
35695         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35696         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35697         CVec_u8Z_free(ret_var);
35698         return ret_arr;
35699 }
35700
35701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35702         LDKu8slice ser_ref;
35703         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35704         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35705         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
35706         *ret_conv = UpdateFee_read(ser_ref);
35707         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35708         return (int64_t)ret_conv;
35709 }
35710
35711 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35712         LDKUpdateFulfillHTLC obj_conv;
35713         obj_conv.inner = (void*)(obj & (~1));
35714         obj_conv.is_owned = false;
35715         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35716         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
35717         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35718         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35719         CVec_u8Z_free(ret_var);
35720         return ret_arr;
35721 }
35722
35723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35724         LDKu8slice ser_ref;
35725         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35726         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35727         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
35728         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
35729         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35730         return (int64_t)ret_conv;
35731 }
35732
35733 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35734         LDKUpdateAddHTLC obj_conv;
35735         obj_conv.inner = (void*)(obj & (~1));
35736         obj_conv.is_owned = false;
35737         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35738         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
35739         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35740         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35741         CVec_u8Z_free(ret_var);
35742         return ret_arr;
35743 }
35744
35745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35746         LDKu8slice ser_ref;
35747         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35748         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35749         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
35750         *ret_conv = UpdateAddHTLC_read(ser_ref);
35751         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35752         return (int64_t)ret_conv;
35753 }
35754
35755 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
35756         LDKPing obj_conv;
35757         obj_conv.inner = (void*)(obj & (~1));
35758         obj_conv.is_owned = false;
35759         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35760         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
35761         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35762         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35763         CVec_u8Z_free(ret_var);
35764         return ret_arr;
35765 }
35766
35767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35768         LDKu8slice ser_ref;
35769         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35770         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35771         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
35772         *ret_conv = Ping_read(ser_ref);
35773         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35774         return (int64_t)ret_conv;
35775 }
35776
35777 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
35778         LDKPong obj_conv;
35779         obj_conv.inner = (void*)(obj & (~1));
35780         obj_conv.is_owned = false;
35781         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35782         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
35783         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35784         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35785         CVec_u8Z_free(ret_var);
35786         return ret_arr;
35787 }
35788
35789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35790         LDKu8slice ser_ref;
35791         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35792         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35793         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
35794         *ret_conv = Pong_read(ser_ref);
35795         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35796         return (int64_t)ret_conv;
35797 }
35798
35799 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35800         LDKUnsignedChannelAnnouncement obj_conv;
35801         obj_conv.inner = (void*)(obj & (~1));
35802         obj_conv.is_owned = false;
35803         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35804         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
35805         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35806         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35807         CVec_u8Z_free(ret_var);
35808         return ret_arr;
35809 }
35810
35811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35812         LDKu8slice ser_ref;
35813         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35814         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35815         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
35816         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
35817         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35818         return (int64_t)ret_conv;
35819 }
35820
35821 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35822         LDKChannelAnnouncement obj_conv;
35823         obj_conv.inner = (void*)(obj & (~1));
35824         obj_conv.is_owned = false;
35825         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35826         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
35827         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35828         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35829         CVec_u8Z_free(ret_var);
35830         return ret_arr;
35831 }
35832
35833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35834         LDKu8slice ser_ref;
35835         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35836         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35837         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
35838         *ret_conv = ChannelAnnouncement_read(ser_ref);
35839         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35840         return (int64_t)ret_conv;
35841 }
35842
35843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
35844         LDKUnsignedChannelUpdate obj_conv;
35845         obj_conv.inner = (void*)(obj & (~1));
35846         obj_conv.is_owned = false;
35847         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35848         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
35849         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35850         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35851         CVec_u8Z_free(ret_var);
35852         return ret_arr;
35853 }
35854
35855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35856         LDKu8slice ser_ref;
35857         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35858         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35859         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
35860         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
35861         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35862         return (int64_t)ret_conv;
35863 }
35864
35865 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
35866         LDKChannelUpdate obj_conv;
35867         obj_conv.inner = (void*)(obj & (~1));
35868         obj_conv.is_owned = false;
35869         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35870         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
35871         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35872         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35873         CVec_u8Z_free(ret_var);
35874         return ret_arr;
35875 }
35876
35877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35878         LDKu8slice ser_ref;
35879         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35880         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35881         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
35882         *ret_conv = ChannelUpdate_read(ser_ref);
35883         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35884         return (int64_t)ret_conv;
35885 }
35886
35887 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
35888         LDKErrorMessage obj_conv;
35889         obj_conv.inner = (void*)(obj & (~1));
35890         obj_conv.is_owned = false;
35891         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35892         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
35893         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35894         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35895         CVec_u8Z_free(ret_var);
35896         return ret_arr;
35897 }
35898
35899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35900         LDKu8slice ser_ref;
35901         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35902         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35903         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
35904         *ret_conv = ErrorMessage_read(ser_ref);
35905         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35906         return (int64_t)ret_conv;
35907 }
35908
35909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
35910         LDKWarningMessage obj_conv;
35911         obj_conv.inner = (void*)(obj & (~1));
35912         obj_conv.is_owned = false;
35913         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35914         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
35915         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35916         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35917         CVec_u8Z_free(ret_var);
35918         return ret_arr;
35919 }
35920
35921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35922         LDKu8slice ser_ref;
35923         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35924         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35925         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
35926         *ret_conv = WarningMessage_read(ser_ref);
35927         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35928         return (int64_t)ret_conv;
35929 }
35930
35931 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35932         LDKUnsignedNodeAnnouncement obj_conv;
35933         obj_conv.inner = (void*)(obj & (~1));
35934         obj_conv.is_owned = false;
35935         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35936         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
35937         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35938         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35939         CVec_u8Z_free(ret_var);
35940         return ret_arr;
35941 }
35942
35943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35944         LDKu8slice ser_ref;
35945         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35946         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35947         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
35948         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
35949         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35950         return (int64_t)ret_conv;
35951 }
35952
35953 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35954         LDKNodeAnnouncement obj_conv;
35955         obj_conv.inner = (void*)(obj & (~1));
35956         obj_conv.is_owned = false;
35957         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35958         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
35959         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35960         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35961         CVec_u8Z_free(ret_var);
35962         return ret_arr;
35963 }
35964
35965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35966         LDKu8slice ser_ref;
35967         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35968         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35969         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
35970         *ret_conv = NodeAnnouncement_read(ser_ref);
35971         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35972         return (int64_t)ret_conv;
35973 }
35974
35975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35976         LDKu8slice ser_ref;
35977         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35978         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35979         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
35980         *ret_conv = QueryShortChannelIds_read(ser_ref);
35981         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35982         return (int64_t)ret_conv;
35983 }
35984
35985 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
35986         LDKQueryShortChannelIds obj_conv;
35987         obj_conv.inner = (void*)(obj & (~1));
35988         obj_conv.is_owned = false;
35989         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35990         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
35991         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35992         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35993         CVec_u8Z_free(ret_var);
35994         return ret_arr;
35995 }
35996
35997 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
35998         LDKReplyShortChannelIdsEnd obj_conv;
35999         obj_conv.inner = (void*)(obj & (~1));
36000         obj_conv.is_owned = false;
36001         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36002         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
36003         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36004         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36005         CVec_u8Z_free(ret_var);
36006         return ret_arr;
36007 }
36008
36009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36010         LDKu8slice ser_ref;
36011         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36012         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36013         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
36014         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
36015         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36016         return (int64_t)ret_conv;
36017 }
36018
36019 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
36020         LDKQueryChannelRange this_arg_conv;
36021         this_arg_conv.inner = (void*)(this_arg & (~1));
36022         this_arg_conv.is_owned = false;
36023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36024         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
36025         return ret_val;
36026 }
36027
36028 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
36029         LDKQueryChannelRange obj_conv;
36030         obj_conv.inner = (void*)(obj & (~1));
36031         obj_conv.is_owned = false;
36032         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36033         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
36034         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36035         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36036         CVec_u8Z_free(ret_var);
36037         return ret_arr;
36038 }
36039
36040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36041         LDKu8slice ser_ref;
36042         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36043         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36044         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
36045         *ret_conv = QueryChannelRange_read(ser_ref);
36046         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36047         return (int64_t)ret_conv;
36048 }
36049
36050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36051         LDKu8slice ser_ref;
36052         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36053         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36054         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
36055         *ret_conv = ReplyChannelRange_read(ser_ref);
36056         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36057         return (int64_t)ret_conv;
36058 }
36059
36060 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
36061         LDKReplyChannelRange obj_conv;
36062         obj_conv.inner = (void*)(obj & (~1));
36063         obj_conv.is_owned = false;
36064         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36065         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
36066         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36067         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36068         CVec_u8Z_free(ret_var);
36069         return ret_arr;
36070 }
36071
36072 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
36073         LDKGossipTimestampFilter obj_conv;
36074         obj_conv.inner = (void*)(obj & (~1));
36075         obj_conv.is_owned = false;
36076         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36077         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
36078         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36079         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36080         CVec_u8Z_free(ret_var);
36081         return ret_arr;
36082 }
36083
36084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36085         LDKu8slice ser_ref;
36086         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36087         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36088         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
36089         *ret_conv = GossipTimestampFilter_read(ser_ref);
36090         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36091         return (int64_t)ret_conv;
36092 }
36093
36094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36095         if ((this_ptr & 1) != 0) return;
36096         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36097         CHECK_ACCESS(this_ptr_ptr);
36098         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
36099         FREE((void*)this_ptr);
36100         CustomMessageHandler_free(this_ptr_conv);
36101 }
36102
36103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36104         LDKIgnoringMessageHandler this_obj_conv;
36105         this_obj_conv.inner = (void*)(this_obj & (~1));
36106         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36108         IgnoringMessageHandler_free(this_obj_conv);
36109 }
36110
36111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
36112         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
36113         int64_t ret_ref = 0;
36114         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36115         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36117         ret_ref = (uintptr_t)ret_var.inner;
36118         if (ret_var.is_owned) {
36119                 ret_ref |= 1;
36120         }
36121         return ret_ref;
36122 }
36123
36124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
36125         LDKIgnoringMessageHandler this_arg_conv;
36126         this_arg_conv.inner = (void*)(this_arg & (~1));
36127         this_arg_conv.is_owned = false;
36128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36129         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
36130         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
36131         return (int64_t)ret_ret;
36132 }
36133
36134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
36135         LDKIgnoringMessageHandler this_arg_conv;
36136         this_arg_conv.inner = (void*)(this_arg & (~1));
36137         this_arg_conv.is_owned = false;
36138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36139         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
36140         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
36141         return (int64_t)ret_ret;
36142 }
36143
36144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
36145         LDKIgnoringMessageHandler this_arg_conv;
36146         this_arg_conv.inner = (void*)(this_arg & (~1));
36147         this_arg_conv.is_owned = false;
36148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36149         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
36150         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
36151         return (int64_t)ret_ret;
36152 }
36153
36154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
36155         LDKIgnoringMessageHandler this_arg_conv;
36156         this_arg_conv.inner = (void*)(this_arg & (~1));
36157         this_arg_conv.is_owned = false;
36158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36159         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
36160         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
36161         return (int64_t)ret_ret;
36162 }
36163
36164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36165         LDKErroringMessageHandler this_obj_conv;
36166         this_obj_conv.inner = (void*)(this_obj & (~1));
36167         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36169         ErroringMessageHandler_free(this_obj_conv);
36170 }
36171
36172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
36173         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
36174         int64_t ret_ref = 0;
36175         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36176         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36178         ret_ref = (uintptr_t)ret_var.inner;
36179         if (ret_var.is_owned) {
36180                 ret_ref |= 1;
36181         }
36182         return ret_ref;
36183 }
36184
36185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
36186         LDKErroringMessageHandler this_arg_conv;
36187         this_arg_conv.inner = (void*)(this_arg & (~1));
36188         this_arg_conv.is_owned = false;
36189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36190         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
36191         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
36192         return (int64_t)ret_ret;
36193 }
36194
36195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
36196         LDKErroringMessageHandler this_arg_conv;
36197         this_arg_conv.inner = (void*)(this_arg & (~1));
36198         this_arg_conv.is_owned = false;
36199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36200         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
36201         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
36202         return (int64_t)ret_ret;
36203 }
36204
36205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36206         LDKMessageHandler this_obj_conv;
36207         this_obj_conv.inner = (void*)(this_obj & (~1));
36208         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36210         MessageHandler_free(this_obj_conv);
36211 }
36212
36213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
36214         LDKMessageHandler this_ptr_conv;
36215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36216         this_ptr_conv.is_owned = false;
36217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36218         // WARNING: This object doesn't live past this scope, needs clone!
36219         int64_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
36220         return ret_ret;
36221 }
36222
36223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36224         LDKMessageHandler this_ptr_conv;
36225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36226         this_ptr_conv.is_owned = false;
36227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36228         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36229         CHECK_ACCESS(val_ptr);
36230         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
36231         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
36232                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36233                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
36234         }
36235         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
36236 }
36237
36238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
36239         LDKMessageHandler this_ptr_conv;
36240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36241         this_ptr_conv.is_owned = false;
36242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36243         // WARNING: This object doesn't live past this scope, needs clone!
36244         int64_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
36245         return ret_ret;
36246 }
36247
36248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36249         LDKMessageHandler this_ptr_conv;
36250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36251         this_ptr_conv.is_owned = false;
36252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36253         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36254         CHECK_ACCESS(val_ptr);
36255         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
36256         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
36257                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36258                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
36259         }
36260         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
36261 }
36262
36263 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) {
36264         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
36265         CHECK_ACCESS(chan_handler_arg_ptr);
36266         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
36267         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
36268                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36269                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
36270         }
36271         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
36272         CHECK_ACCESS(route_handler_arg_ptr);
36273         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
36274         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
36275                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36276                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
36277         }
36278         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
36279         int64_t ret_ref = 0;
36280         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36281         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36283         ret_ref = (uintptr_t)ret_var.inner;
36284         if (ret_var.is_owned) {
36285                 ret_ref |= 1;
36286         }
36287         return ret_ref;
36288 }
36289
36290 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
36291         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
36292         *ret_ret = SocketDescriptor_clone(arg);
36293         return (int64_t)ret_ret;
36294 }
36295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36296         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
36297         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
36298         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
36299         int64_t ret_val = SocketDescriptor_clone_ptr(arg_conv);
36300         return ret_val;
36301 }
36302
36303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36304         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
36305         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
36306         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
36307         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
36308         *ret_ret = SocketDescriptor_clone(orig_conv);
36309         return (int64_t)ret_ret;
36310 }
36311
36312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36313         if ((this_ptr & 1) != 0) return;
36314         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36315         CHECK_ACCESS(this_ptr_ptr);
36316         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
36317         FREE((void*)this_ptr);
36318         SocketDescriptor_free(this_ptr_conv);
36319 }
36320
36321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36322         LDKPeerHandleError this_obj_conv;
36323         this_obj_conv.inner = (void*)(this_obj & (~1));
36324         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36326         PeerHandleError_free(this_obj_conv);
36327 }
36328
36329 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
36330         LDKPeerHandleError this_ptr_conv;
36331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36332         this_ptr_conv.is_owned = false;
36333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36334         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
36335         return ret_val;
36336 }
36337
36338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
36339         LDKPeerHandleError 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         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
36344 }
36345
36346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
36347         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
36348         int64_t ret_ref = 0;
36349         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36350         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36352         ret_ref = (uintptr_t)ret_var.inner;
36353         if (ret_var.is_owned) {
36354                 ret_ref |= 1;
36355         }
36356         return ret_ref;
36357 }
36358
36359 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
36360         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
36361 int64_t ret_ref = 0;
36362 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36363 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36364 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36365 ret_ref = (uintptr_t)ret_var.inner;
36366 if (ret_var.is_owned) {
36367         ret_ref |= 1;
36368 }
36369         return ret_ref;
36370 }
36371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36372         LDKPeerHandleError arg_conv;
36373         arg_conv.inner = (void*)(arg & (~1));
36374         arg_conv.is_owned = false;
36375         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36376         int64_t ret_val = PeerHandleError_clone_ptr(&arg_conv);
36377         return ret_val;
36378 }
36379
36380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36381         LDKPeerHandleError orig_conv;
36382         orig_conv.inner = (void*)(orig & (~1));
36383         orig_conv.is_owned = false;
36384         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36385         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
36386         int64_t ret_ref = 0;
36387         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36388         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36390         ret_ref = (uintptr_t)ret_var.inner;
36391         if (ret_var.is_owned) {
36392                 ret_ref |= 1;
36393         }
36394         return ret_ref;
36395 }
36396
36397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36398         LDKPeerManager this_obj_conv;
36399         this_obj_conv.inner = (void*)(this_obj & (~1));
36400         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36402         PeerManager_free(this_obj_conv);
36403 }
36404
36405 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) {
36406         LDKMessageHandler message_handler_conv;
36407         message_handler_conv.inner = (void*)(message_handler & (~1));
36408         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
36409         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
36410         // WARNING: we need a move here but no clone is available for LDKMessageHandler
36411         LDKSecretKey our_node_secret_ref;
36412         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
36413         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
36414         unsigned char ephemeral_random_data_arr[32];
36415         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
36416         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
36417         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
36418         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
36419         CHECK_ACCESS(logger_ptr);
36420         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
36421         if (logger_conv.free == LDKLogger_JCalls_free) {
36422                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36423                 LDKLogger_JCalls_cloned(&logger_conv);
36424         }
36425         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
36426         CHECK_ACCESS(custom_message_handler_ptr);
36427         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
36428         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
36429                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36430                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
36431         }
36432         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
36433         int64_t ret_ref = 0;
36434         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36435         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36437         ret_ref = (uintptr_t)ret_var.inner;
36438         if (ret_var.is_owned) {
36439                 ret_ref |= 1;
36440         }
36441         return ret_ref;
36442 }
36443
36444 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
36445         LDKPeerManager this_arg_conv;
36446         this_arg_conv.inner = (void*)(this_arg & (~1));
36447         this_arg_conv.is_owned = false;
36448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36449         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
36450         jobjectArray ret_arr = NULL;
36451         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
36452         ;
36453         for (size_t i = 0; i < ret_var.datalen; i++) {
36454                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
36455                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
36456                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
36457         }
36458         
36459         FREE(ret_var.data);
36460         return ret_arr;
36461 }
36462
36463 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) {
36464         LDKPeerManager this_arg_conv;
36465         this_arg_conv.inner = (void*)(this_arg & (~1));
36466         this_arg_conv.is_owned = false;
36467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36468         LDKPublicKey their_node_id_ref;
36469         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
36470         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
36471         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
36472         CHECK_ACCESS(descriptor_ptr);
36473         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
36474         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
36475                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36476                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
36477         }
36478         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
36479         CHECK_ACCESS(remote_network_address_ptr);
36480         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
36481         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
36482         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
36483         return (int64_t)ret_conv;
36484 }
36485
36486 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) {
36487         LDKPeerManager this_arg_conv;
36488         this_arg_conv.inner = (void*)(this_arg & (~1));
36489         this_arg_conv.is_owned = false;
36490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36491         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
36492         CHECK_ACCESS(descriptor_ptr);
36493         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
36494         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
36495                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36496                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
36497         }
36498         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
36499         CHECK_ACCESS(remote_network_address_ptr);
36500         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
36501         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
36502         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
36503         return (int64_t)ret_conv;
36504 }
36505
36506 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) {
36507         LDKPeerManager this_arg_conv;
36508         this_arg_conv.inner = (void*)(this_arg & (~1));
36509         this_arg_conv.is_owned = false;
36510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36511         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
36512         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
36513         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
36514         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
36515         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
36516         return (int64_t)ret_conv;
36517 }
36518
36519 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) {
36520         LDKPeerManager this_arg_conv;
36521         this_arg_conv.inner = (void*)(this_arg & (~1));
36522         this_arg_conv.is_owned = false;
36523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36524         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
36525         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
36526         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
36527         LDKu8slice data_ref;
36528         data_ref.datalen = (*env)->GetArrayLength(env, data);
36529         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
36530         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
36531         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
36532         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
36533         return (int64_t)ret_conv;
36534 }
36535
36536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
36537         LDKPeerManager this_arg_conv;
36538         this_arg_conv.inner = (void*)(this_arg & (~1));
36539         this_arg_conv.is_owned = false;
36540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36541         PeerManager_process_events(&this_arg_conv);
36542 }
36543
36544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
36545         LDKPeerManager this_arg_conv;
36546         this_arg_conv.inner = (void*)(this_arg & (~1));
36547         this_arg_conv.is_owned = false;
36548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36549         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
36550         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
36551         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
36552         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
36553 }
36554
36555 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) {
36556         LDKPeerManager this_arg_conv;
36557         this_arg_conv.inner = (void*)(this_arg & (~1));
36558         this_arg_conv.is_owned = false;
36559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36560         LDKPublicKey node_id_ref;
36561         CHECK((*env)->GetArrayLength(env, node_id) == 33);
36562         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
36563         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
36564 }
36565
36566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
36567         LDKPeerManager this_arg_conv;
36568         this_arg_conv.inner = (void*)(this_arg & (~1));
36569         this_arg_conv.is_owned = false;
36570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36571         PeerManager_disconnect_all_peers(&this_arg_conv);
36572 }
36573
36574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
36575         LDKPeerManager this_arg_conv;
36576         this_arg_conv.inner = (void*)(this_arg & (~1));
36577         this_arg_conv.is_owned = false;
36578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36579         PeerManager_timer_tick_occurred(&this_arg_conv);
36580 }
36581
36582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
36583         int64_t ret_val = htlc_success_tx_weight(opt_anchors);
36584         return ret_val;
36585 }
36586
36587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
36588         int64_t ret_val = htlc_timeout_tx_weight(opt_anchors);
36589         return ret_val;
36590 }
36591
36592 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
36593         unsigned char commitment_seed_arr[32];
36594         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
36595         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
36596         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
36597         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36598         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
36599         return ret_arr;
36600 }
36601
36602 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) {
36603         LDKCVec_u8Z to_holder_script_ref;
36604         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
36605         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
36606         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
36607         LDKCVec_u8Z to_counterparty_script_ref;
36608         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
36609         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
36610         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
36611         LDKOutPoint funding_outpoint_conv;
36612         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
36613         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
36614         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
36615         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
36616         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);
36617         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36618         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36619         Transaction_free(ret_var);
36620         return ret_arr;
36621 }
36622
36623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36624         LDKCounterpartyCommitmentSecrets this_obj_conv;
36625         this_obj_conv.inner = (void*)(this_obj & (~1));
36626         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36628         CounterpartyCommitmentSecrets_free(this_obj_conv);
36629 }
36630
36631 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
36632         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
36633 int64_t ret_ref = 0;
36634 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36635 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36636 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36637 ret_ref = (uintptr_t)ret_var.inner;
36638 if (ret_var.is_owned) {
36639         ret_ref |= 1;
36640 }
36641         return ret_ref;
36642 }
36643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36644         LDKCounterpartyCommitmentSecrets arg_conv;
36645         arg_conv.inner = (void*)(arg & (~1));
36646         arg_conv.is_owned = false;
36647         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36648         int64_t ret_val = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
36649         return ret_val;
36650 }
36651
36652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36653         LDKCounterpartyCommitmentSecrets orig_conv;
36654         orig_conv.inner = (void*)(orig & (~1));
36655         orig_conv.is_owned = false;
36656         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36657         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
36658         int64_t ret_ref = 0;
36659         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36660         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36661         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36662         ret_ref = (uintptr_t)ret_var.inner;
36663         if (ret_var.is_owned) {
36664                 ret_ref |= 1;
36665         }
36666         return ret_ref;
36667 }
36668
36669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
36670         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
36671         int64_t ret_ref = 0;
36672         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36673         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36675         ret_ref = (uintptr_t)ret_var.inner;
36676         if (ret_var.is_owned) {
36677                 ret_ref |= 1;
36678         }
36679         return ret_ref;
36680 }
36681
36682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
36683         LDKCounterpartyCommitmentSecrets this_arg_conv;
36684         this_arg_conv.inner = (void*)(this_arg & (~1));
36685         this_arg_conv.is_owned = false;
36686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36687         int64_t ret_val = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
36688         return ret_val;
36689 }
36690
36691 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) {
36692         LDKCounterpartyCommitmentSecrets this_arg_conv;
36693         this_arg_conv.inner = (void*)(this_arg & (~1));
36694         this_arg_conv.is_owned = false;
36695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36696         LDKThirtyTwoBytes secret_ref;
36697         CHECK((*env)->GetArrayLength(env, secret) == 32);
36698         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
36699         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
36700         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
36701         return (int64_t)ret_conv;
36702 }
36703
36704 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
36705         LDKCounterpartyCommitmentSecrets this_arg_conv;
36706         this_arg_conv.inner = (void*)(this_arg & (~1));
36707         this_arg_conv.is_owned = false;
36708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36709         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36710         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
36711         return ret_arr;
36712 }
36713
36714 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
36715         LDKCounterpartyCommitmentSecrets obj_conv;
36716         obj_conv.inner = (void*)(obj & (~1));
36717         obj_conv.is_owned = false;
36718         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36719         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
36720         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36721         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36722         CVec_u8Z_free(ret_var);
36723         return ret_arr;
36724 }
36725
36726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36727         LDKu8slice ser_ref;
36728         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36729         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36730         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
36731         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
36732         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36733         return (int64_t)ret_conv;
36734 }
36735
36736 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) {
36737         LDKPublicKey per_commitment_point_ref;
36738         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36739         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36740         unsigned char base_secret_arr[32];
36741         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
36742         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
36743         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
36744         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
36745         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
36746         return (int64_t)ret_conv;
36747 }
36748
36749 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) {
36750         LDKPublicKey per_commitment_point_ref;
36751         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36752         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36753         LDKPublicKey base_point_ref;
36754         CHECK((*env)->GetArrayLength(env, base_point) == 33);
36755         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
36756         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
36757         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
36758         return (int64_t)ret_conv;
36759 }
36760
36761 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) {
36762         unsigned char per_commitment_secret_arr[32];
36763         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
36764         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
36765         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
36766         unsigned char countersignatory_revocation_base_secret_arr[32];
36767         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
36768         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
36769         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
36770         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
36771         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
36772         return (int64_t)ret_conv;
36773 }
36774
36775 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) {
36776         LDKPublicKey per_commitment_point_ref;
36777         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36778         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36779         LDKPublicKey countersignatory_revocation_base_point_ref;
36780         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
36781         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
36782         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
36783         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
36784         return (int64_t)ret_conv;
36785 }
36786
36787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36788         LDKTxCreationKeys this_obj_conv;
36789         this_obj_conv.inner = (void*)(this_obj & (~1));
36790         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36792         TxCreationKeys_free(this_obj_conv);
36793 }
36794
36795 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36796         LDKTxCreationKeys this_ptr_conv;
36797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36798         this_ptr_conv.is_owned = false;
36799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36800         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36801         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
36802         return ret_arr;
36803 }
36804
36805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36806         LDKTxCreationKeys this_ptr_conv;
36807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36808         this_ptr_conv.is_owned = false;
36809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36810         LDKPublicKey val_ref;
36811         CHECK((*env)->GetArrayLength(env, val) == 33);
36812         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36813         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
36814 }
36815
36816 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36817         LDKTxCreationKeys this_ptr_conv;
36818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36819         this_ptr_conv.is_owned = false;
36820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36821         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36822         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
36823         return ret_arr;
36824 }
36825
36826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36827         LDKTxCreationKeys this_ptr_conv;
36828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36829         this_ptr_conv.is_owned = false;
36830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36831         LDKPublicKey val_ref;
36832         CHECK((*env)->GetArrayLength(env, val) == 33);
36833         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36834         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
36835 }
36836
36837 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36838         LDKTxCreationKeys this_ptr_conv;
36839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36840         this_ptr_conv.is_owned = false;
36841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36842         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36843         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
36844         return ret_arr;
36845 }
36846
36847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36848         LDKTxCreationKeys this_ptr_conv;
36849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36850         this_ptr_conv.is_owned = false;
36851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36852         LDKPublicKey val_ref;
36853         CHECK((*env)->GetArrayLength(env, val) == 33);
36854         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36855         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
36856 }
36857
36858 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36859         LDKTxCreationKeys this_ptr_conv;
36860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36861         this_ptr_conv.is_owned = false;
36862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36863         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36864         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
36865         return ret_arr;
36866 }
36867
36868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36869         LDKTxCreationKeys this_ptr_conv;
36870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36871         this_ptr_conv.is_owned = false;
36872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36873         LDKPublicKey val_ref;
36874         CHECK((*env)->GetArrayLength(env, val) == 33);
36875         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36876         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
36877 }
36878
36879 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36880         LDKTxCreationKeys this_ptr_conv;
36881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36882         this_ptr_conv.is_owned = false;
36883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36884         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36885         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
36886         return ret_arr;
36887 }
36888
36889 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) {
36890         LDKTxCreationKeys this_ptr_conv;
36891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36892         this_ptr_conv.is_owned = false;
36893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36894         LDKPublicKey val_ref;
36895         CHECK((*env)->GetArrayLength(env, val) == 33);
36896         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36897         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
36898 }
36899
36900 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) {
36901         LDKPublicKey per_commitment_point_arg_ref;
36902         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
36903         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
36904         LDKPublicKey revocation_key_arg_ref;
36905         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
36906         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
36907         LDKPublicKey broadcaster_htlc_key_arg_ref;
36908         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
36909         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
36910         LDKPublicKey countersignatory_htlc_key_arg_ref;
36911         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
36912         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
36913         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
36914         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
36915         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
36916         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);
36917         int64_t ret_ref = 0;
36918         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36919         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36921         ret_ref = (uintptr_t)ret_var.inner;
36922         if (ret_var.is_owned) {
36923                 ret_ref |= 1;
36924         }
36925         return ret_ref;
36926 }
36927
36928 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
36929         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
36930 int64_t ret_ref = 0;
36931 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36932 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36933 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36934 ret_ref = (uintptr_t)ret_var.inner;
36935 if (ret_var.is_owned) {
36936         ret_ref |= 1;
36937 }
36938         return ret_ref;
36939 }
36940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36941         LDKTxCreationKeys arg_conv;
36942         arg_conv.inner = (void*)(arg & (~1));
36943         arg_conv.is_owned = false;
36944         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36945         int64_t ret_val = TxCreationKeys_clone_ptr(&arg_conv);
36946         return ret_val;
36947 }
36948
36949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36950         LDKTxCreationKeys orig_conv;
36951         orig_conv.inner = (void*)(orig & (~1));
36952         orig_conv.is_owned = false;
36953         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36954         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
36955         int64_t ret_ref = 0;
36956         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36957         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36959         ret_ref = (uintptr_t)ret_var.inner;
36960         if (ret_var.is_owned) {
36961                 ret_ref |= 1;
36962         }
36963         return ret_ref;
36964 }
36965
36966 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
36967         LDKTxCreationKeys obj_conv;
36968         obj_conv.inner = (void*)(obj & (~1));
36969         obj_conv.is_owned = false;
36970         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36971         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
36972         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36973         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36974         CVec_u8Z_free(ret_var);
36975         return ret_arr;
36976 }
36977
36978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36979         LDKu8slice ser_ref;
36980         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36981         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36982         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
36983         *ret_conv = TxCreationKeys_read(ser_ref);
36984         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36985         return (int64_t)ret_conv;
36986 }
36987
36988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36989         LDKChannelPublicKeys this_obj_conv;
36990         this_obj_conv.inner = (void*)(this_obj & (~1));
36991         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36993         ChannelPublicKeys_free(this_obj_conv);
36994 }
36995
36996 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
36997         LDKChannelPublicKeys this_ptr_conv;
36998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36999         this_ptr_conv.is_owned = false;
37000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37001         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37002         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
37003         return ret_arr;
37004 }
37005
37006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37007         LDKChannelPublicKeys this_ptr_conv;
37008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37009         this_ptr_conv.is_owned = false;
37010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37011         LDKPublicKey val_ref;
37012         CHECK((*env)->GetArrayLength(env, val) == 33);
37013         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37014         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
37015 }
37016
37017 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37018         LDKChannelPublicKeys this_ptr_conv;
37019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37020         this_ptr_conv.is_owned = false;
37021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37022         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37023         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
37024         return ret_arr;
37025 }
37026
37027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37028         LDKChannelPublicKeys this_ptr_conv;
37029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37030         this_ptr_conv.is_owned = false;
37031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37032         LDKPublicKey val_ref;
37033         CHECK((*env)->GetArrayLength(env, val) == 33);
37034         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37035         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
37036 }
37037
37038 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37039         LDKChannelPublicKeys this_ptr_conv;
37040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37041         this_ptr_conv.is_owned = false;
37042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37043         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37044         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
37045         return ret_arr;
37046 }
37047
37048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37049         LDKChannelPublicKeys this_ptr_conv;
37050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37051         this_ptr_conv.is_owned = false;
37052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37053         LDKPublicKey val_ref;
37054         CHECK((*env)->GetArrayLength(env, val) == 33);
37055         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37056         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
37057 }
37058
37059 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37060         LDKChannelPublicKeys this_ptr_conv;
37061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37062         this_ptr_conv.is_owned = false;
37063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37064         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37065         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
37066         return ret_arr;
37067 }
37068
37069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37070         LDKChannelPublicKeys this_ptr_conv;
37071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37072         this_ptr_conv.is_owned = false;
37073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37074         LDKPublicKey val_ref;
37075         CHECK((*env)->GetArrayLength(env, val) == 33);
37076         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37077         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
37078 }
37079
37080 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37081         LDKChannelPublicKeys this_ptr_conv;
37082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37083         this_ptr_conv.is_owned = false;
37084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37085         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37086         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
37087         return ret_arr;
37088 }
37089
37090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37091         LDKChannelPublicKeys this_ptr_conv;
37092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37093         this_ptr_conv.is_owned = false;
37094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37095         LDKPublicKey val_ref;
37096         CHECK((*env)->GetArrayLength(env, val) == 33);
37097         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37098         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
37099 }
37100
37101 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) {
37102         LDKPublicKey funding_pubkey_arg_ref;
37103         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
37104         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
37105         LDKPublicKey revocation_basepoint_arg_ref;
37106         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
37107         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
37108         LDKPublicKey payment_point_arg_ref;
37109         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
37110         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
37111         LDKPublicKey delayed_payment_basepoint_arg_ref;
37112         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
37113         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
37114         LDKPublicKey htlc_basepoint_arg_ref;
37115         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
37116         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
37117         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);
37118         int64_t ret_ref = 0;
37119         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37120         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37122         ret_ref = (uintptr_t)ret_var.inner;
37123         if (ret_var.is_owned) {
37124                 ret_ref |= 1;
37125         }
37126         return ret_ref;
37127 }
37128
37129 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
37130         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
37131 int64_t ret_ref = 0;
37132 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37133 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37134 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37135 ret_ref = (uintptr_t)ret_var.inner;
37136 if (ret_var.is_owned) {
37137         ret_ref |= 1;
37138 }
37139         return ret_ref;
37140 }
37141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37142         LDKChannelPublicKeys arg_conv;
37143         arg_conv.inner = (void*)(arg & (~1));
37144         arg_conv.is_owned = false;
37145         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37146         int64_t ret_val = ChannelPublicKeys_clone_ptr(&arg_conv);
37147         return ret_val;
37148 }
37149
37150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37151         LDKChannelPublicKeys orig_conv;
37152         orig_conv.inner = (void*)(orig & (~1));
37153         orig_conv.is_owned = false;
37154         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37155         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
37156         int64_t ret_ref = 0;
37157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37160         ret_ref = (uintptr_t)ret_var.inner;
37161         if (ret_var.is_owned) {
37162                 ret_ref |= 1;
37163         }
37164         return ret_ref;
37165 }
37166
37167 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
37168         LDKChannelPublicKeys obj_conv;
37169         obj_conv.inner = (void*)(obj & (~1));
37170         obj_conv.is_owned = false;
37171         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37172         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
37173         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37174         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37175         CVec_u8Z_free(ret_var);
37176         return ret_arr;
37177 }
37178
37179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37180         LDKu8slice ser_ref;
37181         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37182         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37183         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
37184         *ret_conv = ChannelPublicKeys_read(ser_ref);
37185         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37186         return (int64_t)ret_conv;
37187 }
37188
37189 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) {
37190         LDKPublicKey per_commitment_point_ref;
37191         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
37192         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
37193         LDKPublicKey broadcaster_delayed_payment_base_ref;
37194         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
37195         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
37196         LDKPublicKey broadcaster_htlc_base_ref;
37197         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
37198         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
37199         LDKPublicKey countersignatory_revocation_base_ref;
37200         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
37201         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
37202         LDKPublicKey countersignatory_htlc_base_ref;
37203         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
37204         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
37205         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
37206         *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);
37207         return (int64_t)ret_conv;
37208 }
37209
37210 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) {
37211         LDKPublicKey per_commitment_point_ref;
37212         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
37213         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
37214         LDKChannelPublicKeys broadcaster_keys_conv;
37215         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
37216         broadcaster_keys_conv.is_owned = false;
37217         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
37218         LDKChannelPublicKeys countersignatory_keys_conv;
37219         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
37220         countersignatory_keys_conv.is_owned = false;
37221         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
37222         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
37223         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
37224         return (int64_t)ret_conv;
37225 }
37226
37227 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) {
37228         LDKPublicKey revocation_key_ref;
37229         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
37230         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
37231         LDKPublicKey broadcaster_delayed_payment_key_ref;
37232         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
37233         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
37234         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
37235         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37236         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37237         CVec_u8Z_free(ret_var);
37238         return ret_arr;
37239 }
37240
37241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37242         LDKHTLCOutputInCommitment this_obj_conv;
37243         this_obj_conv.inner = (void*)(this_obj & (~1));
37244         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37246         HTLCOutputInCommitment_free(this_obj_conv);
37247 }
37248
37249 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
37250         LDKHTLCOutputInCommitment this_ptr_conv;
37251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37252         this_ptr_conv.is_owned = false;
37253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37254         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
37255         return ret_val;
37256 }
37257
37258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
37259         LDKHTLCOutputInCommitment this_ptr_conv;
37260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37261         this_ptr_conv.is_owned = false;
37262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37263         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
37264 }
37265
37266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37267         LDKHTLCOutputInCommitment this_ptr_conv;
37268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37269         this_ptr_conv.is_owned = false;
37270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37271         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
37272         return ret_val;
37273 }
37274
37275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37276         LDKHTLCOutputInCommitment this_ptr_conv;
37277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37278         this_ptr_conv.is_owned = false;
37279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37280         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
37281 }
37282
37283 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
37284         LDKHTLCOutputInCommitment this_ptr_conv;
37285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37286         this_ptr_conv.is_owned = false;
37287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37288         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
37289         return ret_val;
37290 }
37291
37292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37293         LDKHTLCOutputInCommitment this_ptr_conv;
37294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37295         this_ptr_conv.is_owned = false;
37296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37297         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
37298 }
37299
37300 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
37301         LDKHTLCOutputInCommitment this_ptr_conv;
37302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37303         this_ptr_conv.is_owned = false;
37304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37305         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37306         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
37307         return ret_arr;
37308 }
37309
37310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37311         LDKHTLCOutputInCommitment this_ptr_conv;
37312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37313         this_ptr_conv.is_owned = false;
37314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37315         LDKThirtyTwoBytes val_ref;
37316         CHECK((*env)->GetArrayLength(env, val) == 32);
37317         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37318         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
37319 }
37320
37321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
37322         LDKHTLCOutputInCommitment this_ptr_conv;
37323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37324         this_ptr_conv.is_owned = false;
37325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37326         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
37327         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
37328         int64_t ret_ref = (uintptr_t)ret_copy;
37329         return ret_ref;
37330 }
37331
37332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37333         LDKHTLCOutputInCommitment this_ptr_conv;
37334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37335         this_ptr_conv.is_owned = false;
37336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37337         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
37338         CHECK_ACCESS(val_ptr);
37339         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
37340         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
37341         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
37342 }
37343
37344 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) {
37345         LDKThirtyTwoBytes payment_hash_arg_ref;
37346         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
37347         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
37348         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
37349         CHECK_ACCESS(transaction_output_index_arg_ptr);
37350         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
37351         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
37352         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
37353         int64_t ret_ref = 0;
37354         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37355         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37357         ret_ref = (uintptr_t)ret_var.inner;
37358         if (ret_var.is_owned) {
37359                 ret_ref |= 1;
37360         }
37361         return ret_ref;
37362 }
37363
37364 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
37365         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
37366 int64_t ret_ref = 0;
37367 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37368 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37369 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37370 ret_ref = (uintptr_t)ret_var.inner;
37371 if (ret_var.is_owned) {
37372         ret_ref |= 1;
37373 }
37374         return ret_ref;
37375 }
37376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37377         LDKHTLCOutputInCommitment arg_conv;
37378         arg_conv.inner = (void*)(arg & (~1));
37379         arg_conv.is_owned = false;
37380         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37381         int64_t ret_val = HTLCOutputInCommitment_clone_ptr(&arg_conv);
37382         return ret_val;
37383 }
37384
37385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37386         LDKHTLCOutputInCommitment orig_conv;
37387         orig_conv.inner = (void*)(orig & (~1));
37388         orig_conv.is_owned = false;
37389         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37390         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
37391         int64_t ret_ref = 0;
37392         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37393         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37395         ret_ref = (uintptr_t)ret_var.inner;
37396         if (ret_var.is_owned) {
37397                 ret_ref |= 1;
37398         }
37399         return ret_ref;
37400 }
37401
37402 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
37403         LDKHTLCOutputInCommitment obj_conv;
37404         obj_conv.inner = (void*)(obj & (~1));
37405         obj_conv.is_owned = false;
37406         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37407         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
37408         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37409         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37410         CVec_u8Z_free(ret_var);
37411         return ret_arr;
37412 }
37413
37414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37415         LDKu8slice ser_ref;
37416         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37417         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37418         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
37419         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
37420         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37421         return (int64_t)ret_conv;
37422 }
37423
37424 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) {
37425         LDKHTLCOutputInCommitment htlc_conv;
37426         htlc_conv.inner = (void*)(htlc & (~1));
37427         htlc_conv.is_owned = false;
37428         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
37429         LDKTxCreationKeys keys_conv;
37430         keys_conv.inner = (void*)(keys & (~1));
37431         keys_conv.is_owned = false;
37432         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
37433         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
37434         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37435         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37436         CVec_u8Z_free(ret_var);
37437         return ret_arr;
37438 }
37439
37440 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
37441         LDKPublicKey broadcaster_ref;
37442         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
37443         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
37444         LDKPublicKey countersignatory_ref;
37445         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
37446         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
37447         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
37448         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37449         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37450         CVec_u8Z_free(ret_var);
37451         return ret_arr;
37452 }
37453
37454 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) {
37455         unsigned char commitment_txid_arr[32];
37456         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
37457         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
37458         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
37459         LDKHTLCOutputInCommitment htlc_conv;
37460         htlc_conv.inner = (void*)(htlc & (~1));
37461         htlc_conv.is_owned = false;
37462         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
37463         LDKPublicKey broadcaster_delayed_payment_key_ref;
37464         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
37465         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
37466         LDKPublicKey revocation_key_ref;
37467         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
37468         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
37469         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);
37470         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37471         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37472         Transaction_free(ret_var);
37473         return ret_arr;
37474 }
37475
37476 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
37477         LDKPublicKey funding_pubkey_ref;
37478         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
37479         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
37480         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
37481         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37482         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37483         CVec_u8Z_free(ret_var);
37484         return ret_arr;
37485 }
37486
37487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37488         LDKChannelTransactionParameters this_obj_conv;
37489         this_obj_conv.inner = (void*)(this_obj & (~1));
37490         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37492         ChannelTransactionParameters_free(this_obj_conv);
37493 }
37494
37495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
37496         LDKChannelTransactionParameters this_ptr_conv;
37497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37498         this_ptr_conv.is_owned = false;
37499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37500         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
37501         int64_t ret_ref = 0;
37502         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37503         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37505         ret_ref = (uintptr_t)ret_var.inner;
37506         if (ret_var.is_owned) {
37507                 ret_ref |= 1;
37508         }
37509         return ret_ref;
37510 }
37511
37512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37513         LDKChannelTransactionParameters this_ptr_conv;
37514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37515         this_ptr_conv.is_owned = false;
37516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37517         LDKChannelPublicKeys val_conv;
37518         val_conv.inner = (void*)(val & (~1));
37519         val_conv.is_owned = (val & 1) || (val == 0);
37520         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37521         val_conv = ChannelPublicKeys_clone(&val_conv);
37522         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
37523 }
37524
37525 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
37526         LDKChannelTransactionParameters this_ptr_conv;
37527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37528         this_ptr_conv.is_owned = false;
37529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37530         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
37531         return ret_val;
37532 }
37533
37534 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) {
37535         LDKChannelTransactionParameters this_ptr_conv;
37536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37537         this_ptr_conv.is_owned = false;
37538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37539         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
37540 }
37541
37542 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
37543         LDKChannelTransactionParameters this_ptr_conv;
37544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37545         this_ptr_conv.is_owned = false;
37546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37547         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
37548         return ret_val;
37549 }
37550
37551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
37552         LDKChannelTransactionParameters this_ptr_conv;
37553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37554         this_ptr_conv.is_owned = false;
37555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37556         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
37557 }
37558
37559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
37560         LDKChannelTransactionParameters this_ptr_conv;
37561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37562         this_ptr_conv.is_owned = false;
37563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37564         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
37565         int64_t ret_ref = 0;
37566         if ((uintptr_t)ret_var.inner > 4096) {
37567                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37568                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37570                 ret_ref = (uintptr_t)ret_var.inner;
37571                 if (ret_var.is_owned) {
37572                         ret_ref |= 1;
37573                 }
37574         }
37575         return ret_ref;
37576 }
37577
37578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37579         LDKChannelTransactionParameters this_ptr_conv;
37580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37581         this_ptr_conv.is_owned = false;
37582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37583         LDKCounterpartyChannelTransactionParameters val_conv;
37584         val_conv.inner = (void*)(val & (~1));
37585         val_conv.is_owned = (val & 1) || (val == 0);
37586         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37587         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
37588         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
37589 }
37590
37591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37592         LDKChannelTransactionParameters this_ptr_conv;
37593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37594         this_ptr_conv.is_owned = false;
37595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37596         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
37597         int64_t ret_ref = 0;
37598         if ((uintptr_t)ret_var.inner > 4096) {
37599                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37600                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37602                 ret_ref = (uintptr_t)ret_var.inner;
37603                 if (ret_var.is_owned) {
37604                         ret_ref |= 1;
37605                 }
37606         }
37607         return ret_ref;
37608 }
37609
37610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37611         LDKChannelTransactionParameters this_ptr_conv;
37612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37613         this_ptr_conv.is_owned = false;
37614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37615         LDKOutPoint val_conv;
37616         val_conv.inner = (void*)(val & (~1));
37617         val_conv.is_owned = (val & 1) || (val == 0);
37618         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37619         val_conv = OutPoint_clone(&val_conv);
37620         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
37621 }
37622
37623 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
37624         LDKChannelTransactionParameters this_ptr_conv;
37625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37626         this_ptr_conv.is_owned = false;
37627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37628         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
37629         return ret_conv;
37630 }
37631
37632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
37633         LDKChannelTransactionParameters this_ptr_conv;
37634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37635         this_ptr_conv.is_owned = false;
37636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37637         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
37638         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
37639 }
37640
37641 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) {
37642         LDKChannelPublicKeys holder_pubkeys_arg_conv;
37643         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
37644         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
37645         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
37646         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
37647         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
37648         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
37649         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
37650         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
37651         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
37652         LDKOutPoint funding_outpoint_arg_conv;
37653         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
37654         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
37655         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
37656         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
37657         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
37658         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);
37659         int64_t ret_ref = 0;
37660         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37661         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37663         ret_ref = (uintptr_t)ret_var.inner;
37664         if (ret_var.is_owned) {
37665                 ret_ref |= 1;
37666         }
37667         return ret_ref;
37668 }
37669
37670 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
37671         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
37672 int64_t ret_ref = 0;
37673 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37674 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37675 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37676 ret_ref = (uintptr_t)ret_var.inner;
37677 if (ret_var.is_owned) {
37678         ret_ref |= 1;
37679 }
37680         return ret_ref;
37681 }
37682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37683         LDKChannelTransactionParameters arg_conv;
37684         arg_conv.inner = (void*)(arg & (~1));
37685         arg_conv.is_owned = false;
37686         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37687         int64_t ret_val = ChannelTransactionParameters_clone_ptr(&arg_conv);
37688         return ret_val;
37689 }
37690
37691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37692         LDKChannelTransactionParameters orig_conv;
37693         orig_conv.inner = (void*)(orig & (~1));
37694         orig_conv.is_owned = false;
37695         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37696         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
37697         int64_t ret_ref = 0;
37698         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37699         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37700         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37701         ret_ref = (uintptr_t)ret_var.inner;
37702         if (ret_var.is_owned) {
37703                 ret_ref |= 1;
37704         }
37705         return ret_ref;
37706 }
37707
37708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37709         LDKCounterpartyChannelTransactionParameters this_obj_conv;
37710         this_obj_conv.inner = (void*)(this_obj & (~1));
37711         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37713         CounterpartyChannelTransactionParameters_free(this_obj_conv);
37714 }
37715
37716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
37717         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37719         this_ptr_conv.is_owned = false;
37720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37721         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
37722         int64_t ret_ref = 0;
37723         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37724         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37726         ret_ref = (uintptr_t)ret_var.inner;
37727         if (ret_var.is_owned) {
37728                 ret_ref |= 1;
37729         }
37730         return ret_ref;
37731 }
37732
37733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37734         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37736         this_ptr_conv.is_owned = false;
37737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37738         LDKChannelPublicKeys val_conv;
37739         val_conv.inner = (void*)(val & (~1));
37740         val_conv.is_owned = (val & 1) || (val == 0);
37741         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37742         val_conv = ChannelPublicKeys_clone(&val_conv);
37743         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
37744 }
37745
37746 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
37747         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37749         this_ptr_conv.is_owned = false;
37750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37751         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
37752         return ret_val;
37753 }
37754
37755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
37756         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37758         this_ptr_conv.is_owned = false;
37759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37760         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
37761 }
37762
37763 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) {
37764         LDKChannelPublicKeys pubkeys_arg_conv;
37765         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
37766         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
37767         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
37768         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
37769         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
37770         int64_t ret_ref = 0;
37771         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37772         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37774         ret_ref = (uintptr_t)ret_var.inner;
37775         if (ret_var.is_owned) {
37776                 ret_ref |= 1;
37777         }
37778         return ret_ref;
37779 }
37780
37781 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
37782         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
37783 int64_t ret_ref = 0;
37784 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37785 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37786 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37787 ret_ref = (uintptr_t)ret_var.inner;
37788 if (ret_var.is_owned) {
37789         ret_ref |= 1;
37790 }
37791         return ret_ref;
37792 }
37793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37794         LDKCounterpartyChannelTransactionParameters arg_conv;
37795         arg_conv.inner = (void*)(arg & (~1));
37796         arg_conv.is_owned = false;
37797         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37798         int64_t ret_val = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
37799         return ret_val;
37800 }
37801
37802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37803         LDKCounterpartyChannelTransactionParameters orig_conv;
37804         orig_conv.inner = (void*)(orig & (~1));
37805         orig_conv.is_owned = false;
37806         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37807         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
37808         int64_t ret_ref = 0;
37809         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37810         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37812         ret_ref = (uintptr_t)ret_var.inner;
37813         if (ret_var.is_owned) {
37814                 ret_ref |= 1;
37815         }
37816         return ret_ref;
37817 }
37818
37819 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
37820         LDKChannelTransactionParameters this_arg_conv;
37821         this_arg_conv.inner = (void*)(this_arg & (~1));
37822         this_arg_conv.is_owned = false;
37823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37824         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
37825         return ret_val;
37826 }
37827
37828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
37829         LDKChannelTransactionParameters this_arg_conv;
37830         this_arg_conv.inner = (void*)(this_arg & (~1));
37831         this_arg_conv.is_owned = false;
37832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37833         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
37834         int64_t ret_ref = 0;
37835         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37836         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37838         ret_ref = (uintptr_t)ret_var.inner;
37839         if (ret_var.is_owned) {
37840                 ret_ref |= 1;
37841         }
37842         return ret_ref;
37843 }
37844
37845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
37846         LDKChannelTransactionParameters 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         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
37851         int64_t ret_ref = 0;
37852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37855         ret_ref = (uintptr_t)ret_var.inner;
37856         if (ret_var.is_owned) {
37857                 ret_ref |= 1;
37858         }
37859         return ret_ref;
37860 }
37861
37862 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
37863         LDKCounterpartyChannelTransactionParameters obj_conv;
37864         obj_conv.inner = (void*)(obj & (~1));
37865         obj_conv.is_owned = false;
37866         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37867         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
37868         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37869         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37870         CVec_u8Z_free(ret_var);
37871         return ret_arr;
37872 }
37873
37874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37875         LDKu8slice ser_ref;
37876         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37877         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37878         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
37879         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
37880         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37881         return (int64_t)ret_conv;
37882 }
37883
37884 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
37885         LDKChannelTransactionParameters obj_conv;
37886         obj_conv.inner = (void*)(obj & (~1));
37887         obj_conv.is_owned = false;
37888         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37889         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
37890         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37891         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37892         CVec_u8Z_free(ret_var);
37893         return ret_arr;
37894 }
37895
37896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37897         LDKu8slice ser_ref;
37898         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37899         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37900         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
37901         *ret_conv = ChannelTransactionParameters_read(ser_ref);
37902         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37903         return (int64_t)ret_conv;
37904 }
37905
37906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37907         LDKDirectedChannelTransactionParameters this_obj_conv;
37908         this_obj_conv.inner = (void*)(this_obj & (~1));
37909         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37911         DirectedChannelTransactionParameters_free(this_obj_conv);
37912 }
37913
37914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
37915         LDKDirectedChannelTransactionParameters this_arg_conv;
37916         this_arg_conv.inner = (void*)(this_arg & (~1));
37917         this_arg_conv.is_owned = false;
37918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37919         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
37920         int64_t ret_ref = 0;
37921         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37922         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37923         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37924         ret_ref = (uintptr_t)ret_var.inner;
37925         if (ret_var.is_owned) {
37926                 ret_ref |= 1;
37927         }
37928         return ret_ref;
37929 }
37930
37931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
37932         LDKDirectedChannelTransactionParameters this_arg_conv;
37933         this_arg_conv.inner = (void*)(this_arg & (~1));
37934         this_arg_conv.is_owned = false;
37935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37936         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
37937         int64_t ret_ref = 0;
37938         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37939         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37941         ret_ref = (uintptr_t)ret_var.inner;
37942         if (ret_var.is_owned) {
37943                 ret_ref |= 1;
37944         }
37945         return ret_ref;
37946 }
37947
37948 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
37949         LDKDirectedChannelTransactionParameters this_arg_conv;
37950         this_arg_conv.inner = (void*)(this_arg & (~1));
37951         this_arg_conv.is_owned = false;
37952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37953         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
37954         return ret_val;
37955 }
37956
37957 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
37958         LDKDirectedChannelTransactionParameters this_arg_conv;
37959         this_arg_conv.inner = (void*)(this_arg & (~1));
37960         this_arg_conv.is_owned = false;
37961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37962         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
37963         return ret_val;
37964 }
37965
37966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
37967         LDKDirectedChannelTransactionParameters this_arg_conv;
37968         this_arg_conv.inner = (void*)(this_arg & (~1));
37969         this_arg_conv.is_owned = false;
37970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37971         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
37972         int64_t ret_ref = 0;
37973         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37974         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37976         ret_ref = (uintptr_t)ret_var.inner;
37977         if (ret_var.is_owned) {
37978                 ret_ref |= 1;
37979         }
37980         return ret_ref;
37981 }
37982
37983 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
37984         LDKDirectedChannelTransactionParameters this_arg_conv;
37985         this_arg_conv.inner = (void*)(this_arg & (~1));
37986         this_arg_conv.is_owned = false;
37987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37988         jboolean ret_val = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
37989         return ret_val;
37990 }
37991
37992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37993         LDKHolderCommitmentTransaction this_obj_conv;
37994         this_obj_conv.inner = (void*)(this_obj & (~1));
37995         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37997         HolderCommitmentTransaction_free(this_obj_conv);
37998 }
37999
38000 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
38001         LDKHolderCommitmentTransaction this_ptr_conv;
38002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38003         this_ptr_conv.is_owned = false;
38004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38005         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38006         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
38007         return ret_arr;
38008 }
38009
38010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38011         LDKHolderCommitmentTransaction this_ptr_conv;
38012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38013         this_ptr_conv.is_owned = false;
38014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38015         LDKSignature val_ref;
38016         CHECK((*env)->GetArrayLength(env, val) == 64);
38017         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38018         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
38019 }
38020
38021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
38022         LDKHolderCommitmentTransaction this_ptr_conv;
38023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38024         this_ptr_conv.is_owned = false;
38025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38026         LDKCVec_SignatureZ val_constr;
38027         val_constr.datalen = (*env)->GetArrayLength(env, val);
38028         if (val_constr.datalen > 0)
38029                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
38030         else
38031                 val_constr.data = NULL;
38032         for (size_t i = 0; i < val_constr.datalen; i++) {
38033                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
38034                 LDKSignature val_conv_8_ref;
38035                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
38036                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
38037                 val_constr.data[i] = val_conv_8_ref;
38038         }
38039         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
38040 }
38041
38042 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
38043         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
38044 int64_t ret_ref = 0;
38045 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38046 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38047 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38048 ret_ref = (uintptr_t)ret_var.inner;
38049 if (ret_var.is_owned) {
38050         ret_ref |= 1;
38051 }
38052         return ret_ref;
38053 }
38054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38055         LDKHolderCommitmentTransaction arg_conv;
38056         arg_conv.inner = (void*)(arg & (~1));
38057         arg_conv.is_owned = false;
38058         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38059         int64_t ret_val = HolderCommitmentTransaction_clone_ptr(&arg_conv);
38060         return ret_val;
38061 }
38062
38063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38064         LDKHolderCommitmentTransaction orig_conv;
38065         orig_conv.inner = (void*)(orig & (~1));
38066         orig_conv.is_owned = false;
38067         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38068         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
38069         int64_t ret_ref = 0;
38070         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38071         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38073         ret_ref = (uintptr_t)ret_var.inner;
38074         if (ret_var.is_owned) {
38075                 ret_ref |= 1;
38076         }
38077         return ret_ref;
38078 }
38079
38080 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
38081         LDKHolderCommitmentTransaction obj_conv;
38082         obj_conv.inner = (void*)(obj & (~1));
38083         obj_conv.is_owned = false;
38084         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38085         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
38086         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38087         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38088         CVec_u8Z_free(ret_var);
38089         return ret_arr;
38090 }
38091
38092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38093         LDKu8slice ser_ref;
38094         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38095         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38096         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
38097         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
38098         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38099         return (int64_t)ret_conv;
38100 }
38101
38102 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) {
38103         LDKCommitmentTransaction commitment_tx_conv;
38104         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
38105         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
38106         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
38107         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
38108         LDKSignature counterparty_sig_ref;
38109         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
38110         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
38111         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
38112         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
38113         if (counterparty_htlc_sigs_constr.datalen > 0)
38114                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
38115         else
38116                 counterparty_htlc_sigs_constr.data = NULL;
38117         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
38118                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
38119                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
38120                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
38121                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
38122                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
38123         }
38124         LDKPublicKey holder_funding_key_ref;
38125         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
38126         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
38127         LDKPublicKey counterparty_funding_key_ref;
38128         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
38129         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
38130         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
38131         int64_t ret_ref = 0;
38132         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38133         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38135         ret_ref = (uintptr_t)ret_var.inner;
38136         if (ret_var.is_owned) {
38137                 ret_ref |= 1;
38138         }
38139         return ret_ref;
38140 }
38141
38142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38143         LDKBuiltCommitmentTransaction this_obj_conv;
38144         this_obj_conv.inner = (void*)(this_obj & (~1));
38145         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38147         BuiltCommitmentTransaction_free(this_obj_conv);
38148 }
38149
38150 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
38151         LDKBuiltCommitmentTransaction this_ptr_conv;
38152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38153         this_ptr_conv.is_owned = false;
38154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38155         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
38156         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38157         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38158         Transaction_free(ret_var);
38159         return ret_arr;
38160 }
38161
38162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38163         LDKBuiltCommitmentTransaction this_ptr_conv;
38164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38165         this_ptr_conv.is_owned = false;
38166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38167         LDKTransaction val_ref;
38168         val_ref.datalen = (*env)->GetArrayLength(env, val);
38169         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
38170         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
38171         val_ref.data_is_owned = true;
38172         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
38173 }
38174
38175 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
38176         LDKBuiltCommitmentTransaction this_ptr_conv;
38177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38178         this_ptr_conv.is_owned = false;
38179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38180         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38181         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
38182         return ret_arr;
38183 }
38184
38185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38186         LDKBuiltCommitmentTransaction this_ptr_conv;
38187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38188         this_ptr_conv.is_owned = false;
38189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38190         LDKThirtyTwoBytes val_ref;
38191         CHECK((*env)->GetArrayLength(env, val) == 32);
38192         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38193         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
38194 }
38195
38196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
38197         LDKTransaction transaction_arg_ref;
38198         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
38199         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
38200         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
38201         transaction_arg_ref.data_is_owned = true;
38202         LDKThirtyTwoBytes txid_arg_ref;
38203         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
38204         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
38205         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
38206         int64_t ret_ref = 0;
38207         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38208         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38210         ret_ref = (uintptr_t)ret_var.inner;
38211         if (ret_var.is_owned) {
38212                 ret_ref |= 1;
38213         }
38214         return ret_ref;
38215 }
38216
38217 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
38218         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
38219 int64_t ret_ref = 0;
38220 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38221 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38222 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38223 ret_ref = (uintptr_t)ret_var.inner;
38224 if (ret_var.is_owned) {
38225         ret_ref |= 1;
38226 }
38227         return ret_ref;
38228 }
38229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38230         LDKBuiltCommitmentTransaction arg_conv;
38231         arg_conv.inner = (void*)(arg & (~1));
38232         arg_conv.is_owned = false;
38233         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38234         int64_t ret_val = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
38235         return ret_val;
38236 }
38237
38238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38239         LDKBuiltCommitmentTransaction orig_conv;
38240         orig_conv.inner = (void*)(orig & (~1));
38241         orig_conv.is_owned = false;
38242         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38243         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
38244         int64_t ret_ref = 0;
38245         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38246         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38248         ret_ref = (uintptr_t)ret_var.inner;
38249         if (ret_var.is_owned) {
38250                 ret_ref |= 1;
38251         }
38252         return ret_ref;
38253 }
38254
38255 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
38256         LDKBuiltCommitmentTransaction obj_conv;
38257         obj_conv.inner = (void*)(obj & (~1));
38258         obj_conv.is_owned = false;
38259         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38260         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
38261         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38262         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38263         CVec_u8Z_free(ret_var);
38264         return ret_arr;
38265 }
38266
38267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38268         LDKu8slice ser_ref;
38269         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38270         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38271         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
38272         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
38273         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38274         return (int64_t)ret_conv;
38275 }
38276
38277 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) {
38278         LDKBuiltCommitmentTransaction this_arg_conv;
38279         this_arg_conv.inner = (void*)(this_arg & (~1));
38280         this_arg_conv.is_owned = false;
38281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38282         LDKu8slice funding_redeemscript_ref;
38283         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
38284         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
38285         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38286         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
38287         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
38288         return ret_arr;
38289 }
38290
38291 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) {
38292         LDKBuiltCommitmentTransaction this_arg_conv;
38293         this_arg_conv.inner = (void*)(this_arg & (~1));
38294         this_arg_conv.is_owned = false;
38295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38296         unsigned char funding_key_arr[32];
38297         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
38298         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
38299         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
38300         LDKu8slice funding_redeemscript_ref;
38301         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
38302         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
38303         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38304         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
38305         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
38306         return ret_arr;
38307 }
38308
38309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38310         LDKClosingTransaction this_obj_conv;
38311         this_obj_conv.inner = (void*)(this_obj & (~1));
38312         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38314         ClosingTransaction_free(this_obj_conv);
38315 }
38316
38317 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
38318         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
38319 int64_t ret_ref = 0;
38320 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38321 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38322 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38323 ret_ref = (uintptr_t)ret_var.inner;
38324 if (ret_var.is_owned) {
38325         ret_ref |= 1;
38326 }
38327         return ret_ref;
38328 }
38329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38330         LDKClosingTransaction arg_conv;
38331         arg_conv.inner = (void*)(arg & (~1));
38332         arg_conv.is_owned = false;
38333         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38334         int64_t ret_val = ClosingTransaction_clone_ptr(&arg_conv);
38335         return ret_val;
38336 }
38337
38338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38339         LDKClosingTransaction orig_conv;
38340         orig_conv.inner = (void*)(orig & (~1));
38341         orig_conv.is_owned = false;
38342         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38343         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
38344         int64_t ret_ref = 0;
38345         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38346         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38348         ret_ref = (uintptr_t)ret_var.inner;
38349         if (ret_var.is_owned) {
38350                 ret_ref |= 1;
38351         }
38352         return ret_ref;
38353 }
38354
38355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
38356         LDKClosingTransaction o_conv;
38357         o_conv.inner = (void*)(o & (~1));
38358         o_conv.is_owned = false;
38359         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38360         int64_t ret_val = ClosingTransaction_hash(&o_conv);
38361         return ret_val;
38362 }
38363
38364 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) {
38365         LDKCVec_u8Z to_holder_script_ref;
38366         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
38367         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
38368         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
38369         LDKCVec_u8Z to_counterparty_script_ref;
38370         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
38371         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
38372         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
38373         LDKOutPoint funding_outpoint_conv;
38374         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
38375         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
38376         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
38377         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
38378         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
38379         int64_t ret_ref = 0;
38380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38383         ret_ref = (uintptr_t)ret_var.inner;
38384         if (ret_var.is_owned) {
38385                 ret_ref |= 1;
38386         }
38387         return ret_ref;
38388 }
38389
38390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
38391         LDKClosingTransaction this_arg_conv;
38392         this_arg_conv.inner = (void*)(this_arg & (~1));
38393         this_arg_conv.is_owned = false;
38394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38395         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
38396         int64_t ret_ref = 0;
38397         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38398         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38400         ret_ref = (uintptr_t)ret_var.inner;
38401         if (ret_var.is_owned) {
38402                 ret_ref |= 1;
38403         }
38404         return ret_ref;
38405 }
38406
38407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
38408         LDKClosingTransaction this_arg_conv;
38409         this_arg_conv.inner = (void*)(this_arg & (~1));
38410         this_arg_conv.is_owned = false;
38411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38412         LDKOutPoint funding_outpoint_conv;
38413         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
38414         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
38415         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
38416         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
38417         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
38418         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
38419         return (int64_t)ret_conv;
38420 }
38421
38422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
38423         LDKClosingTransaction this_arg_conv;
38424         this_arg_conv.inner = (void*)(this_arg & (~1));
38425         this_arg_conv.is_owned = false;
38426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38427         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
38428         return ret_val;
38429 }
38430
38431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
38432         LDKClosingTransaction this_arg_conv;
38433         this_arg_conv.inner = (void*)(this_arg & (~1));
38434         this_arg_conv.is_owned = false;
38435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38436         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
38437         return ret_val;
38438 }
38439
38440 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
38441         LDKClosingTransaction this_arg_conv;
38442         this_arg_conv.inner = (void*)(this_arg & (~1));
38443         this_arg_conv.is_owned = false;
38444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38445         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
38446         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38447         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38448         return ret_arr;
38449 }
38450
38451 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
38452         LDKClosingTransaction this_arg_conv;
38453         this_arg_conv.inner = (void*)(this_arg & (~1));
38454         this_arg_conv.is_owned = false;
38455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38456         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
38457         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38458         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38459         return ret_arr;
38460 }
38461
38462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38463         LDKTrustedClosingTransaction this_obj_conv;
38464         this_obj_conv.inner = (void*)(this_obj & (~1));
38465         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38467         TrustedClosingTransaction_free(this_obj_conv);
38468 }
38469
38470 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
38471         LDKTrustedClosingTransaction this_arg_conv;
38472         this_arg_conv.inner = (void*)(this_arg & (~1));
38473         this_arg_conv.is_owned = false;
38474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38475         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
38476         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38477         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38478         Transaction_free(ret_var);
38479         return ret_arr;
38480 }
38481
38482 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) {
38483         LDKTrustedClosingTransaction this_arg_conv;
38484         this_arg_conv.inner = (void*)(this_arg & (~1));
38485         this_arg_conv.is_owned = false;
38486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38487         LDKu8slice funding_redeemscript_ref;
38488         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
38489         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
38490         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38491         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
38492         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
38493         return ret_arr;
38494 }
38495
38496 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) {
38497         LDKTrustedClosingTransaction this_arg_conv;
38498         this_arg_conv.inner = (void*)(this_arg & (~1));
38499         this_arg_conv.is_owned = false;
38500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38501         unsigned char funding_key_arr[32];
38502         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
38503         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
38504         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
38505         LDKu8slice funding_redeemscript_ref;
38506         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
38507         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
38508         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38509         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
38510         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
38511         return ret_arr;
38512 }
38513
38514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38515         LDKCommitmentTransaction this_obj_conv;
38516         this_obj_conv.inner = (void*)(this_obj & (~1));
38517         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38519         CommitmentTransaction_free(this_obj_conv);
38520 }
38521
38522 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
38523         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
38524 int64_t ret_ref = 0;
38525 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38526 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38527 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38528 ret_ref = (uintptr_t)ret_var.inner;
38529 if (ret_var.is_owned) {
38530         ret_ref |= 1;
38531 }
38532         return ret_ref;
38533 }
38534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38535         LDKCommitmentTransaction arg_conv;
38536         arg_conv.inner = (void*)(arg & (~1));
38537         arg_conv.is_owned = false;
38538         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38539         int64_t ret_val = CommitmentTransaction_clone_ptr(&arg_conv);
38540         return ret_val;
38541 }
38542
38543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38544         LDKCommitmentTransaction orig_conv;
38545         orig_conv.inner = (void*)(orig & (~1));
38546         orig_conv.is_owned = false;
38547         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38548         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
38549         int64_t ret_ref = 0;
38550         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38551         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38553         ret_ref = (uintptr_t)ret_var.inner;
38554         if (ret_var.is_owned) {
38555                 ret_ref |= 1;
38556         }
38557         return ret_ref;
38558 }
38559
38560 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
38561         LDKCommitmentTransaction obj_conv;
38562         obj_conv.inner = (void*)(obj & (~1));
38563         obj_conv.is_owned = false;
38564         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38565         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
38566         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38567         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38568         CVec_u8Z_free(ret_var);
38569         return ret_arr;
38570 }
38571
38572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38573         LDKu8slice ser_ref;
38574         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38575         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38576         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
38577         *ret_conv = CommitmentTransaction_read(ser_ref);
38578         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38579         return (int64_t)ret_conv;
38580 }
38581
38582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
38583         LDKCommitmentTransaction this_arg_conv;
38584         this_arg_conv.inner = (void*)(this_arg & (~1));
38585         this_arg_conv.is_owned = false;
38586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38587         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
38588         return ret_val;
38589 }
38590
38591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
38592         LDKCommitmentTransaction this_arg_conv;
38593         this_arg_conv.inner = (void*)(this_arg & (~1));
38594         this_arg_conv.is_owned = false;
38595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38596         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
38597         return ret_val;
38598 }
38599
38600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
38601         LDKCommitmentTransaction this_arg_conv;
38602         this_arg_conv.inner = (void*)(this_arg & (~1));
38603         this_arg_conv.is_owned = false;
38604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38605         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
38606         return ret_val;
38607 }
38608
38609 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
38610         LDKCommitmentTransaction this_arg_conv;
38611         this_arg_conv.inner = (void*)(this_arg & (~1));
38612         this_arg_conv.is_owned = false;
38613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38614         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
38615         return ret_val;
38616 }
38617
38618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
38619         LDKCommitmentTransaction this_arg_conv;
38620         this_arg_conv.inner = (void*)(this_arg & (~1));
38621         this_arg_conv.is_owned = false;
38622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38623         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
38624         int64_t ret_ref = 0;
38625         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38626         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38628         ret_ref = (uintptr_t)ret_var.inner;
38629         if (ret_var.is_owned) {
38630                 ret_ref |= 1;
38631         }
38632         return ret_ref;
38633 }
38634
38635 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) {
38636         LDKCommitmentTransaction this_arg_conv;
38637         this_arg_conv.inner = (void*)(this_arg & (~1));
38638         this_arg_conv.is_owned = false;
38639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38640         LDKDirectedChannelTransactionParameters channel_parameters_conv;
38641         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
38642         channel_parameters_conv.is_owned = false;
38643         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
38644         LDKChannelPublicKeys broadcaster_keys_conv;
38645         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
38646         broadcaster_keys_conv.is_owned = false;
38647         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
38648         LDKChannelPublicKeys countersignatory_keys_conv;
38649         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
38650         countersignatory_keys_conv.is_owned = false;
38651         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
38652         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
38653         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
38654         return (int64_t)ret_conv;
38655 }
38656
38657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38658         LDKTrustedCommitmentTransaction this_obj_conv;
38659         this_obj_conv.inner = (void*)(this_obj & (~1));
38660         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38662         TrustedCommitmentTransaction_free(this_obj_conv);
38663 }
38664
38665 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
38666         LDKTrustedCommitmentTransaction this_arg_conv;
38667         this_arg_conv.inner = (void*)(this_arg & (~1));
38668         this_arg_conv.is_owned = false;
38669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38670         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38671         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
38672         return ret_arr;
38673 }
38674
38675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
38676         LDKTrustedCommitmentTransaction this_arg_conv;
38677         this_arg_conv.inner = (void*)(this_arg & (~1));
38678         this_arg_conv.is_owned = false;
38679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38680         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_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 int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
38693         LDKTrustedCommitmentTransaction this_arg_conv;
38694         this_arg_conv.inner = (void*)(this_arg & (~1));
38695         this_arg_conv.is_owned = false;
38696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38697         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
38698         int64_t ret_ref = 0;
38699         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38700         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38702         ret_ref = (uintptr_t)ret_var.inner;
38703         if (ret_var.is_owned) {
38704                 ret_ref |= 1;
38705         }
38706         return ret_ref;
38707 }
38708
38709 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
38710         LDKTrustedCommitmentTransaction this_arg_conv;
38711         this_arg_conv.inner = (void*)(this_arg & (~1));
38712         this_arg_conv.is_owned = false;
38713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38714         jboolean ret_val = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
38715         return ret_val;
38716 }
38717
38718 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) {
38719         LDKTrustedCommitmentTransaction this_arg_conv;
38720         this_arg_conv.inner = (void*)(this_arg & (~1));
38721         this_arg_conv.is_owned = false;
38722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38723         unsigned char htlc_base_key_arr[32];
38724         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
38725         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
38726         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
38727         LDKDirectedChannelTransactionParameters channel_parameters_conv;
38728         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
38729         channel_parameters_conv.is_owned = false;
38730         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
38731         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
38732         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
38733         return (int64_t)ret_conv;
38734 }
38735
38736 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) {
38737         LDKPublicKey broadcaster_payment_basepoint_ref;
38738         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
38739         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
38740         LDKPublicKey countersignatory_payment_basepoint_ref;
38741         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
38742         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
38743         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
38744         return ret_val;
38745 }
38746
38747 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38748         LDKInitFeatures a_conv;
38749         a_conv.inner = (void*)(a & (~1));
38750         a_conv.is_owned = false;
38751         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38752         LDKInitFeatures b_conv;
38753         b_conv.inner = (void*)(b & (~1));
38754         b_conv.is_owned = false;
38755         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38756         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
38757         return ret_val;
38758 }
38759
38760 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38761         LDKNodeFeatures a_conv;
38762         a_conv.inner = (void*)(a & (~1));
38763         a_conv.is_owned = false;
38764         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38765         LDKNodeFeatures b_conv;
38766         b_conv.inner = (void*)(b & (~1));
38767         b_conv.is_owned = false;
38768         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38769         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
38770         return ret_val;
38771 }
38772
38773 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38774         LDKChannelFeatures a_conv;
38775         a_conv.inner = (void*)(a & (~1));
38776         a_conv.is_owned = false;
38777         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38778         LDKChannelFeatures b_conv;
38779         b_conv.inner = (void*)(b & (~1));
38780         b_conv.is_owned = false;
38781         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38782         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
38783         return ret_val;
38784 }
38785
38786 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38787         LDKInvoiceFeatures a_conv;
38788         a_conv.inner = (void*)(a & (~1));
38789         a_conv.is_owned = false;
38790         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38791         LDKInvoiceFeatures b_conv;
38792         b_conv.inner = (void*)(b & (~1));
38793         b_conv.is_owned = false;
38794         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38795         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
38796         return ret_val;
38797 }
38798
38799 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38800         LDKChannelTypeFeatures a_conv;
38801         a_conv.inner = (void*)(a & (~1));
38802         a_conv.is_owned = false;
38803         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38804         LDKChannelTypeFeatures b_conv;
38805         b_conv.inner = (void*)(b & (~1));
38806         b_conv.is_owned = false;
38807         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38808         jboolean ret_val = ChannelTypeFeatures_eq(&a_conv, &b_conv);
38809         return ret_val;
38810 }
38811
38812 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
38813         LDKInitFeatures ret_var = InitFeatures_clone(arg);
38814 int64_t ret_ref = 0;
38815 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38816 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38817 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38818 ret_ref = (uintptr_t)ret_var.inner;
38819 if (ret_var.is_owned) {
38820         ret_ref |= 1;
38821 }
38822         return ret_ref;
38823 }
38824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38825         LDKInitFeatures arg_conv;
38826         arg_conv.inner = (void*)(arg & (~1));
38827         arg_conv.is_owned = false;
38828         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38829         int64_t ret_val = InitFeatures_clone_ptr(&arg_conv);
38830         return ret_val;
38831 }
38832
38833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38834         LDKInitFeatures orig_conv;
38835         orig_conv.inner = (void*)(orig & (~1));
38836         orig_conv.is_owned = false;
38837         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38838         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
38839         int64_t ret_ref = 0;
38840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38843         ret_ref = (uintptr_t)ret_var.inner;
38844         if (ret_var.is_owned) {
38845                 ret_ref |= 1;
38846         }
38847         return ret_ref;
38848 }
38849
38850 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
38851         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
38852 int64_t ret_ref = 0;
38853 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38854 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38855 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38856 ret_ref = (uintptr_t)ret_var.inner;
38857 if (ret_var.is_owned) {
38858         ret_ref |= 1;
38859 }
38860         return ret_ref;
38861 }
38862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38863         LDKNodeFeatures arg_conv;
38864         arg_conv.inner = (void*)(arg & (~1));
38865         arg_conv.is_owned = false;
38866         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38867         int64_t ret_val = NodeFeatures_clone_ptr(&arg_conv);
38868         return ret_val;
38869 }
38870
38871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38872         LDKNodeFeatures orig_conv;
38873         orig_conv.inner = (void*)(orig & (~1));
38874         orig_conv.is_owned = false;
38875         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38876         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
38877         int64_t ret_ref = 0;
38878         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38879         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38881         ret_ref = (uintptr_t)ret_var.inner;
38882         if (ret_var.is_owned) {
38883                 ret_ref |= 1;
38884         }
38885         return ret_ref;
38886 }
38887
38888 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
38889         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
38890 int64_t ret_ref = 0;
38891 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38892 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38893 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38894 ret_ref = (uintptr_t)ret_var.inner;
38895 if (ret_var.is_owned) {
38896         ret_ref |= 1;
38897 }
38898         return ret_ref;
38899 }
38900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38901         LDKChannelFeatures arg_conv;
38902         arg_conv.inner = (void*)(arg & (~1));
38903         arg_conv.is_owned = false;
38904         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38905         int64_t ret_val = ChannelFeatures_clone_ptr(&arg_conv);
38906         return ret_val;
38907 }
38908
38909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38910         LDKChannelFeatures orig_conv;
38911         orig_conv.inner = (void*)(orig & (~1));
38912         orig_conv.is_owned = false;
38913         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38914         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
38915         int64_t ret_ref = 0;
38916         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38917         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38918         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38919         ret_ref = (uintptr_t)ret_var.inner;
38920         if (ret_var.is_owned) {
38921                 ret_ref |= 1;
38922         }
38923         return ret_ref;
38924 }
38925
38926 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
38927         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
38928 int64_t ret_ref = 0;
38929 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38930 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38931 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38932 ret_ref = (uintptr_t)ret_var.inner;
38933 if (ret_var.is_owned) {
38934         ret_ref |= 1;
38935 }
38936         return ret_ref;
38937 }
38938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38939         LDKInvoiceFeatures arg_conv;
38940         arg_conv.inner = (void*)(arg & (~1));
38941         arg_conv.is_owned = false;
38942         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38943         int64_t ret_val = InvoiceFeatures_clone_ptr(&arg_conv);
38944         return ret_val;
38945 }
38946
38947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38948         LDKInvoiceFeatures orig_conv;
38949         orig_conv.inner = (void*)(orig & (~1));
38950         orig_conv.is_owned = false;
38951         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38952         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
38953         int64_t ret_ref = 0;
38954         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38955         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38957         ret_ref = (uintptr_t)ret_var.inner;
38958         if (ret_var.is_owned) {
38959                 ret_ref |= 1;
38960         }
38961         return ret_ref;
38962 }
38963
38964 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
38965         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
38966 int64_t ret_ref = 0;
38967 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38968 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38969 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38970 ret_ref = (uintptr_t)ret_var.inner;
38971 if (ret_var.is_owned) {
38972         ret_ref |= 1;
38973 }
38974         return ret_ref;
38975 }
38976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38977         LDKChannelTypeFeatures arg_conv;
38978         arg_conv.inner = (void*)(arg & (~1));
38979         arg_conv.is_owned = false;
38980         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38981         int64_t ret_val = ChannelTypeFeatures_clone_ptr(&arg_conv);
38982         return ret_val;
38983 }
38984
38985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38986         LDKChannelTypeFeatures orig_conv;
38987         orig_conv.inner = (void*)(orig & (~1));
38988         orig_conv.is_owned = false;
38989         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38990         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
38991         int64_t ret_ref = 0;
38992         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38993         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38994         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38995         ret_ref = (uintptr_t)ret_var.inner;
38996         if (ret_var.is_owned) {
38997                 ret_ref |= 1;
38998         }
38999         return ret_ref;
39000 }
39001
39002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39003         LDKInitFeatures this_obj_conv;
39004         this_obj_conv.inner = (void*)(this_obj & (~1));
39005         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39007         InitFeatures_free(this_obj_conv);
39008 }
39009
39010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39011         LDKNodeFeatures this_obj_conv;
39012         this_obj_conv.inner = (void*)(this_obj & (~1));
39013         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39015         NodeFeatures_free(this_obj_conv);
39016 }
39017
39018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39019         LDKChannelFeatures this_obj_conv;
39020         this_obj_conv.inner = (void*)(this_obj & (~1));
39021         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39023         ChannelFeatures_free(this_obj_conv);
39024 }
39025
39026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39027         LDKInvoiceFeatures this_obj_conv;
39028         this_obj_conv.inner = (void*)(this_obj & (~1));
39029         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39031         InvoiceFeatures_free(this_obj_conv);
39032 }
39033
39034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39035         LDKChannelTypeFeatures this_obj_conv;
39036         this_obj_conv.inner = (void*)(this_obj & (~1));
39037         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39039         ChannelTypeFeatures_free(this_obj_conv);
39040 }
39041
39042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
39043         LDKInitFeatures ret_var = InitFeatures_empty();
39044         int64_t ret_ref = 0;
39045         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39046         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39048         ret_ref = (uintptr_t)ret_var.inner;
39049         if (ret_var.is_owned) {
39050                 ret_ref |= 1;
39051         }
39052         return ret_ref;
39053 }
39054
39055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
39056         LDKInitFeatures ret_var = InitFeatures_known();
39057         int64_t ret_ref = 0;
39058         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39059         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39060         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39061         ret_ref = (uintptr_t)ret_var.inner;
39062         if (ret_var.is_owned) {
39063                 ret_ref |= 1;
39064         }
39065         return ret_ref;
39066 }
39067
39068 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39069         LDKInitFeatures this_arg_conv;
39070         this_arg_conv.inner = (void*)(this_arg & (~1));
39071         this_arg_conv.is_owned = false;
39072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39073         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
39074         return ret_val;
39075 }
39076
39077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
39078         LDKNodeFeatures ret_var = NodeFeatures_empty();
39079         int64_t ret_ref = 0;
39080         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39081         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39083         ret_ref = (uintptr_t)ret_var.inner;
39084         if (ret_var.is_owned) {
39085                 ret_ref |= 1;
39086         }
39087         return ret_ref;
39088 }
39089
39090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
39091         LDKNodeFeatures ret_var = NodeFeatures_known();
39092         int64_t ret_ref = 0;
39093         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39094         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39096         ret_ref = (uintptr_t)ret_var.inner;
39097         if (ret_var.is_owned) {
39098                 ret_ref |= 1;
39099         }
39100         return ret_ref;
39101 }
39102
39103 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39104         LDKNodeFeatures this_arg_conv;
39105         this_arg_conv.inner = (void*)(this_arg & (~1));
39106         this_arg_conv.is_owned = false;
39107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39108         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
39109         return ret_val;
39110 }
39111
39112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
39113         LDKChannelFeatures ret_var = ChannelFeatures_empty();
39114         int64_t ret_ref = 0;
39115         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39116         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39118         ret_ref = (uintptr_t)ret_var.inner;
39119         if (ret_var.is_owned) {
39120                 ret_ref |= 1;
39121         }
39122         return ret_ref;
39123 }
39124
39125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
39126         LDKChannelFeatures ret_var = ChannelFeatures_known();
39127         int64_t ret_ref = 0;
39128         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39129         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39131         ret_ref = (uintptr_t)ret_var.inner;
39132         if (ret_var.is_owned) {
39133                 ret_ref |= 1;
39134         }
39135         return ret_ref;
39136 }
39137
39138 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39139         LDKChannelFeatures this_arg_conv;
39140         this_arg_conv.inner = (void*)(this_arg & (~1));
39141         this_arg_conv.is_owned = false;
39142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39143         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
39144         return ret_val;
39145 }
39146
39147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
39148         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
39149         int64_t ret_ref = 0;
39150         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39151         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39153         ret_ref = (uintptr_t)ret_var.inner;
39154         if (ret_var.is_owned) {
39155                 ret_ref |= 1;
39156         }
39157         return ret_ref;
39158 }
39159
39160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
39161         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
39162         int64_t ret_ref = 0;
39163         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39164         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39166         ret_ref = (uintptr_t)ret_var.inner;
39167         if (ret_var.is_owned) {
39168                 ret_ref |= 1;
39169         }
39170         return ret_ref;
39171 }
39172
39173 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39174         LDKInvoiceFeatures this_arg_conv;
39175         this_arg_conv.inner = (void*)(this_arg & (~1));
39176         this_arg_conv.is_owned = false;
39177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39178         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
39179         return ret_val;
39180 }
39181
39182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
39183         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
39184         int64_t ret_ref = 0;
39185         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39186         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39188         ret_ref = (uintptr_t)ret_var.inner;
39189         if (ret_var.is_owned) {
39190                 ret_ref |= 1;
39191         }
39192         return ret_ref;
39193 }
39194
39195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1known(JNIEnv *env, jclass clz) {
39196         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
39197         int64_t ret_ref = 0;
39198         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39199         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39201         ret_ref = (uintptr_t)ret_var.inner;
39202         if (ret_var.is_owned) {
39203                 ret_ref |= 1;
39204         }
39205         return ret_ref;
39206 }
39207
39208 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39209         LDKChannelTypeFeatures this_arg_conv;
39210         this_arg_conv.inner = (void*)(this_arg & (~1));
39211         this_arg_conv.is_owned = false;
39212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39213         jboolean ret_val = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
39214         return ret_val;
39215 }
39216
39217 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39218         LDKInitFeatures obj_conv;
39219         obj_conv.inner = (void*)(obj & (~1));
39220         obj_conv.is_owned = false;
39221         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39222         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
39223         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39224         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39225         CVec_u8Z_free(ret_var);
39226         return ret_arr;
39227 }
39228
39229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39230         LDKu8slice ser_ref;
39231         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39232         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39233         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
39234         *ret_conv = InitFeatures_read(ser_ref);
39235         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39236         return (int64_t)ret_conv;
39237 }
39238
39239 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39240         LDKChannelFeatures obj_conv;
39241         obj_conv.inner = (void*)(obj & (~1));
39242         obj_conv.is_owned = false;
39243         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39244         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
39245         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39246         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39247         CVec_u8Z_free(ret_var);
39248         return ret_arr;
39249 }
39250
39251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39252         LDKu8slice ser_ref;
39253         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39254         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39255         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
39256         *ret_conv = ChannelFeatures_read(ser_ref);
39257         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39258         return (int64_t)ret_conv;
39259 }
39260
39261 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39262         LDKNodeFeatures obj_conv;
39263         obj_conv.inner = (void*)(obj & (~1));
39264         obj_conv.is_owned = false;
39265         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39266         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
39267         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39268         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39269         CVec_u8Z_free(ret_var);
39270         return ret_arr;
39271 }
39272
39273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39274         LDKu8slice ser_ref;
39275         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39276         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39277         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
39278         *ret_conv = NodeFeatures_read(ser_ref);
39279         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39280         return (int64_t)ret_conv;
39281 }
39282
39283 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39284         LDKInvoiceFeatures obj_conv;
39285         obj_conv.inner = (void*)(obj & (~1));
39286         obj_conv.is_owned = false;
39287         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39288         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
39289         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39290         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39291         CVec_u8Z_free(ret_var);
39292         return ret_arr;
39293 }
39294
39295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39296         LDKu8slice ser_ref;
39297         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39298         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39299         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
39300         *ret_conv = InvoiceFeatures_read(ser_ref);
39301         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39302         return (int64_t)ret_conv;
39303 }
39304
39305 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39306         LDKChannelTypeFeatures obj_conv;
39307         obj_conv.inner = (void*)(obj & (~1));
39308         obj_conv.is_owned = false;
39309         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39310         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
39311         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39312         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39313         CVec_u8Z_free(ret_var);
39314         return ret_arr;
39315 }
39316
39317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39318         LDKu8slice ser_ref;
39319         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39320         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39321         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
39322         *ret_conv = ChannelTypeFeatures_read(ser_ref);
39323         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39324         return (int64_t)ret_conv;
39325 }
39326
39327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39328         LDKShutdownScript this_obj_conv;
39329         this_obj_conv.inner = (void*)(this_obj & (~1));
39330         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39332         ShutdownScript_free(this_obj_conv);
39333 }
39334
39335 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
39336         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
39337 int64_t ret_ref = 0;
39338 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39339 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39340 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39341 ret_ref = (uintptr_t)ret_var.inner;
39342 if (ret_var.is_owned) {
39343         ret_ref |= 1;
39344 }
39345         return ret_ref;
39346 }
39347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39348         LDKShutdownScript arg_conv;
39349         arg_conv.inner = (void*)(arg & (~1));
39350         arg_conv.is_owned = false;
39351         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39352         int64_t ret_val = ShutdownScript_clone_ptr(&arg_conv);
39353         return ret_val;
39354 }
39355
39356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39357         LDKShutdownScript orig_conv;
39358         orig_conv.inner = (void*)(orig & (~1));
39359         orig_conv.is_owned = false;
39360         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39361         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
39362         int64_t ret_ref = 0;
39363         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39364         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39366         ret_ref = (uintptr_t)ret_var.inner;
39367         if (ret_var.is_owned) {
39368                 ret_ref |= 1;
39369         }
39370         return ret_ref;
39371 }
39372
39373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39374         LDKInvalidShutdownScript this_obj_conv;
39375         this_obj_conv.inner = (void*)(this_obj & (~1));
39376         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39378         InvalidShutdownScript_free(this_obj_conv);
39379 }
39380
39381 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
39382         LDKInvalidShutdownScript this_ptr_conv;
39383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39384         this_ptr_conv.is_owned = false;
39385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39386         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
39387         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39388         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39389         return ret_arr;
39390 }
39391
39392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39393         LDKInvalidShutdownScript this_ptr_conv;
39394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39395         this_ptr_conv.is_owned = false;
39396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39397         LDKCVec_u8Z val_ref;
39398         val_ref.datalen = (*env)->GetArrayLength(env, val);
39399         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
39400         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
39401         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
39402 }
39403
39404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
39405         LDKCVec_u8Z script_arg_ref;
39406         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
39407         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
39408         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
39409         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
39410         int64_t ret_ref = 0;
39411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39414         ret_ref = (uintptr_t)ret_var.inner;
39415         if (ret_var.is_owned) {
39416                 ret_ref |= 1;
39417         }
39418         return ret_ref;
39419 }
39420
39421 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
39422         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
39423 int64_t ret_ref = 0;
39424 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39425 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39426 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39427 ret_ref = (uintptr_t)ret_var.inner;
39428 if (ret_var.is_owned) {
39429         ret_ref |= 1;
39430 }
39431         return ret_ref;
39432 }
39433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39434         LDKInvalidShutdownScript arg_conv;
39435         arg_conv.inner = (void*)(arg & (~1));
39436         arg_conv.is_owned = false;
39437         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39438         int64_t ret_val = InvalidShutdownScript_clone_ptr(&arg_conv);
39439         return ret_val;
39440 }
39441
39442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39443         LDKInvalidShutdownScript orig_conv;
39444         orig_conv.inner = (void*)(orig & (~1));
39445         orig_conv.is_owned = false;
39446         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39447         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
39448         int64_t ret_ref = 0;
39449         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39450         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39452         ret_ref = (uintptr_t)ret_var.inner;
39453         if (ret_var.is_owned) {
39454                 ret_ref |= 1;
39455         }
39456         return ret_ref;
39457 }
39458
39459 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
39460         LDKShutdownScript obj_conv;
39461         obj_conv.inner = (void*)(obj & (~1));
39462         obj_conv.is_owned = false;
39463         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39464         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
39465         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39466         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39467         CVec_u8Z_free(ret_var);
39468         return ret_arr;
39469 }
39470
39471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39472         LDKu8slice ser_ref;
39473         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39474         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39475         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
39476         *ret_conv = ShutdownScript_read(ser_ref);
39477         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39478         return (int64_t)ret_conv;
39479 }
39480
39481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
39482         unsigned char pubkey_hash_arr[20];
39483         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
39484         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
39485         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
39486         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
39487         int64_t ret_ref = 0;
39488         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39489         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39491         ret_ref = (uintptr_t)ret_var.inner;
39492         if (ret_var.is_owned) {
39493                 ret_ref |= 1;
39494         }
39495         return ret_ref;
39496 }
39497
39498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
39499         unsigned char script_hash_arr[32];
39500         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
39501         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
39502         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
39503         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
39504         int64_t ret_ref = 0;
39505         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39506         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39508         ret_ref = (uintptr_t)ret_var.inner;
39509         if (ret_var.is_owned) {
39510                 ret_ref |= 1;
39511         }
39512         return ret_ref;
39513 }
39514
39515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
39516         LDKu8slice program_ref;
39517         program_ref.datalen = (*env)->GetArrayLength(env, program);
39518         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
39519         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
39520         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
39521         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
39522         return (int64_t)ret_conv;
39523 }
39524
39525 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
39526         LDKShutdownScript this_arg_conv;
39527         this_arg_conv.inner = (void*)(this_arg & (~1));
39528         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
39529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39530         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
39531         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
39532         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39533         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39534         CVec_u8Z_free(ret_var);
39535         return ret_arr;
39536 }
39537
39538 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
39539         LDKShutdownScript this_arg_conv;
39540         this_arg_conv.inner = (void*)(this_arg & (~1));
39541         this_arg_conv.is_owned = false;
39542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39543         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39544         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
39545         return ret_arr;
39546 }
39547
39548 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
39549         LDKShutdownScript this_arg_conv;
39550         this_arg_conv.inner = (void*)(this_arg & (~1));
39551         this_arg_conv.is_owned = false;
39552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39553         LDKInitFeatures features_conv;
39554         features_conv.inner = (void*)(features & (~1));
39555         features_conv.is_owned = false;
39556         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
39557         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
39558         return ret_val;
39559 }
39560
39561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39562         if ((this_ptr & 1) != 0) return;
39563         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39564         CHECK_ACCESS(this_ptr_ptr);
39565         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
39566         FREE((void*)this_ptr);
39567         CustomMessageReader_free(this_ptr_conv);
39568 }
39569
39570 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
39571         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
39572         *ret_ret = Type_clone(arg);
39573         return (int64_t)ret_ret;
39574 }
39575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39576         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
39577         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
39578         LDKType* arg_conv = (LDKType*)arg_ptr;
39579         int64_t ret_val = Type_clone_ptr(arg_conv);
39580         return ret_val;
39581 }
39582
39583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39584         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
39585         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
39586         LDKType* orig_conv = (LDKType*)orig_ptr;
39587         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
39588         *ret_ret = Type_clone(orig_conv);
39589         return (int64_t)ret_ret;
39590 }
39591
39592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39593         if ((this_ptr & 1) != 0) return;
39594         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39595         CHECK_ACCESS(this_ptr_ptr);
39596         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
39597         FREE((void*)this_ptr);
39598         Type_free(this_ptr_conv);
39599 }
39600
39601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39602         LDKNodeId this_obj_conv;
39603         this_obj_conv.inner = (void*)(this_obj & (~1));
39604         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39606         NodeId_free(this_obj_conv);
39607 }
39608
39609 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
39610         LDKNodeId ret_var = NodeId_clone(arg);
39611 int64_t ret_ref = 0;
39612 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39613 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39614 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39615 ret_ref = (uintptr_t)ret_var.inner;
39616 if (ret_var.is_owned) {
39617         ret_ref |= 1;
39618 }
39619         return ret_ref;
39620 }
39621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39622         LDKNodeId arg_conv;
39623         arg_conv.inner = (void*)(arg & (~1));
39624         arg_conv.is_owned = false;
39625         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39626         int64_t ret_val = NodeId_clone_ptr(&arg_conv);
39627         return ret_val;
39628 }
39629
39630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39631         LDKNodeId orig_conv;
39632         orig_conv.inner = (void*)(orig & (~1));
39633         orig_conv.is_owned = false;
39634         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39635         LDKNodeId ret_var = NodeId_clone(&orig_conv);
39636         int64_t ret_ref = 0;
39637         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39638         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39640         ret_ref = (uintptr_t)ret_var.inner;
39641         if (ret_var.is_owned) {
39642                 ret_ref |= 1;
39643         }
39644         return ret_ref;
39645 }
39646
39647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
39648         LDKPublicKey pubkey_ref;
39649         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
39650         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
39651         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
39652         int64_t ret_ref = 0;
39653         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39654         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39656         ret_ref = (uintptr_t)ret_var.inner;
39657         if (ret_var.is_owned) {
39658                 ret_ref |= 1;
39659         }
39660         return ret_ref;
39661 }
39662
39663 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
39664         LDKNodeId this_arg_conv;
39665         this_arg_conv.inner = (void*)(this_arg & (~1));
39666         this_arg_conv.is_owned = false;
39667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39668         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
39669         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39670         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39671         return ret_arr;
39672 }
39673
39674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
39675         LDKNodeId o_conv;
39676         o_conv.inner = (void*)(o & (~1));
39677         o_conv.is_owned = false;
39678         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39679         int64_t ret_val = NodeId_hash(&o_conv);
39680         return ret_val;
39681 }
39682
39683 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
39684         LDKNodeId obj_conv;
39685         obj_conv.inner = (void*)(obj & (~1));
39686         obj_conv.is_owned = false;
39687         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39688         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
39689         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39690         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39691         CVec_u8Z_free(ret_var);
39692         return ret_arr;
39693 }
39694
39695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39696         LDKu8slice ser_ref;
39697         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39698         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39699         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
39700         *ret_conv = NodeId_read(ser_ref);
39701         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39702         return (int64_t)ret_conv;
39703 }
39704
39705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39706         LDKNetworkGraph this_obj_conv;
39707         this_obj_conv.inner = (void*)(this_obj & (~1));
39708         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39710         NetworkGraph_free(this_obj_conv);
39711 }
39712
39713 static inline uintptr_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
39714         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
39715 int64_t ret_ref = 0;
39716 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39717 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39718 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39719 ret_ref = (uintptr_t)ret_var.inner;
39720 if (ret_var.is_owned) {
39721         ret_ref |= 1;
39722 }
39723         return ret_ref;
39724 }
39725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39726         LDKNetworkGraph arg_conv;
39727         arg_conv.inner = (void*)(arg & (~1));
39728         arg_conv.is_owned = false;
39729         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39730         int64_t ret_val = NetworkGraph_clone_ptr(&arg_conv);
39731         return ret_val;
39732 }
39733
39734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39735         LDKNetworkGraph orig_conv;
39736         orig_conv.inner = (void*)(orig & (~1));
39737         orig_conv.is_owned = false;
39738         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39739         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
39740         int64_t ret_ref = 0;
39741         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39742         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39744         ret_ref = (uintptr_t)ret_var.inner;
39745         if (ret_var.is_owned) {
39746                 ret_ref |= 1;
39747         }
39748         return ret_ref;
39749 }
39750
39751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39752         LDKReadOnlyNetworkGraph this_obj_conv;
39753         this_obj_conv.inner = (void*)(this_obj & (~1));
39754         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39756         ReadOnlyNetworkGraph_free(this_obj_conv);
39757 }
39758
39759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39760         if ((this_ptr & 1) != 0) return;
39761         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39762         CHECK_ACCESS(this_ptr_ptr);
39763         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
39764         FREE((void*)this_ptr);
39765         NetworkUpdate_free(this_ptr_conv);
39766 }
39767
39768 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
39769         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39770         *ret_copy = NetworkUpdate_clone(arg);
39771 int64_t ret_ref = (uintptr_t)ret_copy;
39772         return ret_ref;
39773 }
39774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39775         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
39776         int64_t ret_val = NetworkUpdate_clone_ptr(arg_conv);
39777         return ret_val;
39778 }
39779
39780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39781         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
39782         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39783         *ret_copy = NetworkUpdate_clone(orig_conv);
39784         int64_t ret_ref = (uintptr_t)ret_copy;
39785         return ret_ref;
39786 }
39787
39788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
39789         LDKChannelUpdate msg_conv;
39790         msg_conv.inner = (void*)(msg & (~1));
39791         msg_conv.is_owned = (msg & 1) || (msg == 0);
39792         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39793         msg_conv = ChannelUpdate_clone(&msg_conv);
39794         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39795         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
39796         int64_t ret_ref = (uintptr_t)ret_copy;
39797         return ret_ref;
39798 }
39799
39800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
39801         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39802         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
39803         int64_t ret_ref = (uintptr_t)ret_copy;
39804         return ret_ref;
39805 }
39806
39807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
39808         LDKPublicKey node_id_ref;
39809         CHECK((*env)->GetArrayLength(env, node_id) == 33);
39810         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
39811         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39812         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
39813         int64_t ret_ref = (uintptr_t)ret_copy;
39814         return ret_ref;
39815 }
39816
39817 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
39818         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
39819         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
39820         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39821         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39822         CVec_u8Z_free(ret_var);
39823         return ret_arr;
39824 }
39825
39826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39827         LDKu8slice ser_ref;
39828         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39829         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39830         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
39831         *ret_conv = NetworkUpdate_read(ser_ref);
39832         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39833         return (int64_t)ret_conv;
39834 }
39835
39836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39837         LDKNetGraphMsgHandler this_arg_conv;
39838         this_arg_conv.inner = (void*)(this_arg & (~1));
39839         this_arg_conv.is_owned = false;
39840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39841         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
39842         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
39843         return (int64_t)ret_ret;
39844 }
39845
39846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39847         LDKNetGraphMsgHandler this_obj_conv;
39848         this_obj_conv.inner = (void*)(this_obj & (~1));
39849         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39851         NetGraphMsgHandler_free(this_obj_conv);
39852 }
39853
39854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t chain_access, int64_t logger) {
39855         LDKNetworkGraph network_graph_conv;
39856         network_graph_conv.inner = (void*)(network_graph & (~1));
39857         network_graph_conv.is_owned = false;
39858         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
39859         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39860         CHECK_ACCESS(chain_access_ptr);
39861         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39862         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39863         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39864                 // Manually implement clone for Java trait instances
39865                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39866                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39867                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39868                 }
39869         }
39870         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
39871         CHECK_ACCESS(logger_ptr);
39872         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
39873         if (logger_conv.free == LDKLogger_JCalls_free) {
39874                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39875                 LDKLogger_JCalls_cloned(&logger_conv);
39876         }
39877         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
39878         int64_t ret_ref = 0;
39879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39882         ret_ref = (uintptr_t)ret_var.inner;
39883         if (ret_var.is_owned) {
39884                 ret_ref |= 1;
39885         }
39886         return ret_ref;
39887 }
39888
39889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
39890         LDKNetGraphMsgHandler this_arg_conv;
39891         this_arg_conv.inner = (void*)(this_arg & (~1));
39892         this_arg_conv.is_owned = false;
39893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39894         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39895         CHECK_ACCESS(chain_access_ptr);
39896         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39897         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39898         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39899                 // Manually implement clone for Java trait instances
39900                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39901                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39902                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39903                 }
39904         }
39905         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
39906 }
39907
39908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39909         LDKNetGraphMsgHandler 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         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
39914         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
39915         return (int64_t)ret_ret;
39916 }
39917
39918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
39919         LDKNetGraphMsgHandler this_arg_conv;
39920         this_arg_conv.inner = (void*)(this_arg & (~1));
39921         this_arg_conv.is_owned = false;
39922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39923         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
39924         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
39925         return (int64_t)ret_ret;
39926 }
39927
39928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39929         LDKChannelUpdateInfo this_obj_conv;
39930         this_obj_conv.inner = (void*)(this_obj & (~1));
39931         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39933         ChannelUpdateInfo_free(this_obj_conv);
39934 }
39935
39936 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
39937         LDKChannelUpdateInfo this_ptr_conv;
39938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39939         this_ptr_conv.is_owned = false;
39940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39941         int32_t ret_val = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
39942         return ret_val;
39943 }
39944
39945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39946         LDKChannelUpdateInfo this_ptr_conv;
39947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39948         this_ptr_conv.is_owned = false;
39949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39950         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
39951 }
39952
39953 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
39954         LDKChannelUpdateInfo this_ptr_conv;
39955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39956         this_ptr_conv.is_owned = false;
39957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39958         jboolean ret_val = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
39959         return ret_val;
39960 }
39961
39962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39963         LDKChannelUpdateInfo this_ptr_conv;
39964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39965         this_ptr_conv.is_owned = false;
39966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39967         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
39968 }
39969
39970 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
39971         LDKChannelUpdateInfo this_ptr_conv;
39972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39973         this_ptr_conv.is_owned = false;
39974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39975         int16_t ret_val = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
39976         return ret_val;
39977 }
39978
39979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
39980         LDKChannelUpdateInfo this_ptr_conv;
39981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39982         this_ptr_conv.is_owned = false;
39983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39984         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
39985 }
39986
39987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39988         LDKChannelUpdateInfo this_ptr_conv;
39989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39990         this_ptr_conv.is_owned = false;
39991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39992         int64_t ret_val = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
39993         return ret_val;
39994 }
39995
39996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39997         LDKChannelUpdateInfo this_ptr_conv;
39998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39999         this_ptr_conv.is_owned = false;
40000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40001         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
40002 }
40003
40004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
40005         LDKChannelUpdateInfo this_ptr_conv;
40006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40007         this_ptr_conv.is_owned = false;
40008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40009         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40010         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
40011         int64_t ret_ref = (uintptr_t)ret_copy;
40012         return ret_ref;
40013 }
40014
40015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40016         LDKChannelUpdateInfo this_ptr_conv;
40017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40018         this_ptr_conv.is_owned = false;
40019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40020         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
40021         CHECK_ACCESS(val_ptr);
40022         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
40023         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
40024         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
40025 }
40026
40027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
40028         LDKChannelUpdateInfo this_ptr_conv;
40029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40030         this_ptr_conv.is_owned = false;
40031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40032         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
40033         int64_t ret_ref = 0;
40034         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40035         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40037         ret_ref = (uintptr_t)ret_var.inner;
40038         if (ret_var.is_owned) {
40039                 ret_ref |= 1;
40040         }
40041         return ret_ref;
40042 }
40043
40044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40045         LDKChannelUpdateInfo this_ptr_conv;
40046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40047         this_ptr_conv.is_owned = false;
40048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40049         LDKRoutingFees val_conv;
40050         val_conv.inner = (void*)(val & (~1));
40051         val_conv.is_owned = (val & 1) || (val == 0);
40052         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40053         val_conv = RoutingFees_clone(&val_conv);
40054         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
40055 }
40056
40057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
40058         LDKChannelUpdateInfo this_ptr_conv;
40059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40060         this_ptr_conv.is_owned = false;
40061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40062         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
40063         int64_t ret_ref = 0;
40064         if ((uintptr_t)ret_var.inner > 4096) {
40065                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40066                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40068                 ret_ref = (uintptr_t)ret_var.inner;
40069                 if (ret_var.is_owned) {
40070                         ret_ref |= 1;
40071                 }
40072         }
40073         return ret_ref;
40074 }
40075
40076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40077         LDKChannelUpdateInfo this_ptr_conv;
40078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40079         this_ptr_conv.is_owned = false;
40080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40081         LDKChannelUpdate val_conv;
40082         val_conv.inner = (void*)(val & (~1));
40083         val_conv.is_owned = (val & 1) || (val == 0);
40084         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40085         val_conv = ChannelUpdate_clone(&val_conv);
40086         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
40087 }
40088
40089 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) {
40090         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
40091         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
40092         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
40093         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
40094         LDKRoutingFees fees_arg_conv;
40095         fees_arg_conv.inner = (void*)(fees_arg & (~1));
40096         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
40097         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
40098         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
40099         LDKChannelUpdate last_update_message_arg_conv;
40100         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
40101         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
40102         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
40103         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
40104         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);
40105         int64_t ret_ref = 0;
40106         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40107         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40109         ret_ref = (uintptr_t)ret_var.inner;
40110         if (ret_var.is_owned) {
40111                 ret_ref |= 1;
40112         }
40113         return ret_ref;
40114 }
40115
40116 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
40117         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
40118 int64_t ret_ref = 0;
40119 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40120 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40121 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40122 ret_ref = (uintptr_t)ret_var.inner;
40123 if (ret_var.is_owned) {
40124         ret_ref |= 1;
40125 }
40126         return ret_ref;
40127 }
40128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40129         LDKChannelUpdateInfo arg_conv;
40130         arg_conv.inner = (void*)(arg & (~1));
40131         arg_conv.is_owned = false;
40132         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40133         int64_t ret_val = ChannelUpdateInfo_clone_ptr(&arg_conv);
40134         return ret_val;
40135 }
40136
40137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40138         LDKChannelUpdateInfo orig_conv;
40139         orig_conv.inner = (void*)(orig & (~1));
40140         orig_conv.is_owned = false;
40141         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40142         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
40143         int64_t ret_ref = 0;
40144         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40145         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40147         ret_ref = (uintptr_t)ret_var.inner;
40148         if (ret_var.is_owned) {
40149                 ret_ref |= 1;
40150         }
40151         return ret_ref;
40152 }
40153
40154 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
40155         LDKChannelUpdateInfo obj_conv;
40156         obj_conv.inner = (void*)(obj & (~1));
40157         obj_conv.is_owned = false;
40158         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40159         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
40160         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40161         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40162         CVec_u8Z_free(ret_var);
40163         return ret_arr;
40164 }
40165
40166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40167         LDKu8slice ser_ref;
40168         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40169         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40170         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
40171         *ret_conv = ChannelUpdateInfo_read(ser_ref);
40172         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40173         return (int64_t)ret_conv;
40174 }
40175
40176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40177         LDKChannelInfo this_obj_conv;
40178         this_obj_conv.inner = (void*)(this_obj & (~1));
40179         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40181         ChannelInfo_free(this_obj_conv);
40182 }
40183
40184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
40185         LDKChannelInfo this_ptr_conv;
40186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40187         this_ptr_conv.is_owned = false;
40188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40189         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
40190         int64_t ret_ref = 0;
40191         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40192         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40194         ret_ref = (uintptr_t)ret_var.inner;
40195         if (ret_var.is_owned) {
40196                 ret_ref |= 1;
40197         }
40198         return ret_ref;
40199 }
40200
40201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40202         LDKChannelInfo this_ptr_conv;
40203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40204         this_ptr_conv.is_owned = false;
40205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40206         LDKChannelFeatures val_conv;
40207         val_conv.inner = (void*)(val & (~1));
40208         val_conv.is_owned = (val & 1) || (val == 0);
40209         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40210         val_conv = ChannelFeatures_clone(&val_conv);
40211         ChannelInfo_set_features(&this_ptr_conv, val_conv);
40212 }
40213
40214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
40215         LDKChannelInfo this_ptr_conv;
40216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40217         this_ptr_conv.is_owned = false;
40218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40219         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
40220         int64_t ret_ref = 0;
40221         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40222         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40224         ret_ref = (uintptr_t)ret_var.inner;
40225         if (ret_var.is_owned) {
40226                 ret_ref |= 1;
40227         }
40228         return ret_ref;
40229 }
40230
40231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40232         LDKChannelInfo this_ptr_conv;
40233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40234         this_ptr_conv.is_owned = false;
40235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40236         LDKNodeId val_conv;
40237         val_conv.inner = (void*)(val & (~1));
40238         val_conv.is_owned = (val & 1) || (val == 0);
40239         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40240         val_conv = NodeId_clone(&val_conv);
40241         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
40242 }
40243
40244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
40245         LDKChannelInfo this_ptr_conv;
40246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40247         this_ptr_conv.is_owned = false;
40248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40249         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
40250         int64_t ret_ref = 0;
40251         if ((uintptr_t)ret_var.inner > 4096) {
40252                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40253                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40255                 ret_ref = (uintptr_t)ret_var.inner;
40256                 if (ret_var.is_owned) {
40257                         ret_ref |= 1;
40258                 }
40259         }
40260         return ret_ref;
40261 }
40262
40263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40264         LDKChannelInfo this_ptr_conv;
40265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40266         this_ptr_conv.is_owned = false;
40267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40268         LDKChannelUpdateInfo val_conv;
40269         val_conv.inner = (void*)(val & (~1));
40270         val_conv.is_owned = (val & 1) || (val == 0);
40271         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40272         val_conv = ChannelUpdateInfo_clone(&val_conv);
40273         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
40274 }
40275
40276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
40277         LDKChannelInfo this_ptr_conv;
40278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40279         this_ptr_conv.is_owned = false;
40280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40281         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
40282         int64_t ret_ref = 0;
40283         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40284         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40286         ret_ref = (uintptr_t)ret_var.inner;
40287         if (ret_var.is_owned) {
40288                 ret_ref |= 1;
40289         }
40290         return ret_ref;
40291 }
40292
40293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40294         LDKChannelInfo this_ptr_conv;
40295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40296         this_ptr_conv.is_owned = false;
40297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40298         LDKNodeId val_conv;
40299         val_conv.inner = (void*)(val & (~1));
40300         val_conv.is_owned = (val & 1) || (val == 0);
40301         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40302         val_conv = NodeId_clone(&val_conv);
40303         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
40304 }
40305
40306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
40307         LDKChannelInfo this_ptr_conv;
40308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40309         this_ptr_conv.is_owned = false;
40310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40311         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
40312         int64_t ret_ref = 0;
40313         if ((uintptr_t)ret_var.inner > 4096) {
40314                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40315                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40317                 ret_ref = (uintptr_t)ret_var.inner;
40318                 if (ret_var.is_owned) {
40319                         ret_ref |= 1;
40320                 }
40321         }
40322         return ret_ref;
40323 }
40324
40325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40326         LDKChannelInfo this_ptr_conv;
40327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40328         this_ptr_conv.is_owned = false;
40329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40330         LDKChannelUpdateInfo val_conv;
40331         val_conv.inner = (void*)(val & (~1));
40332         val_conv.is_owned = (val & 1) || (val == 0);
40333         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40334         val_conv = ChannelUpdateInfo_clone(&val_conv);
40335         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
40336 }
40337
40338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
40339         LDKChannelInfo this_ptr_conv;
40340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40341         this_ptr_conv.is_owned = false;
40342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40343         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40344         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
40345         int64_t ret_ref = (uintptr_t)ret_copy;
40346         return ret_ref;
40347 }
40348
40349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40350         LDKChannelInfo this_ptr_conv;
40351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40352         this_ptr_conv.is_owned = false;
40353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40354         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
40355         CHECK_ACCESS(val_ptr);
40356         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
40357         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
40358         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
40359 }
40360
40361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
40362         LDKChannelInfo this_ptr_conv;
40363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40364         this_ptr_conv.is_owned = false;
40365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40366         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
40367         int64_t ret_ref = 0;
40368         if ((uintptr_t)ret_var.inner > 4096) {
40369                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40370                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40372                 ret_ref = (uintptr_t)ret_var.inner;
40373                 if (ret_var.is_owned) {
40374                         ret_ref |= 1;
40375                 }
40376         }
40377         return ret_ref;
40378 }
40379
40380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40381         LDKChannelInfo this_ptr_conv;
40382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40383         this_ptr_conv.is_owned = false;
40384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40385         LDKChannelAnnouncement val_conv;
40386         val_conv.inner = (void*)(val & (~1));
40387         val_conv.is_owned = (val & 1) || (val == 0);
40388         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40389         val_conv = ChannelAnnouncement_clone(&val_conv);
40390         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
40391 }
40392
40393 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
40394         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
40395 int64_t ret_ref = 0;
40396 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40397 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40398 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40399 ret_ref = (uintptr_t)ret_var.inner;
40400 if (ret_var.is_owned) {
40401         ret_ref |= 1;
40402 }
40403         return ret_ref;
40404 }
40405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40406         LDKChannelInfo arg_conv;
40407         arg_conv.inner = (void*)(arg & (~1));
40408         arg_conv.is_owned = false;
40409         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40410         int64_t ret_val = ChannelInfo_clone_ptr(&arg_conv);
40411         return ret_val;
40412 }
40413
40414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40415         LDKChannelInfo orig_conv;
40416         orig_conv.inner = (void*)(orig & (~1));
40417         orig_conv.is_owned = false;
40418         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40419         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
40420         int64_t ret_ref = 0;
40421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40424         ret_ref = (uintptr_t)ret_var.inner;
40425         if (ret_var.is_owned) {
40426                 ret_ref |= 1;
40427         }
40428         return ret_ref;
40429 }
40430
40431 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
40432         LDKChannelInfo obj_conv;
40433         obj_conv.inner = (void*)(obj & (~1));
40434         obj_conv.is_owned = false;
40435         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40436         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
40437         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40438         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40439         CVec_u8Z_free(ret_var);
40440         return ret_arr;
40441 }
40442
40443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40444         LDKu8slice ser_ref;
40445         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40446         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40447         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
40448         *ret_conv = ChannelInfo_read(ser_ref);
40449         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40450         return (int64_t)ret_conv;
40451 }
40452
40453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40454         LDKDirectedChannelInfo this_obj_conv;
40455         this_obj_conv.inner = (void*)(this_obj & (~1));
40456         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40458         DirectedChannelInfo_free(this_obj_conv);
40459 }
40460
40461 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
40462         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
40463 int64_t ret_ref = 0;
40464 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40465 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40466 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40467 ret_ref = (uintptr_t)ret_var.inner;
40468 if (ret_var.is_owned) {
40469         ret_ref |= 1;
40470 }
40471         return ret_ref;
40472 }
40473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40474         LDKDirectedChannelInfo arg_conv;
40475         arg_conv.inner = (void*)(arg & (~1));
40476         arg_conv.is_owned = false;
40477         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40478         int64_t ret_val = DirectedChannelInfo_clone_ptr(&arg_conv);
40479         return ret_val;
40480 }
40481
40482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40483         LDKDirectedChannelInfo orig_conv;
40484         orig_conv.inner = (void*)(orig & (~1));
40485         orig_conv.is_owned = false;
40486         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40487         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
40488         int64_t ret_ref = 0;
40489         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40490         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40492         ret_ref = (uintptr_t)ret_var.inner;
40493         if (ret_var.is_owned) {
40494                 ret_ref |= 1;
40495         }
40496         return ret_ref;
40497 }
40498
40499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
40500         LDKDirectedChannelInfo this_arg_conv;
40501         this_arg_conv.inner = (void*)(this_arg & (~1));
40502         this_arg_conv.is_owned = false;
40503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40504         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
40505         int64_t ret_ref = 0;
40506         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40507         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40509         ret_ref = (uintptr_t)ret_var.inner;
40510         if (ret_var.is_owned) {
40511                 ret_ref |= 1;
40512         }
40513         return ret_ref;
40514 }
40515
40516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1direction(JNIEnv *env, jclass clz, int64_t this_arg) {
40517         LDKDirectedChannelInfo this_arg_conv;
40518         this_arg_conv.inner = (void*)(this_arg & (~1));
40519         this_arg_conv.is_owned = false;
40520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40521         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
40522         int64_t ret_ref = 0;
40523         if ((uintptr_t)ret_var.inner > 4096) {
40524                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40525                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40527                 ret_ref = (uintptr_t)ret_var.inner;
40528                 if (ret_var.is_owned) {
40529                         ret_ref |= 1;
40530                 }
40531         }
40532         return ret_ref;
40533 }
40534
40535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
40536         LDKDirectedChannelInfo this_arg_conv;
40537         this_arg_conv.inner = (void*)(this_arg & (~1));
40538         this_arg_conv.is_owned = false;
40539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40540         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40541         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
40542         int64_t ret_ref = (uintptr_t)ret_copy;
40543         return ret_ref;
40544 }
40545
40546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40547         if ((this_ptr & 1) != 0) return;
40548         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40549         CHECK_ACCESS(this_ptr_ptr);
40550         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
40551         FREE((void*)this_ptr);
40552         EffectiveCapacity_free(this_ptr_conv);
40553 }
40554
40555 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
40556         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40557         *ret_copy = EffectiveCapacity_clone(arg);
40558 int64_t ret_ref = (uintptr_t)ret_copy;
40559         return ret_ref;
40560 }
40561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40562         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
40563         int64_t ret_val = EffectiveCapacity_clone_ptr(arg_conv);
40564         return ret_val;
40565 }
40566
40567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40568         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
40569         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40570         *ret_copy = EffectiveCapacity_clone(orig_conv);
40571         int64_t ret_ref = (uintptr_t)ret_copy;
40572         return ret_ref;
40573 }
40574
40575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
40576         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40577         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
40578         int64_t ret_ref = (uintptr_t)ret_copy;
40579         return ret_ref;
40580 }
40581
40582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
40583         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40584         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
40585         int64_t ret_ref = (uintptr_t)ret_copy;
40586         return ret_ref;
40587 }
40588
40589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat) {
40590         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40591         *ret_copy = EffectiveCapacity_total(capacity_msat);
40592         int64_t ret_ref = (uintptr_t)ret_copy;
40593         return ret_ref;
40594 }
40595
40596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
40597         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40598         *ret_copy = EffectiveCapacity_infinite();
40599         int64_t ret_ref = (uintptr_t)ret_copy;
40600         return ret_ref;
40601 }
40602
40603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
40604         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40605         *ret_copy = EffectiveCapacity_unknown();
40606         int64_t ret_ref = (uintptr_t)ret_copy;
40607         return ret_ref;
40608 }
40609
40610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
40611         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
40612         int64_t ret_val = EffectiveCapacity_as_msat(this_arg_conv);
40613         return ret_val;
40614 }
40615
40616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40617         LDKRoutingFees this_obj_conv;
40618         this_obj_conv.inner = (void*)(this_obj & (~1));
40619         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40621         RoutingFees_free(this_obj_conv);
40622 }
40623
40624 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
40625         LDKRoutingFees this_ptr_conv;
40626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40627         this_ptr_conv.is_owned = false;
40628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40629         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
40630         return ret_val;
40631 }
40632
40633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40634         LDKRoutingFees this_ptr_conv;
40635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40636         this_ptr_conv.is_owned = false;
40637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40638         RoutingFees_set_base_msat(&this_ptr_conv, val);
40639 }
40640
40641 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
40642         LDKRoutingFees this_ptr_conv;
40643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40644         this_ptr_conv.is_owned = false;
40645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40646         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
40647         return ret_val;
40648 }
40649
40650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40651         LDKRoutingFees this_ptr_conv;
40652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40653         this_ptr_conv.is_owned = false;
40654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40655         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
40656 }
40657
40658 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) {
40659         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
40660         int64_t ret_ref = 0;
40661         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40662         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40664         ret_ref = (uintptr_t)ret_var.inner;
40665         if (ret_var.is_owned) {
40666                 ret_ref |= 1;
40667         }
40668         return ret_ref;
40669 }
40670
40671 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40672         LDKRoutingFees a_conv;
40673         a_conv.inner = (void*)(a & (~1));
40674         a_conv.is_owned = false;
40675         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40676         LDKRoutingFees b_conv;
40677         b_conv.inner = (void*)(b & (~1));
40678         b_conv.is_owned = false;
40679         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40680         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
40681         return ret_val;
40682 }
40683
40684 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
40685         LDKRoutingFees ret_var = RoutingFees_clone(arg);
40686 int64_t ret_ref = 0;
40687 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40688 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40689 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40690 ret_ref = (uintptr_t)ret_var.inner;
40691 if (ret_var.is_owned) {
40692         ret_ref |= 1;
40693 }
40694         return ret_ref;
40695 }
40696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40697         LDKRoutingFees arg_conv;
40698         arg_conv.inner = (void*)(arg & (~1));
40699         arg_conv.is_owned = false;
40700         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40701         int64_t ret_val = RoutingFees_clone_ptr(&arg_conv);
40702         return ret_val;
40703 }
40704
40705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40706         LDKRoutingFees orig_conv;
40707         orig_conv.inner = (void*)(orig & (~1));
40708         orig_conv.is_owned = false;
40709         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40710         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
40711         int64_t ret_ref = 0;
40712         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40713         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40715         ret_ref = (uintptr_t)ret_var.inner;
40716         if (ret_var.is_owned) {
40717                 ret_ref |= 1;
40718         }
40719         return ret_ref;
40720 }
40721
40722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
40723         LDKRoutingFees o_conv;
40724         o_conv.inner = (void*)(o & (~1));
40725         o_conv.is_owned = false;
40726         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40727         int64_t ret_val = RoutingFees_hash(&o_conv);
40728         return ret_val;
40729 }
40730
40731 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
40732         LDKRoutingFees obj_conv;
40733         obj_conv.inner = (void*)(obj & (~1));
40734         obj_conv.is_owned = false;
40735         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40736         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
40737         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40738         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40739         CVec_u8Z_free(ret_var);
40740         return ret_arr;
40741 }
40742
40743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40744         LDKu8slice ser_ref;
40745         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40746         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40747         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
40748         *ret_conv = RoutingFees_read(ser_ref);
40749         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40750         return (int64_t)ret_conv;
40751 }
40752
40753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40754         LDKNodeAnnouncementInfo this_obj_conv;
40755         this_obj_conv.inner = (void*)(this_obj & (~1));
40756         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40758         NodeAnnouncementInfo_free(this_obj_conv);
40759 }
40760
40761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
40762         LDKNodeAnnouncementInfo this_ptr_conv;
40763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40764         this_ptr_conv.is_owned = false;
40765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40766         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
40767         int64_t ret_ref = 0;
40768         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40769         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40771         ret_ref = (uintptr_t)ret_var.inner;
40772         if (ret_var.is_owned) {
40773                 ret_ref |= 1;
40774         }
40775         return ret_ref;
40776 }
40777
40778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40779         LDKNodeAnnouncementInfo this_ptr_conv;
40780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40781         this_ptr_conv.is_owned = false;
40782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40783         LDKNodeFeatures val_conv;
40784         val_conv.inner = (void*)(val & (~1));
40785         val_conv.is_owned = (val & 1) || (val == 0);
40786         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40787         val_conv = NodeFeatures_clone(&val_conv);
40788         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
40789 }
40790
40791 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
40792         LDKNodeAnnouncementInfo this_ptr_conv;
40793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40794         this_ptr_conv.is_owned = false;
40795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40796         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
40797         return ret_val;
40798 }
40799
40800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40801         LDKNodeAnnouncementInfo this_ptr_conv;
40802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40803         this_ptr_conv.is_owned = false;
40804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40805         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
40806 }
40807
40808 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
40809         LDKNodeAnnouncementInfo this_ptr_conv;
40810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40811         this_ptr_conv.is_owned = false;
40812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40813         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
40814         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
40815         return ret_arr;
40816 }
40817
40818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40819         LDKNodeAnnouncementInfo this_ptr_conv;
40820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40821         this_ptr_conv.is_owned = false;
40822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40823         LDKThreeBytes val_ref;
40824         CHECK((*env)->GetArrayLength(env, val) == 3);
40825         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
40826         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
40827 }
40828
40829 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
40830         LDKNodeAnnouncementInfo this_ptr_conv;
40831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40832         this_ptr_conv.is_owned = false;
40833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40834         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40835         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
40836         return ret_arr;
40837 }
40838
40839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40840         LDKNodeAnnouncementInfo this_ptr_conv;
40841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40842         this_ptr_conv.is_owned = false;
40843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40844         LDKThirtyTwoBytes val_ref;
40845         CHECK((*env)->GetArrayLength(env, val) == 32);
40846         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
40847         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
40848 }
40849
40850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40851         LDKNodeAnnouncementInfo this_ptr_conv;
40852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40853         this_ptr_conv.is_owned = false;
40854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40855         LDKCVec_NetAddressZ val_constr;
40856         val_constr.datalen = (*env)->GetArrayLength(env, val);
40857         if (val_constr.datalen > 0)
40858                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40859         else
40860                 val_constr.data = NULL;
40861         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40862         for (size_t m = 0; m < val_constr.datalen; m++) {
40863                 int64_t val_conv_12 = val_vals[m];
40864                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
40865                 CHECK_ACCESS(val_conv_12_ptr);
40866                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
40867                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
40868                 val_constr.data[m] = val_conv_12_conv;
40869         }
40870         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40871         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
40872 }
40873
40874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
40875         LDKNodeAnnouncementInfo this_ptr_conv;
40876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40877         this_ptr_conv.is_owned = false;
40878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40879         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
40880         int64_t ret_ref = 0;
40881         if ((uintptr_t)ret_var.inner > 4096) {
40882                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40883                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40885                 ret_ref = (uintptr_t)ret_var.inner;
40886                 if (ret_var.is_owned) {
40887                         ret_ref |= 1;
40888                 }
40889         }
40890         return ret_ref;
40891 }
40892
40893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40894         LDKNodeAnnouncementInfo this_ptr_conv;
40895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40896         this_ptr_conv.is_owned = false;
40897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40898         LDKNodeAnnouncement val_conv;
40899         val_conv.inner = (void*)(val & (~1));
40900         val_conv.is_owned = (val & 1) || (val == 0);
40901         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40902         val_conv = NodeAnnouncement_clone(&val_conv);
40903         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
40904 }
40905
40906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int8_tArray alias_arg, int64_tArray addresses_arg, int64_t announcement_message_arg) {
40907         LDKNodeFeatures features_arg_conv;
40908         features_arg_conv.inner = (void*)(features_arg & (~1));
40909         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
40910         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
40911         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
40912         LDKThreeBytes rgb_arg_ref;
40913         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
40914         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
40915         LDKThirtyTwoBytes alias_arg_ref;
40916         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
40917         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
40918         LDKCVec_NetAddressZ addresses_arg_constr;
40919         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
40920         if (addresses_arg_constr.datalen > 0)
40921                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40922         else
40923                 addresses_arg_constr.data = NULL;
40924         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
40925         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
40926                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
40927                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
40928                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
40929                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
40930                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
40931         }
40932         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
40933         LDKNodeAnnouncement announcement_message_arg_conv;
40934         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
40935         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
40936         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
40937         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
40938         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
40939         int64_t ret_ref = 0;
40940         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40941         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40943         ret_ref = (uintptr_t)ret_var.inner;
40944         if (ret_var.is_owned) {
40945                 ret_ref |= 1;
40946         }
40947         return ret_ref;
40948 }
40949
40950 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
40951         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
40952 int64_t ret_ref = 0;
40953 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40954 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40955 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40956 ret_ref = (uintptr_t)ret_var.inner;
40957 if (ret_var.is_owned) {
40958         ret_ref |= 1;
40959 }
40960         return ret_ref;
40961 }
40962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40963         LDKNodeAnnouncementInfo arg_conv;
40964         arg_conv.inner = (void*)(arg & (~1));
40965         arg_conv.is_owned = false;
40966         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40967         int64_t ret_val = NodeAnnouncementInfo_clone_ptr(&arg_conv);
40968         return ret_val;
40969 }
40970
40971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40972         LDKNodeAnnouncementInfo orig_conv;
40973         orig_conv.inner = (void*)(orig & (~1));
40974         orig_conv.is_owned = false;
40975         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40976         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
40977         int64_t ret_ref = 0;
40978         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40979         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40981         ret_ref = (uintptr_t)ret_var.inner;
40982         if (ret_var.is_owned) {
40983                 ret_ref |= 1;
40984         }
40985         return ret_ref;
40986 }
40987
40988 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
40989         LDKNodeAnnouncementInfo obj_conv;
40990         obj_conv.inner = (void*)(obj & (~1));
40991         obj_conv.is_owned = false;
40992         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40993         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
40994         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40995         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40996         CVec_u8Z_free(ret_var);
40997         return ret_arr;
40998 }
40999
41000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41001         LDKu8slice ser_ref;
41002         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41003         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41004         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
41005         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
41006         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41007         return (int64_t)ret_conv;
41008 }
41009
41010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41011         LDKNodeInfo this_obj_conv;
41012         this_obj_conv.inner = (void*)(this_obj & (~1));
41013         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41015         NodeInfo_free(this_obj_conv);
41016 }
41017
41018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
41019         LDKNodeInfo this_ptr_conv;
41020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41021         this_ptr_conv.is_owned = false;
41022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41023         LDKCVec_u64Z val_constr;
41024         val_constr.datalen = (*env)->GetArrayLength(env, val);
41025         if (val_constr.datalen > 0)
41026                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
41027         else
41028                 val_constr.data = NULL;
41029         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
41030         for (size_t g = 0; g < val_constr.datalen; g++) {
41031                 int64_t val_conv_6 = val_vals[g];
41032                 val_constr.data[g] = val_conv_6;
41033         }
41034         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
41035         NodeInfo_set_channels(&this_ptr_conv, val_constr);
41036 }
41037
41038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
41039         LDKNodeInfo this_ptr_conv;
41040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41041         this_ptr_conv.is_owned = false;
41042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41043         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
41044         int64_t ret_ref = 0;
41045         if ((uintptr_t)ret_var.inner > 4096) {
41046                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41047                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41049                 ret_ref = (uintptr_t)ret_var.inner;
41050                 if (ret_var.is_owned) {
41051                         ret_ref |= 1;
41052                 }
41053         }
41054         return ret_ref;
41055 }
41056
41057 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) {
41058         LDKNodeInfo this_ptr_conv;
41059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41060         this_ptr_conv.is_owned = false;
41061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41062         LDKRoutingFees val_conv;
41063         val_conv.inner = (void*)(val & (~1));
41064         val_conv.is_owned = (val & 1) || (val == 0);
41065         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41066         val_conv = RoutingFees_clone(&val_conv);
41067         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
41068 }
41069
41070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
41071         LDKNodeInfo this_ptr_conv;
41072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41073         this_ptr_conv.is_owned = false;
41074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41075         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
41076         int64_t ret_ref = 0;
41077         if ((uintptr_t)ret_var.inner > 4096) {
41078                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41079                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41081                 ret_ref = (uintptr_t)ret_var.inner;
41082                 if (ret_var.is_owned) {
41083                         ret_ref |= 1;
41084                 }
41085         }
41086         return ret_ref;
41087 }
41088
41089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41090         LDKNodeInfo this_ptr_conv;
41091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41092         this_ptr_conv.is_owned = false;
41093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41094         LDKNodeAnnouncementInfo val_conv;
41095         val_conv.inner = (void*)(val & (~1));
41096         val_conv.is_owned = (val & 1) || (val == 0);
41097         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41098         val_conv = NodeAnnouncementInfo_clone(&val_conv);
41099         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
41100 }
41101
41102 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) {
41103         LDKCVec_u64Z channels_arg_constr;
41104         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
41105         if (channels_arg_constr.datalen > 0)
41106                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
41107         else
41108                 channels_arg_constr.data = NULL;
41109         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
41110         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
41111                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
41112                 channels_arg_constr.data[g] = channels_arg_conv_6;
41113         }
41114         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
41115         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
41116         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
41117         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
41118         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
41119         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
41120         LDKNodeAnnouncementInfo announcement_info_arg_conv;
41121         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
41122         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
41123         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
41124         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
41125         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
41126         int64_t ret_ref = 0;
41127         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41128         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41129         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41130         ret_ref = (uintptr_t)ret_var.inner;
41131         if (ret_var.is_owned) {
41132                 ret_ref |= 1;
41133         }
41134         return ret_ref;
41135 }
41136
41137 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
41138         LDKNodeInfo ret_var = NodeInfo_clone(arg);
41139 int64_t ret_ref = 0;
41140 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41141 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41142 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41143 ret_ref = (uintptr_t)ret_var.inner;
41144 if (ret_var.is_owned) {
41145         ret_ref |= 1;
41146 }
41147         return ret_ref;
41148 }
41149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41150         LDKNodeInfo arg_conv;
41151         arg_conv.inner = (void*)(arg & (~1));
41152         arg_conv.is_owned = false;
41153         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41154         int64_t ret_val = NodeInfo_clone_ptr(&arg_conv);
41155         return ret_val;
41156 }
41157
41158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41159         LDKNodeInfo orig_conv;
41160         orig_conv.inner = (void*)(orig & (~1));
41161         orig_conv.is_owned = false;
41162         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41163         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
41164         int64_t ret_ref = 0;
41165         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41166         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41168         ret_ref = (uintptr_t)ret_var.inner;
41169         if (ret_var.is_owned) {
41170                 ret_ref |= 1;
41171         }
41172         return ret_ref;
41173 }
41174
41175 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
41176         LDKNodeInfo obj_conv;
41177         obj_conv.inner = (void*)(obj & (~1));
41178         obj_conv.is_owned = false;
41179         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41180         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
41181         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41182         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41183         CVec_u8Z_free(ret_var);
41184         return ret_arr;
41185 }
41186
41187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41188         LDKu8slice ser_ref;
41189         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41190         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41191         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
41192         *ret_conv = NodeInfo_read(ser_ref);
41193         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41194         return (int64_t)ret_conv;
41195 }
41196
41197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
41198         LDKNetworkGraph obj_conv;
41199         obj_conv.inner = (void*)(obj & (~1));
41200         obj_conv.is_owned = false;
41201         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41202         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
41203         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41204         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41205         CVec_u8Z_free(ret_var);
41206         return ret_arr;
41207 }
41208
41209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41210         LDKu8slice ser_ref;
41211         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41212         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41213         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
41214         *ret_conv = NetworkGraph_read(ser_ref);
41215         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41216         return (int64_t)ret_conv;
41217 }
41218
41219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
41220         LDKThirtyTwoBytes genesis_hash_ref;
41221         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
41222         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
41223         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
41224         int64_t ret_ref = 0;
41225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41228         ret_ref = (uintptr_t)ret_var.inner;
41229         if (ret_var.is_owned) {
41230                 ret_ref |= 1;
41231         }
41232         return ret_ref;
41233 }
41234
41235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
41236         LDKNetworkGraph this_arg_conv;
41237         this_arg_conv.inner = (void*)(this_arg & (~1));
41238         this_arg_conv.is_owned = false;
41239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41240         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
41241         int64_t ret_ref = 0;
41242         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41243         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41245         ret_ref = (uintptr_t)ret_var.inner;
41246         if (ret_var.is_owned) {
41247                 ret_ref |= 1;
41248         }
41249         return ret_ref;
41250 }
41251
41252 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) {
41253         LDKNetworkGraph this_arg_conv;
41254         this_arg_conv.inner = (void*)(this_arg & (~1));
41255         this_arg_conv.is_owned = false;
41256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41257         LDKNodeAnnouncement msg_conv;
41258         msg_conv.inner = (void*)(msg & (~1));
41259         msg_conv.is_owned = false;
41260         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41261         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41262         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
41263         return (int64_t)ret_conv;
41264 }
41265
41266 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) {
41267         LDKNetworkGraph this_arg_conv;
41268         this_arg_conv.inner = (void*)(this_arg & (~1));
41269         this_arg_conv.is_owned = false;
41270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41271         LDKUnsignedNodeAnnouncement msg_conv;
41272         msg_conv.inner = (void*)(msg & (~1));
41273         msg_conv.is_owned = false;
41274         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41275         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41276         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
41277         return (int64_t)ret_conv;
41278 }
41279
41280 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) {
41281         LDKNetworkGraph this_arg_conv;
41282         this_arg_conv.inner = (void*)(this_arg & (~1));
41283         this_arg_conv.is_owned = false;
41284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41285         LDKChannelAnnouncement msg_conv;
41286         msg_conv.inner = (void*)(msg & (~1));
41287         msg_conv.is_owned = false;
41288         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41289         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
41290         CHECK_ACCESS(chain_access_ptr);
41291         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
41292         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
41293         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
41294                 // Manually implement clone for Java trait instances
41295                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
41296                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41297                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
41298                 }
41299         }
41300         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41301         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
41302         return (int64_t)ret_conv;
41303 }
41304
41305 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) {
41306         LDKNetworkGraph this_arg_conv;
41307         this_arg_conv.inner = (void*)(this_arg & (~1));
41308         this_arg_conv.is_owned = false;
41309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41310         LDKUnsignedChannelAnnouncement msg_conv;
41311         msg_conv.inner = (void*)(msg & (~1));
41312         msg_conv.is_owned = false;
41313         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41314         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
41315         CHECK_ACCESS(chain_access_ptr);
41316         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
41317         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
41318         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
41319                 // Manually implement clone for Java trait instances
41320                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
41321                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41322                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
41323                 }
41324         }
41325         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41326         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
41327         return (int64_t)ret_conv;
41328 }
41329
41330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1close_1channel_1from_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
41331         LDKNetworkGraph 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         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
41336 }
41337
41338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1fail_1node(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
41339         LDKNetworkGraph 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         LDKPublicKey _node_id_ref;
41344         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
41345         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
41346         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
41347 }
41348
41349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
41350         LDKNetworkGraph this_arg_conv;
41351         this_arg_conv.inner = (void*)(this_arg & (~1));
41352         this_arg_conv.is_owned = false;
41353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41354         NetworkGraph_remove_stale_channels(&this_arg_conv);
41355 }
41356
41357 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) {
41358         LDKNetworkGraph this_arg_conv;
41359         this_arg_conv.inner = (void*)(this_arg & (~1));
41360         this_arg_conv.is_owned = false;
41361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41362         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
41363 }
41364
41365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
41366         LDKNetworkGraph this_arg_conv;
41367         this_arg_conv.inner = (void*)(this_arg & (~1));
41368         this_arg_conv.is_owned = false;
41369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41370         LDKChannelUpdate msg_conv;
41371         msg_conv.inner = (void*)(msg & (~1));
41372         msg_conv.is_owned = false;
41373         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41374         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41375         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
41376         return (int64_t)ret_conv;
41377 }
41378
41379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
41380         LDKNetworkGraph this_arg_conv;
41381         this_arg_conv.inner = (void*)(this_arg & (~1));
41382         this_arg_conv.is_owned = false;
41383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41384         LDKUnsignedChannelUpdate msg_conv;
41385         msg_conv.inner = (void*)(msg & (~1));
41386         msg_conv.is_owned = false;
41387         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41388         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41389         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
41390         return (int64_t)ret_conv;
41391 }
41392
41393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
41394         LDKReadOnlyNetworkGraph this_arg_conv;
41395         this_arg_conv.inner = (void*)(this_arg & (~1));
41396         this_arg_conv.is_owned = false;
41397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41398         LDKPublicKey pubkey_ref;
41399         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
41400         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
41401         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
41402         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
41403         int64_t ret_ref = (uintptr_t)ret_copy;
41404         return ret_ref;
41405 }
41406
41407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41408         LDKRouteHop this_obj_conv;
41409         this_obj_conv.inner = (void*)(this_obj & (~1));
41410         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41412         RouteHop_free(this_obj_conv);
41413 }
41414
41415 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
41416         LDKRouteHop this_ptr_conv;
41417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41418         this_ptr_conv.is_owned = false;
41419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41420         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41421         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
41422         return ret_arr;
41423 }
41424
41425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41426         LDKRouteHop this_ptr_conv;
41427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41428         this_ptr_conv.is_owned = false;
41429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41430         LDKPublicKey val_ref;
41431         CHECK((*env)->GetArrayLength(env, val) == 33);
41432         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41433         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
41434 }
41435
41436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
41437         LDKRouteHop this_ptr_conv;
41438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41439         this_ptr_conv.is_owned = false;
41440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41441         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
41442         int64_t ret_ref = 0;
41443         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41444         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41446         ret_ref = (uintptr_t)ret_var.inner;
41447         if (ret_var.is_owned) {
41448                 ret_ref |= 1;
41449         }
41450         return ret_ref;
41451 }
41452
41453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41454         LDKRouteHop this_ptr_conv;
41455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41456         this_ptr_conv.is_owned = false;
41457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41458         LDKNodeFeatures val_conv;
41459         val_conv.inner = (void*)(val & (~1));
41460         val_conv.is_owned = (val & 1) || (val == 0);
41461         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41462         val_conv = NodeFeatures_clone(&val_conv);
41463         RouteHop_set_node_features(&this_ptr_conv, val_conv);
41464 }
41465
41466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
41467         LDKRouteHop this_ptr_conv;
41468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41469         this_ptr_conv.is_owned = false;
41470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41471         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
41472         return ret_val;
41473 }
41474
41475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41476         LDKRouteHop this_ptr_conv;
41477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41478         this_ptr_conv.is_owned = false;
41479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41480         RouteHop_set_short_channel_id(&this_ptr_conv, val);
41481 }
41482
41483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
41484         LDKRouteHop this_ptr_conv;
41485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41486         this_ptr_conv.is_owned = false;
41487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41488         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
41489         int64_t ret_ref = 0;
41490         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41491         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41493         ret_ref = (uintptr_t)ret_var.inner;
41494         if (ret_var.is_owned) {
41495                 ret_ref |= 1;
41496         }
41497         return ret_ref;
41498 }
41499
41500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41501         LDKRouteHop this_ptr_conv;
41502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41503         this_ptr_conv.is_owned = false;
41504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41505         LDKChannelFeatures val_conv;
41506         val_conv.inner = (void*)(val & (~1));
41507         val_conv.is_owned = (val & 1) || (val == 0);
41508         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41509         val_conv = ChannelFeatures_clone(&val_conv);
41510         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
41511 }
41512
41513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
41514         LDKRouteHop this_ptr_conv;
41515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41516         this_ptr_conv.is_owned = false;
41517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41518         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
41519         return ret_val;
41520 }
41521
41522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41523         LDKRouteHop this_ptr_conv;
41524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41525         this_ptr_conv.is_owned = false;
41526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41527         RouteHop_set_fee_msat(&this_ptr_conv, val);
41528 }
41529
41530 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
41531         LDKRouteHop this_ptr_conv;
41532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41533         this_ptr_conv.is_owned = false;
41534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41535         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
41536         return ret_val;
41537 }
41538
41539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
41540         LDKRouteHop this_ptr_conv;
41541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41542         this_ptr_conv.is_owned = false;
41543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41544         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
41545 }
41546
41547 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) {
41548         LDKPublicKey pubkey_arg_ref;
41549         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
41550         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
41551         LDKNodeFeatures node_features_arg_conv;
41552         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
41553         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
41554         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
41555         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
41556         LDKChannelFeatures channel_features_arg_conv;
41557         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
41558         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
41559         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
41560         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
41561         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);
41562         int64_t ret_ref = 0;
41563         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41564         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41566         ret_ref = (uintptr_t)ret_var.inner;
41567         if (ret_var.is_owned) {
41568                 ret_ref |= 1;
41569         }
41570         return ret_ref;
41571 }
41572
41573 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
41574         LDKRouteHop ret_var = RouteHop_clone(arg);
41575 int64_t ret_ref = 0;
41576 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41577 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41578 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41579 ret_ref = (uintptr_t)ret_var.inner;
41580 if (ret_var.is_owned) {
41581         ret_ref |= 1;
41582 }
41583         return ret_ref;
41584 }
41585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41586         LDKRouteHop arg_conv;
41587         arg_conv.inner = (void*)(arg & (~1));
41588         arg_conv.is_owned = false;
41589         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41590         int64_t ret_val = RouteHop_clone_ptr(&arg_conv);
41591         return ret_val;
41592 }
41593
41594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41595         LDKRouteHop orig_conv;
41596         orig_conv.inner = (void*)(orig & (~1));
41597         orig_conv.is_owned = false;
41598         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41599         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
41600         int64_t ret_ref = 0;
41601         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41602         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41604         ret_ref = (uintptr_t)ret_var.inner;
41605         if (ret_var.is_owned) {
41606                 ret_ref |= 1;
41607         }
41608         return ret_ref;
41609 }
41610
41611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
41612         LDKRouteHop o_conv;
41613         o_conv.inner = (void*)(o & (~1));
41614         o_conv.is_owned = false;
41615         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41616         int64_t ret_val = RouteHop_hash(&o_conv);
41617         return ret_val;
41618 }
41619
41620 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41621         LDKRouteHop a_conv;
41622         a_conv.inner = (void*)(a & (~1));
41623         a_conv.is_owned = false;
41624         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41625         LDKRouteHop b_conv;
41626         b_conv.inner = (void*)(b & (~1));
41627         b_conv.is_owned = false;
41628         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41629         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
41630         return ret_val;
41631 }
41632
41633 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
41634         LDKRouteHop obj_conv;
41635         obj_conv.inner = (void*)(obj & (~1));
41636         obj_conv.is_owned = false;
41637         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41638         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
41639         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41640         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41641         CVec_u8Z_free(ret_var);
41642         return ret_arr;
41643 }
41644
41645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41646         LDKu8slice ser_ref;
41647         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41648         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41649         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
41650         *ret_conv = RouteHop_read(ser_ref);
41651         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41652         return (int64_t)ret_conv;
41653 }
41654
41655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41656         LDKRoute this_obj_conv;
41657         this_obj_conv.inner = (void*)(this_obj & (~1));
41658         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41660         Route_free(this_obj_conv);
41661 }
41662
41663 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
41664         LDKRoute this_ptr_conv;
41665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41666         this_ptr_conv.is_owned = false;
41667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41668         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
41669         jobjectArray ret_arr = NULL;
41670         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
41671         ;
41672         for (size_t m = 0; m < ret_var.datalen; m++) {
41673                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
41674                 int64_tArray ret_conv_12_arr = NULL;
41675                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
41676                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
41677                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
41678                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
41679                         int64_t ret_conv_12_conv_10_ref = 0;
41680                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41681                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41682                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
41683                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
41684                         if (ret_conv_12_conv_10_var.is_owned) {
41685                                 ret_conv_12_conv_10_ref |= 1;
41686                         }
41687                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
41688                 }
41689                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
41690                 FREE(ret_conv_12_var.data);
41691                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
41692         }
41693         
41694         FREE(ret_var.data);
41695         return ret_arr;
41696 }
41697
41698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
41699         LDKRoute this_ptr_conv;
41700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41701         this_ptr_conv.is_owned = false;
41702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41703         LDKCVec_CVec_RouteHopZZ val_constr;
41704         val_constr.datalen = (*env)->GetArrayLength(env, val);
41705         if (val_constr.datalen > 0)
41706                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41707         else
41708                 val_constr.data = NULL;
41709         for (size_t m = 0; m < val_constr.datalen; m++) {
41710                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
41711                 LDKCVec_RouteHopZ val_conv_12_constr;
41712                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
41713                 if (val_conv_12_constr.datalen > 0)
41714                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41715                 else
41716                         val_conv_12_constr.data = NULL;
41717                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
41718                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
41719                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
41720                         LDKRouteHop val_conv_12_conv_10_conv;
41721                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
41722                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
41723                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
41724                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
41725                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
41726                 }
41727                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
41728                 val_constr.data[m] = val_conv_12_constr;
41729         }
41730         Route_set_paths(&this_ptr_conv, val_constr);
41731 }
41732
41733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
41734         LDKRoute this_ptr_conv;
41735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41736         this_ptr_conv.is_owned = false;
41737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41738         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
41739         int64_t ret_ref = 0;
41740         if ((uintptr_t)ret_var.inner > 4096) {
41741                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41742                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41744                 ret_ref = (uintptr_t)ret_var.inner;
41745                 if (ret_var.is_owned) {
41746                         ret_ref |= 1;
41747                 }
41748         }
41749         return ret_ref;
41750 }
41751
41752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41753         LDKRoute this_ptr_conv;
41754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41755         this_ptr_conv.is_owned = false;
41756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41757         LDKPaymentParameters val_conv;
41758         val_conv.inner = (void*)(val & (~1));
41759         val_conv.is_owned = (val & 1) || (val == 0);
41760         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41761         val_conv = PaymentParameters_clone(&val_conv);
41762         Route_set_payment_params(&this_ptr_conv, val_conv);
41763 }
41764
41765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
41766         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
41767         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
41768         if (paths_arg_constr.datalen > 0)
41769                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41770         else
41771                 paths_arg_constr.data = NULL;
41772         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
41773                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
41774                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
41775                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
41776                 if (paths_arg_conv_12_constr.datalen > 0)
41777                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41778                 else
41779                         paths_arg_conv_12_constr.data = NULL;
41780                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
41781                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
41782                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
41783                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
41784                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
41785                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
41786                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
41787                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
41788                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
41789                 }
41790                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
41791                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
41792         }
41793         LDKPaymentParameters payment_params_arg_conv;
41794         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
41795         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
41796         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
41797         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
41798         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
41799         int64_t ret_ref = 0;
41800         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41801         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41803         ret_ref = (uintptr_t)ret_var.inner;
41804         if (ret_var.is_owned) {
41805                 ret_ref |= 1;
41806         }
41807         return ret_ref;
41808 }
41809
41810 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
41811         LDKRoute ret_var = Route_clone(arg);
41812 int64_t ret_ref = 0;
41813 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41814 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41815 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41816 ret_ref = (uintptr_t)ret_var.inner;
41817 if (ret_var.is_owned) {
41818         ret_ref |= 1;
41819 }
41820         return ret_ref;
41821 }
41822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41823         LDKRoute arg_conv;
41824         arg_conv.inner = (void*)(arg & (~1));
41825         arg_conv.is_owned = false;
41826         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41827         int64_t ret_val = Route_clone_ptr(&arg_conv);
41828         return ret_val;
41829 }
41830
41831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41832         LDKRoute orig_conv;
41833         orig_conv.inner = (void*)(orig & (~1));
41834         orig_conv.is_owned = false;
41835         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41836         LDKRoute ret_var = Route_clone(&orig_conv);
41837         int64_t ret_ref = 0;
41838         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41839         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41841         ret_ref = (uintptr_t)ret_var.inner;
41842         if (ret_var.is_owned) {
41843                 ret_ref |= 1;
41844         }
41845         return ret_ref;
41846 }
41847
41848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
41849         LDKRoute o_conv;
41850         o_conv.inner = (void*)(o & (~1));
41851         o_conv.is_owned = false;
41852         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41853         int64_t ret_val = Route_hash(&o_conv);
41854         return ret_val;
41855 }
41856
41857 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41858         LDKRoute a_conv;
41859         a_conv.inner = (void*)(a & (~1));
41860         a_conv.is_owned = false;
41861         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41862         LDKRoute b_conv;
41863         b_conv.inner = (void*)(b & (~1));
41864         b_conv.is_owned = false;
41865         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41866         jboolean ret_val = Route_eq(&a_conv, &b_conv);
41867         return ret_val;
41868 }
41869
41870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
41871         LDKRoute this_arg_conv;
41872         this_arg_conv.inner = (void*)(this_arg & (~1));
41873         this_arg_conv.is_owned = false;
41874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41875         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
41876         return ret_val;
41877 }
41878
41879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
41880         LDKRoute this_arg_conv;
41881         this_arg_conv.inner = (void*)(this_arg & (~1));
41882         this_arg_conv.is_owned = false;
41883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41884         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
41885         return ret_val;
41886 }
41887
41888 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
41889         LDKRoute obj_conv;
41890         obj_conv.inner = (void*)(obj & (~1));
41891         obj_conv.is_owned = false;
41892         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41893         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
41894         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41895         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41896         CVec_u8Z_free(ret_var);
41897         return ret_arr;
41898 }
41899
41900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41901         LDKu8slice ser_ref;
41902         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41903         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41904         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
41905         *ret_conv = Route_read(ser_ref);
41906         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41907         return (int64_t)ret_conv;
41908 }
41909
41910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41911         LDKRouteParameters this_obj_conv;
41912         this_obj_conv.inner = (void*)(this_obj & (~1));
41913         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41915         RouteParameters_free(this_obj_conv);
41916 }
41917
41918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
41919         LDKRouteParameters this_ptr_conv;
41920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41921         this_ptr_conv.is_owned = false;
41922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41923         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
41924         int64_t ret_ref = 0;
41925         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41926         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41928         ret_ref = (uintptr_t)ret_var.inner;
41929         if (ret_var.is_owned) {
41930                 ret_ref |= 1;
41931         }
41932         return ret_ref;
41933 }
41934
41935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41936         LDKRouteParameters this_ptr_conv;
41937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41938         this_ptr_conv.is_owned = false;
41939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41940         LDKPaymentParameters val_conv;
41941         val_conv.inner = (void*)(val & (~1));
41942         val_conv.is_owned = (val & 1) || (val == 0);
41943         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41944         val_conv = PaymentParameters_clone(&val_conv);
41945         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
41946 }
41947
41948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
41949         LDKRouteParameters this_ptr_conv;
41950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41951         this_ptr_conv.is_owned = false;
41952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41953         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
41954         return ret_val;
41955 }
41956
41957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41958         LDKRouteParameters this_ptr_conv;
41959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41960         this_ptr_conv.is_owned = false;
41961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41962         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
41963 }
41964
41965 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
41966         LDKRouteParameters this_ptr_conv;
41967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41968         this_ptr_conv.is_owned = false;
41969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41970         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
41971         return ret_val;
41972 }
41973
41974 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) {
41975         LDKRouteParameters this_ptr_conv;
41976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41977         this_ptr_conv.is_owned = false;
41978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41979         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
41980 }
41981
41982 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) {
41983         LDKPaymentParameters payment_params_arg_conv;
41984         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
41985         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
41986         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
41987         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
41988         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
41989         int64_t ret_ref = 0;
41990         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41991         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41993         ret_ref = (uintptr_t)ret_var.inner;
41994         if (ret_var.is_owned) {
41995                 ret_ref |= 1;
41996         }
41997         return ret_ref;
41998 }
41999
42000 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
42001         LDKRouteParameters ret_var = RouteParameters_clone(arg);
42002 int64_t ret_ref = 0;
42003 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42004 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42005 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42006 ret_ref = (uintptr_t)ret_var.inner;
42007 if (ret_var.is_owned) {
42008         ret_ref |= 1;
42009 }
42010         return ret_ref;
42011 }
42012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42013         LDKRouteParameters arg_conv;
42014         arg_conv.inner = (void*)(arg & (~1));
42015         arg_conv.is_owned = false;
42016         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42017         int64_t ret_val = RouteParameters_clone_ptr(&arg_conv);
42018         return ret_val;
42019 }
42020
42021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42022         LDKRouteParameters orig_conv;
42023         orig_conv.inner = (void*)(orig & (~1));
42024         orig_conv.is_owned = false;
42025         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42026         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
42027         int64_t ret_ref = 0;
42028         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42029         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42031         ret_ref = (uintptr_t)ret_var.inner;
42032         if (ret_var.is_owned) {
42033                 ret_ref |= 1;
42034         }
42035         return ret_ref;
42036 }
42037
42038 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
42039         LDKRouteParameters obj_conv;
42040         obj_conv.inner = (void*)(obj & (~1));
42041         obj_conv.is_owned = false;
42042         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42043         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
42044         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42045         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42046         CVec_u8Z_free(ret_var);
42047         return ret_arr;
42048 }
42049
42050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42051         LDKu8slice ser_ref;
42052         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42053         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42054         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
42055         *ret_conv = RouteParameters_read(ser_ref);
42056         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42057         return (int64_t)ret_conv;
42058 }
42059
42060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42061         LDKPaymentParameters this_obj_conv;
42062         this_obj_conv.inner = (void*)(this_obj & (~1));
42063         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42065         PaymentParameters_free(this_obj_conv);
42066 }
42067
42068 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
42069         LDKPaymentParameters this_ptr_conv;
42070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42071         this_ptr_conv.is_owned = false;
42072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42073         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42074         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
42075         return ret_arr;
42076 }
42077
42078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42079         LDKPaymentParameters this_ptr_conv;
42080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42081         this_ptr_conv.is_owned = false;
42082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42083         LDKPublicKey val_ref;
42084         CHECK((*env)->GetArrayLength(env, val) == 33);
42085         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42086         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
42087 }
42088
42089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
42090         LDKPaymentParameters this_ptr_conv;
42091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42092         this_ptr_conv.is_owned = false;
42093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42094         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
42095         int64_t ret_ref = 0;
42096         if ((uintptr_t)ret_var.inner > 4096) {
42097                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42098                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42100                 ret_ref = (uintptr_t)ret_var.inner;
42101                 if (ret_var.is_owned) {
42102                         ret_ref |= 1;
42103                 }
42104         }
42105         return ret_ref;
42106 }
42107
42108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42109         LDKPaymentParameters this_ptr_conv;
42110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42111         this_ptr_conv.is_owned = false;
42112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42113         LDKInvoiceFeatures val_conv;
42114         val_conv.inner = (void*)(val & (~1));
42115         val_conv.is_owned = (val & 1) || (val == 0);
42116         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42117         val_conv = InvoiceFeatures_clone(&val_conv);
42118         PaymentParameters_set_features(&this_ptr_conv, val_conv);
42119 }
42120
42121 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
42122         LDKPaymentParameters this_ptr_conv;
42123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42124         this_ptr_conv.is_owned = false;
42125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42126         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
42127         int64_tArray ret_arr = NULL;
42128         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
42129         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
42130         for (size_t l = 0; l < ret_var.datalen; l++) {
42131                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
42132                 int64_t ret_conv_11_ref = 0;
42133                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42134                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42135                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
42136                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
42137                 if (ret_conv_11_var.is_owned) {
42138                         ret_conv_11_ref |= 1;
42139                 }
42140                 ret_arr_ptr[l] = ret_conv_11_ref;
42141         }
42142         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
42143         FREE(ret_var.data);
42144         return ret_arr;
42145 }
42146
42147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
42148         LDKPaymentParameters this_ptr_conv;
42149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42150         this_ptr_conv.is_owned = false;
42151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42152         LDKCVec_RouteHintZ val_constr;
42153         val_constr.datalen = (*env)->GetArrayLength(env, val);
42154         if (val_constr.datalen > 0)
42155                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
42156         else
42157                 val_constr.data = NULL;
42158         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
42159         for (size_t l = 0; l < val_constr.datalen; l++) {
42160                 int64_t val_conv_11 = val_vals[l];
42161                 LDKRouteHint val_conv_11_conv;
42162                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
42163                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
42164                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
42165                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
42166                 val_constr.data[l] = val_conv_11_conv;
42167         }
42168         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
42169         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
42170 }
42171
42172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
42173         LDKPaymentParameters this_ptr_conv;
42174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42175         this_ptr_conv.is_owned = false;
42176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42177         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42178         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
42179         int64_t ret_ref = (uintptr_t)ret_copy;
42180         return ret_ref;
42181 }
42182
42183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42184         LDKPaymentParameters this_ptr_conv;
42185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42186         this_ptr_conv.is_owned = false;
42187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42188         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42189         CHECK_ACCESS(val_ptr);
42190         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42191         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42192         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
42193 }
42194
42195 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
42196         LDKPaymentParameters this_ptr_conv;
42197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42198         this_ptr_conv.is_owned = false;
42199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42200         int32_t ret_val = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
42201         return ret_val;
42202 }
42203
42204 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) {
42205         LDKPaymentParameters this_ptr_conv;
42206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42207         this_ptr_conv.is_owned = false;
42208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42209         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
42210 }
42211
42212 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) {
42213         LDKPublicKey payee_pubkey_arg_ref;
42214         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
42215         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
42216         LDKInvoiceFeatures features_arg_conv;
42217         features_arg_conv.inner = (void*)(features_arg & (~1));
42218         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
42219         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
42220         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
42221         LDKCVec_RouteHintZ route_hints_arg_constr;
42222         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
42223         if (route_hints_arg_constr.datalen > 0)
42224                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
42225         else
42226                 route_hints_arg_constr.data = NULL;
42227         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
42228         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
42229                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
42230                 LDKRouteHint route_hints_arg_conv_11_conv;
42231                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
42232                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
42233                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
42234                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
42235                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
42236         }
42237         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
42238         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
42239         CHECK_ACCESS(expiry_time_arg_ptr);
42240         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
42241         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
42242         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);
42243         int64_t ret_ref = 0;
42244         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42245         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42247         ret_ref = (uintptr_t)ret_var.inner;
42248         if (ret_var.is_owned) {
42249                 ret_ref |= 1;
42250         }
42251         return ret_ref;
42252 }
42253
42254 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
42255         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
42256 int64_t ret_ref = 0;
42257 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42258 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42259 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42260 ret_ref = (uintptr_t)ret_var.inner;
42261 if (ret_var.is_owned) {
42262         ret_ref |= 1;
42263 }
42264         return ret_ref;
42265 }
42266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42267         LDKPaymentParameters arg_conv;
42268         arg_conv.inner = (void*)(arg & (~1));
42269         arg_conv.is_owned = false;
42270         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42271         int64_t ret_val = PaymentParameters_clone_ptr(&arg_conv);
42272         return ret_val;
42273 }
42274
42275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42276         LDKPaymentParameters orig_conv;
42277         orig_conv.inner = (void*)(orig & (~1));
42278         orig_conv.is_owned = false;
42279         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42280         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
42281         int64_t ret_ref = 0;
42282         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42283         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42285         ret_ref = (uintptr_t)ret_var.inner;
42286         if (ret_var.is_owned) {
42287                 ret_ref |= 1;
42288         }
42289         return ret_ref;
42290 }
42291
42292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
42293         LDKPaymentParameters o_conv;
42294         o_conv.inner = (void*)(o & (~1));
42295         o_conv.is_owned = false;
42296         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42297         int64_t ret_val = PaymentParameters_hash(&o_conv);
42298         return ret_val;
42299 }
42300
42301 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42302         LDKPaymentParameters a_conv;
42303         a_conv.inner = (void*)(a & (~1));
42304         a_conv.is_owned = false;
42305         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42306         LDKPaymentParameters b_conv;
42307         b_conv.inner = (void*)(b & (~1));
42308         b_conv.is_owned = false;
42309         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42310         jboolean ret_val = PaymentParameters_eq(&a_conv, &b_conv);
42311         return ret_val;
42312 }
42313
42314 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
42315         LDKPaymentParameters obj_conv;
42316         obj_conv.inner = (void*)(obj & (~1));
42317         obj_conv.is_owned = false;
42318         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42319         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
42320         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42321         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42322         CVec_u8Z_free(ret_var);
42323         return ret_arr;
42324 }
42325
42326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42327         LDKu8slice ser_ref;
42328         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42329         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42330         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
42331         *ret_conv = PaymentParameters_read(ser_ref);
42332         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42333         return (int64_t)ret_conv;
42334 }
42335
42336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
42337         LDKPublicKey payee_pubkey_ref;
42338         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
42339         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
42340         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
42341         int64_t ret_ref = 0;
42342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42345         ret_ref = (uintptr_t)ret_var.inner;
42346         if (ret_var.is_owned) {
42347                 ret_ref |= 1;
42348         }
42349         return ret_ref;
42350 }
42351
42352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
42353         LDKPublicKey payee_pubkey_ref;
42354         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
42355         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
42356         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
42357         int64_t ret_ref = 0;
42358         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42359         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42361         ret_ref = (uintptr_t)ret_var.inner;
42362         if (ret_var.is_owned) {
42363                 ret_ref |= 1;
42364         }
42365         return ret_ref;
42366 }
42367
42368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42369         LDKRouteHint this_obj_conv;
42370         this_obj_conv.inner = (void*)(this_obj & (~1));
42371         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42373         RouteHint_free(this_obj_conv);
42374 }
42375
42376 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
42377         LDKRouteHint 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         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
42382         int64_tArray ret_arr = NULL;
42383         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
42384         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
42385         for (size_t o = 0; o < ret_var.datalen; o++) {
42386                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
42387                 int64_t ret_conv_14_ref = 0;
42388                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42389                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42390                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
42391                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
42392                 if (ret_conv_14_var.is_owned) {
42393                         ret_conv_14_ref |= 1;
42394                 }
42395                 ret_arr_ptr[o] = ret_conv_14_ref;
42396         }
42397         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
42398         FREE(ret_var.data);
42399         return ret_arr;
42400 }
42401
42402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
42403         LDKRouteHint this_ptr_conv;
42404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42405         this_ptr_conv.is_owned = false;
42406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42407         LDKCVec_RouteHintHopZ val_constr;
42408         val_constr.datalen = (*env)->GetArrayLength(env, val);
42409         if (val_constr.datalen > 0)
42410                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
42411         else
42412                 val_constr.data = NULL;
42413         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
42414         for (size_t o = 0; o < val_constr.datalen; o++) {
42415                 int64_t val_conv_14 = val_vals[o];
42416                 LDKRouteHintHop val_conv_14_conv;
42417                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
42418                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
42419                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
42420                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
42421                 val_constr.data[o] = val_conv_14_conv;
42422         }
42423         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
42424         RouteHint_set_a(&this_ptr_conv, val_constr);
42425 }
42426
42427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
42428         LDKCVec_RouteHintHopZ a_arg_constr;
42429         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
42430         if (a_arg_constr.datalen > 0)
42431                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
42432         else
42433                 a_arg_constr.data = NULL;
42434         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
42435         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
42436                 int64_t a_arg_conv_14 = a_arg_vals[o];
42437                 LDKRouteHintHop a_arg_conv_14_conv;
42438                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
42439                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
42440                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
42441                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
42442                 a_arg_constr.data[o] = a_arg_conv_14_conv;
42443         }
42444         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
42445         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
42446         int64_t ret_ref = 0;
42447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42450         ret_ref = (uintptr_t)ret_var.inner;
42451         if (ret_var.is_owned) {
42452                 ret_ref |= 1;
42453         }
42454         return ret_ref;
42455 }
42456
42457 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
42458         LDKRouteHint ret_var = RouteHint_clone(arg);
42459 int64_t ret_ref = 0;
42460 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42461 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42462 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42463 ret_ref = (uintptr_t)ret_var.inner;
42464 if (ret_var.is_owned) {
42465         ret_ref |= 1;
42466 }
42467         return ret_ref;
42468 }
42469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42470         LDKRouteHint arg_conv;
42471         arg_conv.inner = (void*)(arg & (~1));
42472         arg_conv.is_owned = false;
42473         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42474         int64_t ret_val = RouteHint_clone_ptr(&arg_conv);
42475         return ret_val;
42476 }
42477
42478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42479         LDKRouteHint orig_conv;
42480         orig_conv.inner = (void*)(orig & (~1));
42481         orig_conv.is_owned = false;
42482         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42483         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
42484         int64_t ret_ref = 0;
42485         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42486         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42488         ret_ref = (uintptr_t)ret_var.inner;
42489         if (ret_var.is_owned) {
42490                 ret_ref |= 1;
42491         }
42492         return ret_ref;
42493 }
42494
42495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
42496         LDKRouteHint o_conv;
42497         o_conv.inner = (void*)(o & (~1));
42498         o_conv.is_owned = false;
42499         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42500         int64_t ret_val = RouteHint_hash(&o_conv);
42501         return ret_val;
42502 }
42503
42504 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42505         LDKRouteHint a_conv;
42506         a_conv.inner = (void*)(a & (~1));
42507         a_conv.is_owned = false;
42508         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42509         LDKRouteHint b_conv;
42510         b_conv.inner = (void*)(b & (~1));
42511         b_conv.is_owned = false;
42512         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42513         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
42514         return ret_val;
42515 }
42516
42517 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
42518         LDKRouteHint obj_conv;
42519         obj_conv.inner = (void*)(obj & (~1));
42520         obj_conv.is_owned = false;
42521         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42522         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
42523         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42524         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42525         CVec_u8Z_free(ret_var);
42526         return ret_arr;
42527 }
42528
42529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42530         LDKu8slice ser_ref;
42531         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42532         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42533         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
42534         *ret_conv = RouteHint_read(ser_ref);
42535         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42536         return (int64_t)ret_conv;
42537 }
42538
42539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42540         LDKRouteHintHop this_obj_conv;
42541         this_obj_conv.inner = (void*)(this_obj & (~1));
42542         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42544         RouteHintHop_free(this_obj_conv);
42545 }
42546
42547 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
42548         LDKRouteHintHop this_ptr_conv;
42549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42550         this_ptr_conv.is_owned = false;
42551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42552         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42553         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
42554         return ret_arr;
42555 }
42556
42557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42558         LDKRouteHintHop this_ptr_conv;
42559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42560         this_ptr_conv.is_owned = false;
42561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42562         LDKPublicKey val_ref;
42563         CHECK((*env)->GetArrayLength(env, val) == 33);
42564         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42565         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
42566 }
42567
42568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
42569         LDKRouteHintHop this_ptr_conv;
42570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42571         this_ptr_conv.is_owned = false;
42572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42573         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
42574         return ret_val;
42575 }
42576
42577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42578         LDKRouteHintHop this_ptr_conv;
42579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42580         this_ptr_conv.is_owned = false;
42581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42582         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
42583 }
42584
42585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
42586         LDKRouteHintHop this_ptr_conv;
42587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42588         this_ptr_conv.is_owned = false;
42589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42590         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
42591         int64_t ret_ref = 0;
42592         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42593         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42595         ret_ref = (uintptr_t)ret_var.inner;
42596         if (ret_var.is_owned) {
42597                 ret_ref |= 1;
42598         }
42599         return ret_ref;
42600 }
42601
42602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42603         LDKRouteHintHop this_ptr_conv;
42604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42605         this_ptr_conv.is_owned = false;
42606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42607         LDKRoutingFees val_conv;
42608         val_conv.inner = (void*)(val & (~1));
42609         val_conv.is_owned = (val & 1) || (val == 0);
42610         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42611         val_conv = RoutingFees_clone(&val_conv);
42612         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
42613 }
42614
42615 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
42616         LDKRouteHintHop this_ptr_conv;
42617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42618         this_ptr_conv.is_owned = false;
42619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42620         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
42621         return ret_val;
42622 }
42623
42624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
42625         LDKRouteHintHop this_ptr_conv;
42626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42627         this_ptr_conv.is_owned = false;
42628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42629         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
42630 }
42631
42632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42633         LDKRouteHintHop this_ptr_conv;
42634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42635         this_ptr_conv.is_owned = false;
42636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42637         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42638         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
42639         int64_t ret_ref = (uintptr_t)ret_copy;
42640         return ret_ref;
42641 }
42642
42643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42644         LDKRouteHintHop this_ptr_conv;
42645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42646         this_ptr_conv.is_owned = false;
42647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42648         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42649         CHECK_ACCESS(val_ptr);
42650         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42651         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42652         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
42653 }
42654
42655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42656         LDKRouteHintHop this_ptr_conv;
42657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42658         this_ptr_conv.is_owned = false;
42659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42660         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42661         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
42662         int64_t ret_ref = (uintptr_t)ret_copy;
42663         return ret_ref;
42664 }
42665
42666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42667         LDKRouteHintHop this_ptr_conv;
42668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42669         this_ptr_conv.is_owned = false;
42670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42671         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42672         CHECK_ACCESS(val_ptr);
42673         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42674         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42675         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
42676 }
42677
42678 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) {
42679         LDKPublicKey src_node_id_arg_ref;
42680         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
42681         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
42682         LDKRoutingFees fees_arg_conv;
42683         fees_arg_conv.inner = (void*)(fees_arg & (~1));
42684         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
42685         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
42686         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
42687         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
42688         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
42689         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
42690         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
42691         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
42692         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
42693         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
42694         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
42695         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);
42696         int64_t ret_ref = 0;
42697         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42698         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42700         ret_ref = (uintptr_t)ret_var.inner;
42701         if (ret_var.is_owned) {
42702                 ret_ref |= 1;
42703         }
42704         return ret_ref;
42705 }
42706
42707 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
42708         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
42709 int64_t ret_ref = 0;
42710 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42711 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42712 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42713 ret_ref = (uintptr_t)ret_var.inner;
42714 if (ret_var.is_owned) {
42715         ret_ref |= 1;
42716 }
42717         return ret_ref;
42718 }
42719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42720         LDKRouteHintHop arg_conv;
42721         arg_conv.inner = (void*)(arg & (~1));
42722         arg_conv.is_owned = false;
42723         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42724         int64_t ret_val = RouteHintHop_clone_ptr(&arg_conv);
42725         return ret_val;
42726 }
42727
42728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42729         LDKRouteHintHop orig_conv;
42730         orig_conv.inner = (void*)(orig & (~1));
42731         orig_conv.is_owned = false;
42732         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42733         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
42734         int64_t ret_ref = 0;
42735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42738         ret_ref = (uintptr_t)ret_var.inner;
42739         if (ret_var.is_owned) {
42740                 ret_ref |= 1;
42741         }
42742         return ret_ref;
42743 }
42744
42745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
42746         LDKRouteHintHop o_conv;
42747         o_conv.inner = (void*)(o & (~1));
42748         o_conv.is_owned = false;
42749         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42750         int64_t ret_val = RouteHintHop_hash(&o_conv);
42751         return ret_val;
42752 }
42753
42754 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42755         LDKRouteHintHop a_conv;
42756         a_conv.inner = (void*)(a & (~1));
42757         a_conv.is_owned = false;
42758         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42759         LDKRouteHintHop b_conv;
42760         b_conv.inner = (void*)(b & (~1));
42761         b_conv.is_owned = false;
42762         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42763         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
42764         return ret_val;
42765 }
42766
42767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
42768         LDKRouteHintHop obj_conv;
42769         obj_conv.inner = (void*)(obj & (~1));
42770         obj_conv.is_owned = false;
42771         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42772         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
42773         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42774         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42775         CVec_u8Z_free(ret_var);
42776         return ret_arr;
42777 }
42778
42779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42780         LDKu8slice ser_ref;
42781         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42782         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42783         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
42784         *ret_conv = RouteHintHop_read(ser_ref);
42785         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42786         return (int64_t)ret_conv;
42787 }
42788
42789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_find_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t route_params, int64_t network, int64_tArray first_hops, int64_t logger, int64_t scorer, int8_tArray random_seed_bytes) {
42790         LDKPublicKey our_node_pubkey_ref;
42791         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
42792         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
42793         LDKRouteParameters route_params_conv;
42794         route_params_conv.inner = (void*)(route_params & (~1));
42795         route_params_conv.is_owned = false;
42796         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
42797         LDKNetworkGraph network_conv;
42798         network_conv.inner = (void*)(network & (~1));
42799         network_conv.is_owned = false;
42800         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
42801         LDKCVec_ChannelDetailsZ first_hops_constr;
42802         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
42803         if (first_hops != NULL) {
42804                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
42805                 if (first_hops_constr.datalen > 0)
42806                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
42807                 else
42808                         first_hops_constr.data = NULL;
42809                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
42810                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
42811                         int64_t first_hops_conv_16 = first_hops_vals[q];
42812                         LDKChannelDetails first_hops_conv_16_conv;
42813                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
42814                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
42815                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
42816                         first_hops_constr.data[q] = first_hops_conv_16_conv;
42817                 }
42818                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
42819                 first_hops_ptr = &first_hops_constr;
42820         }
42821         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42822         CHECK_ACCESS(logger_ptr);
42823         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42824         if (logger_conv.free == LDKLogger_JCalls_free) {
42825                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42826                 LDKLogger_JCalls_cloned(&logger_conv);
42827         }
42828         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
42829         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
42830         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
42831         unsigned char random_seed_bytes_arr[32];
42832         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
42833         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
42834         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
42835         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
42836         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv, random_seed_bytes_ref);
42837         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
42838         return (int64_t)ret_conv;
42839 }
42840
42841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42842         if ((this_ptr & 1) != 0) return;
42843         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42844         CHECK_ACCESS(this_ptr_ptr);
42845         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
42846         FREE((void*)this_ptr);
42847         Score_free(this_ptr_conv);
42848 }
42849
42850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42851         if ((this_ptr & 1) != 0) return;
42852         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42853         CHECK_ACCESS(this_ptr_ptr);
42854         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
42855         FREE((void*)this_ptr);
42856         LockableScore_free(this_ptr_conv);
42857 }
42858
42859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42860         LDKMultiThreadedLockableScore this_obj_conv;
42861         this_obj_conv.inner = (void*)(this_obj & (~1));
42862         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42864         MultiThreadedLockableScore_free(this_obj_conv);
42865 }
42866
42867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
42868         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
42869         CHECK_ACCESS(score_ptr);
42870         LDKScore score_conv = *(LDKScore*)(score_ptr);
42871         if (score_conv.free == LDKScore_JCalls_free) {
42872                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42873                 LDKScore_JCalls_cloned(&score_conv);
42874         }
42875         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
42876         int64_t ret_ref = 0;
42877         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42878         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42880         ret_ref = (uintptr_t)ret_var.inner;
42881         if (ret_var.is_owned) {
42882                 ret_ref |= 1;
42883         }
42884         return ret_ref;
42885 }
42886
42887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42888         LDKFixedPenaltyScorer this_obj_conv;
42889         this_obj_conv.inner = (void*)(this_obj & (~1));
42890         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42892         FixedPenaltyScorer_free(this_obj_conv);
42893 }
42894
42895 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
42896         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
42897 int64_t ret_ref = 0;
42898 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42899 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42900 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42901 ret_ref = (uintptr_t)ret_var.inner;
42902 if (ret_var.is_owned) {
42903         ret_ref |= 1;
42904 }
42905         return ret_ref;
42906 }
42907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42908         LDKFixedPenaltyScorer arg_conv;
42909         arg_conv.inner = (void*)(arg & (~1));
42910         arg_conv.is_owned = false;
42911         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42912         int64_t ret_val = FixedPenaltyScorer_clone_ptr(&arg_conv);
42913         return ret_val;
42914 }
42915
42916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42917         LDKFixedPenaltyScorer orig_conv;
42918         orig_conv.inner = (void*)(orig & (~1));
42919         orig_conv.is_owned = false;
42920         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42921         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
42922         int64_t ret_ref = 0;
42923         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42924         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42926         ret_ref = (uintptr_t)ret_var.inner;
42927         if (ret_var.is_owned) {
42928                 ret_ref |= 1;
42929         }
42930         return ret_ref;
42931 }
42932
42933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
42934         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
42935         int64_t ret_ref = 0;
42936         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42937         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42939         ret_ref = (uintptr_t)ret_var.inner;
42940         if (ret_var.is_owned) {
42941                 ret_ref |= 1;
42942         }
42943         return ret_ref;
42944 }
42945
42946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
42947         LDKFixedPenaltyScorer this_arg_conv;
42948         this_arg_conv.inner = (void*)(this_arg & (~1));
42949         this_arg_conv.is_owned = false;
42950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42951         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
42952         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
42953         return (int64_t)ret_ret;
42954 }
42955
42956 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
42957         LDKFixedPenaltyScorer obj_conv;
42958         obj_conv.inner = (void*)(obj & (~1));
42959         obj_conv.is_owned = false;
42960         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42961         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
42962         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42963         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42964         CVec_u8Z_free(ret_var);
42965         return ret_arr;
42966 }
42967
42968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
42969         LDKu8slice ser_ref;
42970         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42971         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42972         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
42973         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
42974         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42975         return (int64_t)ret_conv;
42976 }
42977
42978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Scorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42979         LDKScorer this_obj_conv;
42980         this_obj_conv.inner = (void*)(this_obj & (~1));
42981         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42983         Scorer_free(this_obj_conv);
42984 }
42985
42986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42987         LDKScoringParameters this_obj_conv;
42988         this_obj_conv.inner = (void*)(this_obj & (~1));
42989         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42991         ScoringParameters_free(this_obj_conv);
42992 }
42993
42994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42995         LDKScoringParameters this_ptr_conv;
42996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42997         this_ptr_conv.is_owned = false;
42998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42999         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
43000         return ret_val;
43001 }
43002
43003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43004         LDKScoringParameters this_ptr_conv;
43005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43006         this_ptr_conv.is_owned = false;
43007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43008         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
43009 }
43010
43011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43012         LDKScoringParameters this_ptr_conv;
43013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43014         this_ptr_conv.is_owned = false;
43015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43016         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
43017         return ret_val;
43018 }
43019
43020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43021         LDKScoringParameters this_ptr_conv;
43022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43023         this_ptr_conv.is_owned = false;
43024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43025         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
43026 }
43027
43028 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1overuse_1penalty_1start_11024th(JNIEnv *env, jclass clz, int64_t this_ptr) {
43029         LDKScoringParameters this_ptr_conv;
43030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43031         this_ptr_conv.is_owned = false;
43032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43033         int16_t ret_val = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
43034         return ret_val;
43035 }
43036
43037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1overuse_1penalty_1start_11024th(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
43038         LDKScoringParameters this_ptr_conv;
43039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43040         this_ptr_conv.is_owned = false;
43041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43042         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
43043 }
43044
43045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1overuse_1penalty_1msat_1per_11024th(JNIEnv *env, jclass clz, int64_t this_ptr) {
43046         LDKScoringParameters this_ptr_conv;
43047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43048         this_ptr_conv.is_owned = false;
43049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43050         int64_t ret_val = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
43051         return ret_val;
43052 }
43053
43054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1overuse_1penalty_1msat_1per_11024th(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43055         LDKScoringParameters this_ptr_conv;
43056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43057         this_ptr_conv.is_owned = false;
43058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43059         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
43060 }
43061
43062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
43063         LDKScoringParameters this_ptr_conv;
43064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43065         this_ptr_conv.is_owned = false;
43066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43067         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
43068         return ret_val;
43069 }
43070
43071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43072         LDKScoringParameters this_ptr_conv;
43073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43074         this_ptr_conv.is_owned = false;
43075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43076         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
43077 }
43078
43079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1new(JNIEnv *env, jclass clz, int64_t base_penalty_msat_arg, int64_t failure_penalty_msat_arg, int16_t overuse_penalty_start_1024th_arg, int64_t overuse_penalty_msat_per_1024th_arg, int64_t failure_penalty_half_life_arg) {
43080         LDKScoringParameters ret_var = ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, overuse_penalty_start_1024th_arg, overuse_penalty_msat_per_1024th_arg, failure_penalty_half_life_arg);
43081         int64_t ret_ref = 0;
43082         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43083         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43085         ret_ref = (uintptr_t)ret_var.inner;
43086         if (ret_var.is_owned) {
43087                 ret_ref |= 1;
43088         }
43089         return ret_ref;
43090 }
43091
43092 static inline uintptr_t ScoringParameters_clone_ptr(LDKScoringParameters *NONNULL_PTR arg) {
43093         LDKScoringParameters ret_var = ScoringParameters_clone(arg);
43094 int64_t ret_ref = 0;
43095 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43096 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43097 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43098 ret_ref = (uintptr_t)ret_var.inner;
43099 if (ret_var.is_owned) {
43100         ret_ref |= 1;
43101 }
43102         return ret_ref;
43103 }
43104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43105         LDKScoringParameters arg_conv;
43106         arg_conv.inner = (void*)(arg & (~1));
43107         arg_conv.is_owned = false;
43108         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43109         int64_t ret_val = ScoringParameters_clone_ptr(&arg_conv);
43110         return ret_val;
43111 }
43112
43113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43114         LDKScoringParameters orig_conv;
43115         orig_conv.inner = (void*)(orig & (~1));
43116         orig_conv.is_owned = false;
43117         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43118         LDKScoringParameters ret_var = ScoringParameters_clone(&orig_conv);
43119         int64_t ret_ref = 0;
43120         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43121         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43123         ret_ref = (uintptr_t)ret_var.inner;
43124         if (ret_var.is_owned) {
43125                 ret_ref |= 1;
43126         }
43127         return ret_ref;
43128 }
43129
43130 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
43131         LDKScoringParameters obj_conv;
43132         obj_conv.inner = (void*)(obj & (~1));
43133         obj_conv.is_owned = false;
43134         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43135         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
43136         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43137         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43138         CVec_u8Z_free(ret_var);
43139         return ret_arr;
43140 }
43141
43142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43143         LDKu8slice ser_ref;
43144         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43145         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43146         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
43147         *ret_conv = ScoringParameters_read(ser_ref);
43148         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43149         return (int64_t)ret_conv;
43150 }
43151
43152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1new(JNIEnv *env, jclass clz, int64_t params) {
43153         LDKScoringParameters params_conv;
43154         params_conv.inner = (void*)(params & (~1));
43155         params_conv.is_owned = (params & 1) || (params == 0);
43156         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
43157         params_conv = ScoringParameters_clone(&params_conv);
43158         LDKScorer ret_var = Scorer_new(params_conv);
43159         int64_t ret_ref = 0;
43160         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43161         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43162         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43163         ret_ref = (uintptr_t)ret_var.inner;
43164         if (ret_var.is_owned) {
43165                 ret_ref |= 1;
43166         }
43167         return ret_ref;
43168 }
43169
43170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1default(JNIEnv *env, jclass clz) {
43171         LDKScorer ret_var = Scorer_default();
43172         int64_t ret_ref = 0;
43173         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43174         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43176         ret_ref = (uintptr_t)ret_var.inner;
43177         if (ret_var.is_owned) {
43178                 ret_ref |= 1;
43179         }
43180         return ret_ref;
43181 }
43182
43183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1default(JNIEnv *env, jclass clz) {
43184         LDKScoringParameters ret_var = ScoringParameters_default();
43185         int64_t ret_ref = 0;
43186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43189         ret_ref = (uintptr_t)ret_var.inner;
43190         if (ret_var.is_owned) {
43191                 ret_ref |= 1;
43192         }
43193         return ret_ref;
43194 }
43195
43196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
43197         LDKScorer this_arg_conv;
43198         this_arg_conv.inner = (void*)(this_arg & (~1));
43199         this_arg_conv.is_owned = false;
43200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43201         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
43202         *ret_ret = Scorer_as_Score(&this_arg_conv);
43203         return (int64_t)ret_ret;
43204 }
43205
43206 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Scorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
43207         LDKScorer obj_conv;
43208         obj_conv.inner = (void*)(obj & (~1));
43209         obj_conv.is_owned = false;
43210         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43211         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
43212         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43213         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43214         CVec_u8Z_free(ret_var);
43215         return ret_arr;
43216 }
43217
43218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43219         LDKu8slice ser_ref;
43220         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43221         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43222         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
43223         *ret_conv = Scorer_read(ser_ref);
43224         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43225         return (int64_t)ret_conv;
43226 }
43227
43228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43229         LDKProbabilisticScorer this_obj_conv;
43230         this_obj_conv.inner = (void*)(this_obj & (~1));
43231         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43233         ProbabilisticScorer_free(this_obj_conv);
43234 }
43235
43236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43237         LDKProbabilisticScoringParameters this_obj_conv;
43238         this_obj_conv.inner = (void*)(this_obj & (~1));
43239         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43241         ProbabilisticScoringParameters_free(this_obj_conv);
43242 }
43243
43244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43245         LDKProbabilisticScoringParameters this_ptr_conv;
43246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43247         this_ptr_conv.is_owned = false;
43248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43249         int64_t ret_val = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
43250         return ret_val;
43251 }
43252
43253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43254         LDKProbabilisticScoringParameters this_ptr_conv;
43255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43256         this_ptr_conv.is_owned = false;
43257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43258         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
43259 }
43260
43261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43262         LDKProbabilisticScoringParameters this_ptr_conv;
43263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43264         this_ptr_conv.is_owned = false;
43265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43266         int64_t ret_val = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
43267         return ret_val;
43268 }
43269
43270 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) {
43271         LDKProbabilisticScoringParameters this_ptr_conv;
43272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43273         this_ptr_conv.is_owned = false;
43274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43275         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
43276 }
43277
43278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
43279         LDKProbabilisticScoringParameters this_ptr_conv;
43280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43281         this_ptr_conv.is_owned = false;
43282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43283         int64_t ret_val = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
43284         return ret_val;
43285 }
43286
43287 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) {
43288         LDKProbabilisticScoringParameters this_ptr_conv;
43289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43290         this_ptr_conv.is_owned = false;
43291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43292         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
43293 }
43294
43295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1amount_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43296         LDKProbabilisticScoringParameters this_ptr_conv;
43297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43298         this_ptr_conv.is_owned = false;
43299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43300         int64_t ret_val = ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(&this_ptr_conv);
43301         return ret_val;
43302 }
43303
43304 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) {
43305         LDKProbabilisticScoringParameters this_ptr_conv;
43306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43307         this_ptr_conv.is_owned = false;
43308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43309         ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(&this_ptr_conv, val);
43310 }
43311
43312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1new(JNIEnv *env, jclass clz, int64_t base_penalty_msat_arg, int64_t liquidity_penalty_multiplier_msat_arg, int64_t liquidity_offset_half_life_arg, int64_t amount_penalty_multiplier_msat_arg) {
43313         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_new(base_penalty_msat_arg, liquidity_penalty_multiplier_msat_arg, liquidity_offset_half_life_arg, amount_penalty_multiplier_msat_arg);
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 ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
43326         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_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_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43338         LDKProbabilisticScoringParameters 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_val = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
43343         return ret_val;
43344 }
43345
43346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43347         LDKProbabilisticScoringParameters 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         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_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 int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1new(JNIEnv *env, jclass clz, int64_t params, int64_t network_graph) {
43364         LDKProbabilisticScoringParameters params_conv;
43365         params_conv.inner = (void*)(params & (~1));
43366         params_conv.is_owned = (params & 1) || (params == 0);
43367         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
43368         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
43369         LDKNetworkGraph network_graph_conv;
43370         network_graph_conv.inner = (void*)(network_graph & (~1));
43371         network_graph_conv.is_owned = false;
43372         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
43373         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv);
43374         int64_t ret_ref = 0;
43375         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43376         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43378         ret_ref = (uintptr_t)ret_var.inner;
43379         if (ret_var.is_owned) {
43380                 ret_ref |= 1;
43381         }
43382         return ret_ref;
43383 }
43384
43385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
43386         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
43387         int64_t ret_ref = 0;
43388         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43389         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43391         ret_ref = (uintptr_t)ret_var.inner;
43392         if (ret_var.is_owned) {
43393                 ret_ref |= 1;
43394         }
43395         return ret_ref;
43396 }
43397
43398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
43399         LDKProbabilisticScorer this_arg_conv;
43400         this_arg_conv.inner = (void*)(this_arg & (~1));
43401         this_arg_conv.is_owned = false;
43402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43403         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
43404         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
43405         return (int64_t)ret_ret;
43406 }
43407
43408 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
43409         LDKProbabilisticScorer obj_conv;
43410         obj_conv.inner = (void*)(obj & (~1));
43411         obj_conv.is_owned = false;
43412         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43413         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
43414         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43415         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43416         CVec_u8Z_free(ret_var);
43417         return ret_arr;
43418 }
43419
43420 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) {
43421         LDKu8slice ser_ref;
43422         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43423         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43424         LDKProbabilisticScoringParameters arg_a_conv;
43425         arg_a_conv.inner = (void*)(arg_a & (~1));
43426         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
43427         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
43428         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
43429         LDKNetworkGraph arg_b_conv;
43430         arg_b_conv.inner = (void*)(arg_b & (~1));
43431         arg_b_conv.is_owned = false;
43432         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
43433         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
43434         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv);
43435         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43436         return (int64_t)ret_conv;
43437 }
43438
43439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43440         LDKFilesystemPersister this_obj_conv;
43441         this_obj_conv.inner = (void*)(this_obj & (~1));
43442         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43444         FilesystemPersister_free(this_obj_conv);
43445 }
43446
43447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
43448         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
43449         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
43450         int64_t ret_ref = 0;
43451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43454         ret_ref = (uintptr_t)ret_var.inner;
43455         if (ret_var.is_owned) {
43456                 ret_ref |= 1;
43457         }
43458         return ret_ref;
43459 }
43460
43461 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
43462         LDKFilesystemPersister this_arg_conv;
43463         this_arg_conv.inner = (void*)(this_arg & (~1));
43464         this_arg_conv.is_owned = false;
43465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43466         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
43467         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
43468         Str_free(ret_str);
43469         return ret_conv;
43470 }
43471
43472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
43473         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
43474         LDKChannelManager manager_conv;
43475         manager_conv.inner = (void*)(manager & (~1));
43476         manager_conv.is_owned = false;
43477         CHECK_INNER_FIELD_ACCESS_OR_NULL(manager_conv);
43478         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
43479         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
43480         return (int64_t)ret_conv;
43481 }
43482
43483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1network_1graph(JNIEnv *env, jclass clz, jstring data_dir, int64_t network_graph) {
43484         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
43485         LDKNetworkGraph network_graph_conv;
43486         network_graph_conv.inner = (void*)(network_graph & (~1));
43487         network_graph_conv.is_owned = false;
43488         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
43489         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
43490         *ret_conv = FilesystemPersister_persist_network_graph(data_dir_conv, &network_graph_conv);
43491         return (int64_t)ret_conv;
43492 }
43493
43494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
43495         LDKFilesystemPersister this_arg_conv;
43496         this_arg_conv.inner = (void*)(this_arg & (~1));
43497         this_arg_conv.is_owned = false;
43498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43499         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
43500         CHECK_ACCESS(keys_manager_ptr);
43501         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
43502         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
43503                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43504                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
43505         }
43506         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
43507         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
43508         return (int64_t)ret_conv;
43509 }
43510
43511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
43512         LDKFilesystemPersister this_arg_conv;
43513         this_arg_conv.inner = (void*)(this_arg & (~1));
43514         this_arg_conv.is_owned = false;
43515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43516         LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
43517         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
43518         return (int64_t)ret_ret;
43519 }
43520
43521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43522         LDKBackgroundProcessor this_obj_conv;
43523         this_obj_conv.inner = (void*)(this_obj & (~1));
43524         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43526         BackgroundProcessor_free(this_obj_conv);
43527 }
43528
43529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43530         if ((this_ptr & 1) != 0) return;
43531         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43532         CHECK_ACCESS(this_ptr_ptr);
43533         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
43534         FREE((void*)this_ptr);
43535         Persister_free(this_ptr_conv);
43536 }
43537
43538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(JNIEnv *env, jclass clz, int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t net_graph_msg_handler, int64_t peer_manager, int64_t logger) {
43539         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
43540         CHECK_ACCESS(persister_ptr);
43541         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
43542         if (persister_conv.free == LDKPersister_JCalls_free) {
43543                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43544                 LDKPersister_JCalls_cloned(&persister_conv);
43545         }
43546         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
43547         CHECK_ACCESS(event_handler_ptr);
43548         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
43549         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
43550                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43551                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
43552         }
43553         LDKChainMonitor chain_monitor_conv;
43554         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
43555         chain_monitor_conv.is_owned = false;
43556         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
43557         LDKChannelManager channel_manager_conv;
43558         channel_manager_conv.inner = (void*)(channel_manager & (~1));
43559         channel_manager_conv.is_owned = false;
43560         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
43561         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
43562         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
43563         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
43564         CHECK_INNER_FIELD_ACCESS_OR_NULL(net_graph_msg_handler_conv);
43565         LDKPeerManager peer_manager_conv;
43566         peer_manager_conv.inner = (void*)(peer_manager & (~1));
43567         peer_manager_conv.is_owned = false;
43568         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
43569         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
43570         CHECK_ACCESS(logger_ptr);
43571         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
43572         if (logger_conv.free == LDKLogger_JCalls_free) {
43573                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43574                 LDKLogger_JCalls_cloned(&logger_conv);
43575         }
43576         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, net_graph_msg_handler_conv, &peer_manager_conv, logger_conv);
43577         int64_t ret_ref = 0;
43578         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43579         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43581         ret_ref = (uintptr_t)ret_var.inner;
43582         if (ret_var.is_owned) {
43583                 ret_ref |= 1;
43584         }
43585         return ret_ref;
43586 }
43587
43588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
43589         LDKBackgroundProcessor this_arg_conv;
43590         this_arg_conv.inner = (void*)(this_arg & (~1));
43591         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
43592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43593         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
43594         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
43595         *ret_conv = BackgroundProcessor_join(this_arg_conv);
43596         return (int64_t)ret_conv;
43597 }
43598
43599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
43600         LDKBackgroundProcessor this_arg_conv;
43601         this_arg_conv.inner = (void*)(this_arg & (~1));
43602         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
43603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43604         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
43605         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
43606         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
43607         return (int64_t)ret_conv;
43608 }
43609
43610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43611         if ((this_ptr & 1) != 0) return;
43612         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43613         CHECK_ACCESS(this_ptr_ptr);
43614         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
43615         FREE((void*)this_ptr);
43616         ParseError_free(this_ptr_conv);
43617 }
43618
43619 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
43620         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43621         *ret_copy = ParseError_clone(arg);
43622 int64_t ret_ref = (uintptr_t)ret_copy;
43623         return ret_ref;
43624 }
43625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43626         LDKParseError* arg_conv = (LDKParseError*)arg;
43627         int64_t ret_val = ParseError_clone_ptr(arg_conv);
43628         return ret_val;
43629 }
43630
43631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43632         LDKParseError* orig_conv = (LDKParseError*)orig;
43633         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43634         *ret_copy = ParseError_clone(orig_conv);
43635         int64_t ret_ref = (uintptr_t)ret_copy;
43636         return ret_ref;
43637 }
43638
43639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
43640         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
43641         CHECK_ACCESS(a_ptr);
43642         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
43643         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
43644         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43645         *ret_copy = ParseError_bech32_error(a_conv);
43646         int64_t ret_ref = (uintptr_t)ret_copy;
43647         return ret_ref;
43648 }
43649
43650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
43651         
43652         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43653         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
43654         int64_t ret_ref = (uintptr_t)ret_copy;
43655         return ret_ref;
43656 }
43657
43658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
43659         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
43660         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43661         *ret_copy = ParseError_malformed_signature(a_conv);
43662         int64_t ret_ref = (uintptr_t)ret_copy;
43663         return ret_ref;
43664 }
43665
43666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
43667         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43668         *ret_copy = ParseError_bad_prefix();
43669         int64_t ret_ref = (uintptr_t)ret_copy;
43670         return ret_ref;
43671 }
43672
43673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
43674         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43675         *ret_copy = ParseError_unknown_currency();
43676         int64_t ret_ref = (uintptr_t)ret_copy;
43677         return ret_ref;
43678 }
43679
43680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
43681         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43682         *ret_copy = ParseError_unknown_si_prefix();
43683         int64_t ret_ref = (uintptr_t)ret_copy;
43684         return ret_ref;
43685 }
43686
43687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
43688         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43689         *ret_copy = ParseError_malformed_hrp();
43690         int64_t ret_ref = (uintptr_t)ret_copy;
43691         return ret_ref;
43692 }
43693
43694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
43695         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43696         *ret_copy = ParseError_too_short_data_part();
43697         int64_t ret_ref = (uintptr_t)ret_copy;
43698         return ret_ref;
43699 }
43700
43701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
43702         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43703         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
43704         int64_t ret_ref = (uintptr_t)ret_copy;
43705         return ret_ref;
43706 }
43707
43708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
43709         
43710         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43711         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
43712         int64_t ret_ref = (uintptr_t)ret_copy;
43713         return ret_ref;
43714 }
43715
43716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
43717         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43718         *ret_copy = ParseError_padding_error();
43719         int64_t ret_ref = (uintptr_t)ret_copy;
43720         return ret_ref;
43721 }
43722
43723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
43724         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43725         *ret_copy = ParseError_integer_overflow_error();
43726         int64_t ret_ref = (uintptr_t)ret_copy;
43727         return ret_ref;
43728 }
43729
43730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
43731         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43732         *ret_copy = ParseError_invalid_seg_wit_program_length();
43733         int64_t ret_ref = (uintptr_t)ret_copy;
43734         return ret_ref;
43735 }
43736
43737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
43738         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43739         *ret_copy = ParseError_invalid_pub_key_hash_length();
43740         int64_t ret_ref = (uintptr_t)ret_copy;
43741         return ret_ref;
43742 }
43743
43744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
43745         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43746         *ret_copy = ParseError_invalid_script_hash_length();
43747         int64_t ret_ref = (uintptr_t)ret_copy;
43748         return ret_ref;
43749 }
43750
43751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
43752         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43753         *ret_copy = ParseError_invalid_recovery_id();
43754         int64_t ret_ref = (uintptr_t)ret_copy;
43755         return ret_ref;
43756 }
43757
43758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
43759         LDKStr a_conv = java_to_owned_str(env, a);
43760         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43761         *ret_copy = ParseError_invalid_slice_length(a_conv);
43762         int64_t ret_ref = (uintptr_t)ret_copy;
43763         return ret_ref;
43764 }
43765
43766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
43767         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43768         *ret_copy = ParseError_skip();
43769         int64_t ret_ref = (uintptr_t)ret_copy;
43770         return ret_ref;
43771 }
43772
43773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43774         if ((this_ptr & 1) != 0) return;
43775         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43776         CHECK_ACCESS(this_ptr_ptr);
43777         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
43778         FREE((void*)this_ptr);
43779         ParseOrSemanticError_free(this_ptr_conv);
43780 }
43781
43782 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
43783         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43784         *ret_copy = ParseOrSemanticError_clone(arg);
43785 int64_t ret_ref = (uintptr_t)ret_copy;
43786         return ret_ref;
43787 }
43788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43789         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
43790         int64_t ret_val = ParseOrSemanticError_clone_ptr(arg_conv);
43791         return ret_val;
43792 }
43793
43794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43795         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
43796         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43797         *ret_copy = ParseOrSemanticError_clone(orig_conv);
43798         int64_t ret_ref = (uintptr_t)ret_copy;
43799         return ret_ref;
43800 }
43801
43802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
43803         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
43804         CHECK_ACCESS(a_ptr);
43805         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
43806         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
43807         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43808         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
43809         int64_t ret_ref = (uintptr_t)ret_copy;
43810         return ret_ref;
43811 }
43812
43813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
43814         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
43815         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43816         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
43817         int64_t ret_ref = (uintptr_t)ret_copy;
43818         return ret_ref;
43819 }
43820
43821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43822         LDKInvoice this_obj_conv;
43823         this_obj_conv.inner = (void*)(this_obj & (~1));
43824         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43826         Invoice_free(this_obj_conv);
43827 }
43828
43829 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43830         LDKInvoice a_conv;
43831         a_conv.inner = (void*)(a & (~1));
43832         a_conv.is_owned = false;
43833         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43834         LDKInvoice b_conv;
43835         b_conv.inner = (void*)(b & (~1));
43836         b_conv.is_owned = false;
43837         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43838         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
43839         return ret_val;
43840 }
43841
43842 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
43843         LDKInvoice ret_var = Invoice_clone(arg);
43844 int64_t ret_ref = 0;
43845 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43846 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43847 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43848 ret_ref = (uintptr_t)ret_var.inner;
43849 if (ret_var.is_owned) {
43850         ret_ref |= 1;
43851 }
43852         return ret_ref;
43853 }
43854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43855         LDKInvoice arg_conv;
43856         arg_conv.inner = (void*)(arg & (~1));
43857         arg_conv.is_owned = false;
43858         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43859         int64_t ret_val = Invoice_clone_ptr(&arg_conv);
43860         return ret_val;
43861 }
43862
43863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43864         LDKInvoice orig_conv;
43865         orig_conv.inner = (void*)(orig & (~1));
43866         orig_conv.is_owned = false;
43867         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43868         LDKInvoice ret_var = Invoice_clone(&orig_conv);
43869         int64_t ret_ref = 0;
43870         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43871         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43873         ret_ref = (uintptr_t)ret_var.inner;
43874         if (ret_var.is_owned) {
43875                 ret_ref |= 1;
43876         }
43877         return ret_ref;
43878 }
43879
43880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43881         LDKSignedRawInvoice this_obj_conv;
43882         this_obj_conv.inner = (void*)(this_obj & (~1));
43883         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43885         SignedRawInvoice_free(this_obj_conv);
43886 }
43887
43888 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43889         LDKSignedRawInvoice a_conv;
43890         a_conv.inner = (void*)(a & (~1));
43891         a_conv.is_owned = false;
43892         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43893         LDKSignedRawInvoice b_conv;
43894         b_conv.inner = (void*)(b & (~1));
43895         b_conv.is_owned = false;
43896         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43897         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
43898         return ret_val;
43899 }
43900
43901 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
43902         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
43903 int64_t ret_ref = 0;
43904 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43905 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43906 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43907 ret_ref = (uintptr_t)ret_var.inner;
43908 if (ret_var.is_owned) {
43909         ret_ref |= 1;
43910 }
43911         return ret_ref;
43912 }
43913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43914         LDKSignedRawInvoice arg_conv;
43915         arg_conv.inner = (void*)(arg & (~1));
43916         arg_conv.is_owned = false;
43917         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43918         int64_t ret_val = SignedRawInvoice_clone_ptr(&arg_conv);
43919         return ret_val;
43920 }
43921
43922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43923         LDKSignedRawInvoice orig_conv;
43924         orig_conv.inner = (void*)(orig & (~1));
43925         orig_conv.is_owned = false;
43926         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43927         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
43928         int64_t ret_ref = 0;
43929         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43930         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43932         ret_ref = (uintptr_t)ret_var.inner;
43933         if (ret_var.is_owned) {
43934                 ret_ref |= 1;
43935         }
43936         return ret_ref;
43937 }
43938
43939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43940         LDKRawInvoice this_obj_conv;
43941         this_obj_conv.inner = (void*)(this_obj & (~1));
43942         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43944         RawInvoice_free(this_obj_conv);
43945 }
43946
43947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
43948         LDKRawInvoice this_ptr_conv;
43949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43950         this_ptr_conv.is_owned = false;
43951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43952         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
43953         int64_t ret_ref = 0;
43954         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43955         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43957         ret_ref = (uintptr_t)ret_var.inner;
43958         if (ret_var.is_owned) {
43959                 ret_ref |= 1;
43960         }
43961         return ret_ref;
43962 }
43963
43964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43965         LDKRawInvoice this_ptr_conv;
43966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43967         this_ptr_conv.is_owned = false;
43968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43969         LDKRawDataPart val_conv;
43970         val_conv.inner = (void*)(val & (~1));
43971         val_conv.is_owned = (val & 1) || (val == 0);
43972         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43973         val_conv = RawDataPart_clone(&val_conv);
43974         RawInvoice_set_data(&this_ptr_conv, val_conv);
43975 }
43976
43977 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43978         LDKRawInvoice a_conv;
43979         a_conv.inner = (void*)(a & (~1));
43980         a_conv.is_owned = false;
43981         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43982         LDKRawInvoice b_conv;
43983         b_conv.inner = (void*)(b & (~1));
43984         b_conv.is_owned = false;
43985         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43986         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
43987         return ret_val;
43988 }
43989
43990 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
43991         LDKRawInvoice ret_var = RawInvoice_clone(arg);
43992 int64_t ret_ref = 0;
43993 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43994 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43995 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43996 ret_ref = (uintptr_t)ret_var.inner;
43997 if (ret_var.is_owned) {
43998         ret_ref |= 1;
43999 }
44000         return ret_ref;
44001 }
44002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44003         LDKRawInvoice arg_conv;
44004         arg_conv.inner = (void*)(arg & (~1));
44005         arg_conv.is_owned = false;
44006         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44007         int64_t ret_val = RawInvoice_clone_ptr(&arg_conv);
44008         return ret_val;
44009 }
44010
44011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44012         LDKRawInvoice orig_conv;
44013         orig_conv.inner = (void*)(orig & (~1));
44014         orig_conv.is_owned = false;
44015         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44016         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
44017         int64_t ret_ref = 0;
44018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44021         ret_ref = (uintptr_t)ret_var.inner;
44022         if (ret_var.is_owned) {
44023                 ret_ref |= 1;
44024         }
44025         return ret_ref;
44026 }
44027
44028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44029         LDKRawDataPart this_obj_conv;
44030         this_obj_conv.inner = (void*)(this_obj & (~1));
44031         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44033         RawDataPart_free(this_obj_conv);
44034 }
44035
44036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
44037         LDKRawDataPart this_ptr_conv;
44038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44039         this_ptr_conv.is_owned = false;
44040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44041         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
44042         int64_t ret_ref = 0;
44043         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44044         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44046         ret_ref = (uintptr_t)ret_var.inner;
44047         if (ret_var.is_owned) {
44048                 ret_ref |= 1;
44049         }
44050         return ret_ref;
44051 }
44052
44053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44054         LDKRawDataPart this_ptr_conv;
44055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44056         this_ptr_conv.is_owned = false;
44057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44058         LDKPositiveTimestamp val_conv;
44059         val_conv.inner = (void*)(val & (~1));
44060         val_conv.is_owned = (val & 1) || (val == 0);
44061         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44062         val_conv = PositiveTimestamp_clone(&val_conv);
44063         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
44064 }
44065
44066 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44067         LDKRawDataPart a_conv;
44068         a_conv.inner = (void*)(a & (~1));
44069         a_conv.is_owned = false;
44070         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44071         LDKRawDataPart b_conv;
44072         b_conv.inner = (void*)(b & (~1));
44073         b_conv.is_owned = false;
44074         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44075         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
44076         return ret_val;
44077 }
44078
44079 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
44080         LDKRawDataPart ret_var = RawDataPart_clone(arg);
44081 int64_t ret_ref = 0;
44082 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44083 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44084 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44085 ret_ref = (uintptr_t)ret_var.inner;
44086 if (ret_var.is_owned) {
44087         ret_ref |= 1;
44088 }
44089         return ret_ref;
44090 }
44091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44092         LDKRawDataPart arg_conv;
44093         arg_conv.inner = (void*)(arg & (~1));
44094         arg_conv.is_owned = false;
44095         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44096         int64_t ret_val = RawDataPart_clone_ptr(&arg_conv);
44097         return ret_val;
44098 }
44099
44100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44101         LDKRawDataPart orig_conv;
44102         orig_conv.inner = (void*)(orig & (~1));
44103         orig_conv.is_owned = false;
44104         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44105         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
44106         int64_t ret_ref = 0;
44107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44110         ret_ref = (uintptr_t)ret_var.inner;
44111         if (ret_var.is_owned) {
44112                 ret_ref |= 1;
44113         }
44114         return ret_ref;
44115 }
44116
44117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44118         LDKPositiveTimestamp this_obj_conv;
44119         this_obj_conv.inner = (void*)(this_obj & (~1));
44120         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44122         PositiveTimestamp_free(this_obj_conv);
44123 }
44124
44125 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44126         LDKPositiveTimestamp a_conv;
44127         a_conv.inner = (void*)(a & (~1));
44128         a_conv.is_owned = false;
44129         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44130         LDKPositiveTimestamp b_conv;
44131         b_conv.inner = (void*)(b & (~1));
44132         b_conv.is_owned = false;
44133         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44134         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
44135         return ret_val;
44136 }
44137
44138 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
44139         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
44140 int64_t ret_ref = 0;
44141 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44142 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44143 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44144 ret_ref = (uintptr_t)ret_var.inner;
44145 if (ret_var.is_owned) {
44146         ret_ref |= 1;
44147 }
44148         return ret_ref;
44149 }
44150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44151         LDKPositiveTimestamp arg_conv;
44152         arg_conv.inner = (void*)(arg & (~1));
44153         arg_conv.is_owned = false;
44154         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44155         int64_t ret_val = PositiveTimestamp_clone_ptr(&arg_conv);
44156         return ret_val;
44157 }
44158
44159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44160         LDKPositiveTimestamp orig_conv;
44161         orig_conv.inner = (void*)(orig & (~1));
44162         orig_conv.is_owned = false;
44163         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44164         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
44165         int64_t ret_ref = 0;
44166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44169         ret_ref = (uintptr_t)ret_var.inner;
44170         if (ret_var.is_owned) {
44171                 ret_ref |= 1;
44172         }
44173         return ret_ref;
44174 }
44175
44176 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44177         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
44178         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
44179         return ret_conv;
44180 }
44181
44182 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
44183         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
44184         return ret_conv;
44185 }
44186
44187 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
44188         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
44189         return ret_conv;
44190 }
44191
44192 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
44193         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
44194         return ret_conv;
44195 }
44196
44197 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
44198         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
44199         return ret_conv;
44200 }
44201
44202 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44203         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
44204         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
44205         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
44206         return ret_val;
44207 }
44208
44209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
44210         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
44211         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
44212         return ret_val;
44213 }
44214
44215 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44216         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
44217         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
44218         return ret_conv;
44219 }
44220
44221 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
44222         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
44223         return ret_conv;
44224 }
44225
44226 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
44227         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
44228         return ret_conv;
44229 }
44230
44231 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
44232         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
44233         return ret_conv;
44234 }
44235
44236 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
44237         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
44238         return ret_conv;
44239 }
44240
44241 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
44242         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
44243         return ret_conv;
44244 }
44245
44246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
44247         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
44248         int64_t ret_val = Currency_hash(o_conv);
44249         return ret_val;
44250 }
44251
44252 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44253         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
44254         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
44255         jboolean ret_val = Currency_eq(a_conv, b_conv);
44256         return ret_val;
44257 }
44258
44259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44260         LDKSha256 this_obj_conv;
44261         this_obj_conv.inner = (void*)(this_obj & (~1));
44262         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44264         Sha256_free(this_obj_conv);
44265 }
44266
44267 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
44268         LDKSha256 ret_var = Sha256_clone(arg);
44269 int64_t ret_ref = 0;
44270 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44271 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44272 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44273 ret_ref = (uintptr_t)ret_var.inner;
44274 if (ret_var.is_owned) {
44275         ret_ref |= 1;
44276 }
44277         return ret_ref;
44278 }
44279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44280         LDKSha256 arg_conv;
44281         arg_conv.inner = (void*)(arg & (~1));
44282         arg_conv.is_owned = false;
44283         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44284         int64_t ret_val = Sha256_clone_ptr(&arg_conv);
44285         return ret_val;
44286 }
44287
44288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44289         LDKSha256 orig_conv;
44290         orig_conv.inner = (void*)(orig & (~1));
44291         orig_conv.is_owned = false;
44292         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44293         LDKSha256 ret_var = Sha256_clone(&orig_conv);
44294         int64_t ret_ref = 0;
44295         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44296         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44298         ret_ref = (uintptr_t)ret_var.inner;
44299         if (ret_var.is_owned) {
44300                 ret_ref |= 1;
44301         }
44302         return ret_ref;
44303 }
44304
44305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
44306         LDKSha256 o_conv;
44307         o_conv.inner = (void*)(o & (~1));
44308         o_conv.is_owned = false;
44309         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44310         int64_t ret_val = Sha256_hash(&o_conv);
44311         return ret_val;
44312 }
44313
44314 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44315         LDKSha256 a_conv;
44316         a_conv.inner = (void*)(a & (~1));
44317         a_conv.is_owned = false;
44318         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44319         LDKSha256 b_conv;
44320         b_conv.inner = (void*)(b & (~1));
44321         b_conv.is_owned = false;
44322         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44323         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
44324         return ret_val;
44325 }
44326
44327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44328         LDKDescription this_obj_conv;
44329         this_obj_conv.inner = (void*)(this_obj & (~1));
44330         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44332         Description_free(this_obj_conv);
44333 }
44334
44335 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
44336         LDKDescription ret_var = Description_clone(arg);
44337 int64_t ret_ref = 0;
44338 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44339 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44340 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44341 ret_ref = (uintptr_t)ret_var.inner;
44342 if (ret_var.is_owned) {
44343         ret_ref |= 1;
44344 }
44345         return ret_ref;
44346 }
44347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44348         LDKDescription arg_conv;
44349         arg_conv.inner = (void*)(arg & (~1));
44350         arg_conv.is_owned = false;
44351         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44352         int64_t ret_val = Description_clone_ptr(&arg_conv);
44353         return ret_val;
44354 }
44355
44356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44357         LDKDescription orig_conv;
44358         orig_conv.inner = (void*)(orig & (~1));
44359         orig_conv.is_owned = false;
44360         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44361         LDKDescription ret_var = Description_clone(&orig_conv);
44362         int64_t ret_ref = 0;
44363         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44364         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44366         ret_ref = (uintptr_t)ret_var.inner;
44367         if (ret_var.is_owned) {
44368                 ret_ref |= 1;
44369         }
44370         return ret_ref;
44371 }
44372
44373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
44374         LDKDescription o_conv;
44375         o_conv.inner = (void*)(o & (~1));
44376         o_conv.is_owned = false;
44377         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44378         int64_t ret_val = Description_hash(&o_conv);
44379         return ret_val;
44380 }
44381
44382 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44383         LDKDescription a_conv;
44384         a_conv.inner = (void*)(a & (~1));
44385         a_conv.is_owned = false;
44386         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44387         LDKDescription b_conv;
44388         b_conv.inner = (void*)(b & (~1));
44389         b_conv.is_owned = false;
44390         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44391         jboolean ret_val = Description_eq(&a_conv, &b_conv);
44392         return ret_val;
44393 }
44394
44395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44396         LDKPayeePubKey this_obj_conv;
44397         this_obj_conv.inner = (void*)(this_obj & (~1));
44398         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44400         PayeePubKey_free(this_obj_conv);
44401 }
44402
44403 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
44404         LDKPayeePubKey this_ptr_conv;
44405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44406         this_ptr_conv.is_owned = false;
44407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44408         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44409         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
44410         return ret_arr;
44411 }
44412
44413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44414         LDKPayeePubKey this_ptr_conv;
44415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44416         this_ptr_conv.is_owned = false;
44417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44418         LDKPublicKey val_ref;
44419         CHECK((*env)->GetArrayLength(env, val) == 33);
44420         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
44421         PayeePubKey_set_a(&this_ptr_conv, val_ref);
44422 }
44423
44424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
44425         LDKPublicKey a_arg_ref;
44426         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
44427         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
44428         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
44429         int64_t ret_ref = 0;
44430         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44431         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44433         ret_ref = (uintptr_t)ret_var.inner;
44434         if (ret_var.is_owned) {
44435                 ret_ref |= 1;
44436         }
44437         return ret_ref;
44438 }
44439
44440 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
44441         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
44442 int64_t ret_ref = 0;
44443 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44444 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44445 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44446 ret_ref = (uintptr_t)ret_var.inner;
44447 if (ret_var.is_owned) {
44448         ret_ref |= 1;
44449 }
44450         return ret_ref;
44451 }
44452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44453         LDKPayeePubKey arg_conv;
44454         arg_conv.inner = (void*)(arg & (~1));
44455         arg_conv.is_owned = false;
44456         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44457         int64_t ret_val = PayeePubKey_clone_ptr(&arg_conv);
44458         return ret_val;
44459 }
44460
44461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44462         LDKPayeePubKey orig_conv;
44463         orig_conv.inner = (void*)(orig & (~1));
44464         orig_conv.is_owned = false;
44465         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44466         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
44467         int64_t ret_ref = 0;
44468         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44469         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44471         ret_ref = (uintptr_t)ret_var.inner;
44472         if (ret_var.is_owned) {
44473                 ret_ref |= 1;
44474         }
44475         return ret_ref;
44476 }
44477
44478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
44479         LDKPayeePubKey o_conv;
44480         o_conv.inner = (void*)(o & (~1));
44481         o_conv.is_owned = false;
44482         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44483         int64_t ret_val = PayeePubKey_hash(&o_conv);
44484         return ret_val;
44485 }
44486
44487 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44488         LDKPayeePubKey a_conv;
44489         a_conv.inner = (void*)(a & (~1));
44490         a_conv.is_owned = false;
44491         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44492         LDKPayeePubKey b_conv;
44493         b_conv.inner = (void*)(b & (~1));
44494         b_conv.is_owned = false;
44495         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44496         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
44497         return ret_val;
44498 }
44499
44500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44501         LDKExpiryTime this_obj_conv;
44502         this_obj_conv.inner = (void*)(this_obj & (~1));
44503         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44505         ExpiryTime_free(this_obj_conv);
44506 }
44507
44508 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
44509         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
44510 int64_t ret_ref = 0;
44511 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44512 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44513 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44514 ret_ref = (uintptr_t)ret_var.inner;
44515 if (ret_var.is_owned) {
44516         ret_ref |= 1;
44517 }
44518         return ret_ref;
44519 }
44520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44521         LDKExpiryTime arg_conv;
44522         arg_conv.inner = (void*)(arg & (~1));
44523         arg_conv.is_owned = false;
44524         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44525         int64_t ret_val = ExpiryTime_clone_ptr(&arg_conv);
44526         return ret_val;
44527 }
44528
44529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44530         LDKExpiryTime orig_conv;
44531         orig_conv.inner = (void*)(orig & (~1));
44532         orig_conv.is_owned = false;
44533         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44534         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
44535         int64_t ret_ref = 0;
44536         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44537         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44538         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44539         ret_ref = (uintptr_t)ret_var.inner;
44540         if (ret_var.is_owned) {
44541                 ret_ref |= 1;
44542         }
44543         return ret_ref;
44544 }
44545
44546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
44547         LDKExpiryTime o_conv;
44548         o_conv.inner = (void*)(o & (~1));
44549         o_conv.is_owned = false;
44550         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44551         int64_t ret_val = ExpiryTime_hash(&o_conv);
44552         return ret_val;
44553 }
44554
44555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44556         LDKExpiryTime a_conv;
44557         a_conv.inner = (void*)(a & (~1));
44558         a_conv.is_owned = false;
44559         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44560         LDKExpiryTime b_conv;
44561         b_conv.inner = (void*)(b & (~1));
44562         b_conv.is_owned = false;
44563         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44564         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
44565         return ret_val;
44566 }
44567
44568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44569         LDKMinFinalCltvExpiry this_obj_conv;
44570         this_obj_conv.inner = (void*)(this_obj & (~1));
44571         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44573         MinFinalCltvExpiry_free(this_obj_conv);
44574 }
44575
44576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
44577         LDKMinFinalCltvExpiry this_ptr_conv;
44578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44579         this_ptr_conv.is_owned = false;
44580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44581         int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
44582         return ret_val;
44583 }
44584
44585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44586         LDKMinFinalCltvExpiry this_ptr_conv;
44587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44588         this_ptr_conv.is_owned = false;
44589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44590         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
44591 }
44592
44593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
44594         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
44595         int64_t ret_ref = 0;
44596         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44597         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44599         ret_ref = (uintptr_t)ret_var.inner;
44600         if (ret_var.is_owned) {
44601                 ret_ref |= 1;
44602         }
44603         return ret_ref;
44604 }
44605
44606 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
44607         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
44608 int64_t ret_ref = 0;
44609 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44610 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44611 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44612 ret_ref = (uintptr_t)ret_var.inner;
44613 if (ret_var.is_owned) {
44614         ret_ref |= 1;
44615 }
44616         return ret_ref;
44617 }
44618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44619         LDKMinFinalCltvExpiry arg_conv;
44620         arg_conv.inner = (void*)(arg & (~1));
44621         arg_conv.is_owned = false;
44622         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44623         int64_t ret_val = MinFinalCltvExpiry_clone_ptr(&arg_conv);
44624         return ret_val;
44625 }
44626
44627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44628         LDKMinFinalCltvExpiry orig_conv;
44629         orig_conv.inner = (void*)(orig & (~1));
44630         orig_conv.is_owned = false;
44631         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44632         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
44633         int64_t ret_ref = 0;
44634         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44635         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44637         ret_ref = (uintptr_t)ret_var.inner;
44638         if (ret_var.is_owned) {
44639                 ret_ref |= 1;
44640         }
44641         return ret_ref;
44642 }
44643
44644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
44645         LDKMinFinalCltvExpiry o_conv;
44646         o_conv.inner = (void*)(o & (~1));
44647         o_conv.is_owned = false;
44648         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44649         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
44650         return ret_val;
44651 }
44652
44653 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44654         LDKMinFinalCltvExpiry a_conv;
44655         a_conv.inner = (void*)(a & (~1));
44656         a_conv.is_owned = false;
44657         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44658         LDKMinFinalCltvExpiry b_conv;
44659         b_conv.inner = (void*)(b & (~1));
44660         b_conv.is_owned = false;
44661         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44662         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
44663         return ret_val;
44664 }
44665
44666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44667         if ((this_ptr & 1) != 0) return;
44668         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44669         CHECK_ACCESS(this_ptr_ptr);
44670         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
44671         FREE((void*)this_ptr);
44672         Fallback_free(this_ptr_conv);
44673 }
44674
44675 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
44676         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44677         *ret_copy = Fallback_clone(arg);
44678 int64_t ret_ref = (uintptr_t)ret_copy;
44679         return ret_ref;
44680 }
44681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44682         LDKFallback* arg_conv = (LDKFallback*)arg;
44683         int64_t ret_val = Fallback_clone_ptr(arg_conv);
44684         return ret_val;
44685 }
44686
44687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44688         LDKFallback* orig_conv = (LDKFallback*)orig;
44689         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44690         *ret_copy = Fallback_clone(orig_conv);
44691         int64_t ret_ref = (uintptr_t)ret_copy;
44692         return ret_ref;
44693 }
44694
44695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
44696         
44697         LDKCVec_u8Z program_ref;
44698         program_ref.datalen = (*env)->GetArrayLength(env, program);
44699         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
44700         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
44701         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44702         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
44703         int64_t ret_ref = (uintptr_t)ret_copy;
44704         return ret_ref;
44705 }
44706
44707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
44708         LDKTwentyBytes a_ref;
44709         CHECK((*env)->GetArrayLength(env, a) == 20);
44710         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
44711         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44712         *ret_copy = Fallback_pub_key_hash(a_ref);
44713         int64_t ret_ref = (uintptr_t)ret_copy;
44714         return ret_ref;
44715 }
44716
44717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
44718         LDKTwentyBytes a_ref;
44719         CHECK((*env)->GetArrayLength(env, a) == 20);
44720         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
44721         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44722         *ret_copy = Fallback_script_hash(a_ref);
44723         int64_t ret_ref = (uintptr_t)ret_copy;
44724         return ret_ref;
44725 }
44726
44727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
44728         LDKFallback* o_conv = (LDKFallback*)o;
44729         int64_t ret_val = Fallback_hash(o_conv);
44730         return ret_val;
44731 }
44732
44733 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44734         LDKFallback* a_conv = (LDKFallback*)a;
44735         LDKFallback* b_conv = (LDKFallback*)b;
44736         jboolean ret_val = Fallback_eq(a_conv, b_conv);
44737         return ret_val;
44738 }
44739
44740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44741         LDKInvoiceSignature this_obj_conv;
44742         this_obj_conv.inner = (void*)(this_obj & (~1));
44743         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44745         InvoiceSignature_free(this_obj_conv);
44746 }
44747
44748 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
44749         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
44750 int64_t ret_ref = 0;
44751 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44752 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44753 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44754 ret_ref = (uintptr_t)ret_var.inner;
44755 if (ret_var.is_owned) {
44756         ret_ref |= 1;
44757 }
44758         return ret_ref;
44759 }
44760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44761         LDKInvoiceSignature arg_conv;
44762         arg_conv.inner = (void*)(arg & (~1));
44763         arg_conv.is_owned = false;
44764         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44765         int64_t ret_val = InvoiceSignature_clone_ptr(&arg_conv);
44766         return ret_val;
44767 }
44768
44769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44770         LDKInvoiceSignature orig_conv;
44771         orig_conv.inner = (void*)(orig & (~1));
44772         orig_conv.is_owned = false;
44773         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44774         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
44775         int64_t ret_ref = 0;
44776         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44777         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44779         ret_ref = (uintptr_t)ret_var.inner;
44780         if (ret_var.is_owned) {
44781                 ret_ref |= 1;
44782         }
44783         return ret_ref;
44784 }
44785
44786 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44787         LDKInvoiceSignature a_conv;
44788         a_conv.inner = (void*)(a & (~1));
44789         a_conv.is_owned = false;
44790         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44791         LDKInvoiceSignature b_conv;
44792         b_conv.inner = (void*)(b & (~1));
44793         b_conv.is_owned = false;
44794         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44795         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
44796         return ret_val;
44797 }
44798
44799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44800         LDKPrivateRoute this_obj_conv;
44801         this_obj_conv.inner = (void*)(this_obj & (~1));
44802         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44804         PrivateRoute_free(this_obj_conv);
44805 }
44806
44807 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
44808         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
44809 int64_t ret_ref = 0;
44810 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44811 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44812 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44813 ret_ref = (uintptr_t)ret_var.inner;
44814 if (ret_var.is_owned) {
44815         ret_ref |= 1;
44816 }
44817         return ret_ref;
44818 }
44819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44820         LDKPrivateRoute arg_conv;
44821         arg_conv.inner = (void*)(arg & (~1));
44822         arg_conv.is_owned = false;
44823         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44824         int64_t ret_val = PrivateRoute_clone_ptr(&arg_conv);
44825         return ret_val;
44826 }
44827
44828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44829         LDKPrivateRoute orig_conv;
44830         orig_conv.inner = (void*)(orig & (~1));
44831         orig_conv.is_owned = false;
44832         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44833         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
44834         int64_t ret_ref = 0;
44835         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44836         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44838         ret_ref = (uintptr_t)ret_var.inner;
44839         if (ret_var.is_owned) {
44840                 ret_ref |= 1;
44841         }
44842         return ret_ref;
44843 }
44844
44845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
44846         LDKPrivateRoute o_conv;
44847         o_conv.inner = (void*)(o & (~1));
44848         o_conv.is_owned = false;
44849         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44850         int64_t ret_val = PrivateRoute_hash(&o_conv);
44851         return ret_val;
44852 }
44853
44854 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44855         LDKPrivateRoute a_conv;
44856         a_conv.inner = (void*)(a & (~1));
44857         a_conv.is_owned = false;
44858         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44859         LDKPrivateRoute b_conv;
44860         b_conv.inner = (void*)(b & (~1));
44861         b_conv.is_owned = false;
44862         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44863         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
44864         return ret_val;
44865 }
44866
44867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
44868         LDKSignedRawInvoice this_arg_conv;
44869         this_arg_conv.inner = (void*)(this_arg & (~1));
44870         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44872         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
44873         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
44874         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
44875         return ((int64_t)ret_conv);
44876 }
44877
44878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
44879         LDKSignedRawInvoice this_arg_conv;
44880         this_arg_conv.inner = (void*)(this_arg & (~1));
44881         this_arg_conv.is_owned = false;
44882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44883         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
44884         int64_t ret_ref = 0;
44885         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44886         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44888         ret_ref = (uintptr_t)ret_var.inner;
44889         if (ret_var.is_owned) {
44890                 ret_ref |= 1;
44891         }
44892         return ret_ref;
44893 }
44894
44895 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
44896         LDKSignedRawInvoice this_arg_conv;
44897         this_arg_conv.inner = (void*)(this_arg & (~1));
44898         this_arg_conv.is_owned = false;
44899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44900         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44901         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
44902         return ret_arr;
44903 }
44904
44905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
44906         LDKSignedRawInvoice this_arg_conv;
44907         this_arg_conv.inner = (void*)(this_arg & (~1));
44908         this_arg_conv.is_owned = false;
44909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44910         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
44911         int64_t ret_ref = 0;
44912         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44913         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44915         ret_ref = (uintptr_t)ret_var.inner;
44916         if (ret_var.is_owned) {
44917                 ret_ref |= 1;
44918         }
44919         return ret_ref;
44920 }
44921
44922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44923         LDKSignedRawInvoice this_arg_conv;
44924         this_arg_conv.inner = (void*)(this_arg & (~1));
44925         this_arg_conv.is_owned = false;
44926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44927         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
44928         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
44929         return (int64_t)ret_conv;
44930 }
44931
44932 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
44933         LDKSignedRawInvoice this_arg_conv;
44934         this_arg_conv.inner = (void*)(this_arg & (~1));
44935         this_arg_conv.is_owned = false;
44936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44937         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
44938         return ret_val;
44939 }
44940
44941 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
44942         LDKRawInvoice this_arg_conv;
44943         this_arg_conv.inner = (void*)(this_arg & (~1));
44944         this_arg_conv.is_owned = false;
44945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44946         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44947         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
44948         return ret_arr;
44949 }
44950
44951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
44952         LDKRawInvoice this_arg_conv;
44953         this_arg_conv.inner = (void*)(this_arg & (~1));
44954         this_arg_conv.is_owned = false;
44955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44956         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
44957         int64_t ret_ref = 0;
44958         if ((uintptr_t)ret_var.inner > 4096) {
44959                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44960                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44961         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44962                 ret_ref = (uintptr_t)ret_var.inner;
44963                 if (ret_var.is_owned) {
44964                         ret_ref |= 1;
44965                 }
44966         }
44967         return ret_ref;
44968 }
44969
44970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
44971         LDKRawInvoice this_arg_conv;
44972         this_arg_conv.inner = (void*)(this_arg & (~1));
44973         this_arg_conv.is_owned = false;
44974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44975         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
44976         int64_t ret_ref = 0;
44977         if ((uintptr_t)ret_var.inner > 4096) {
44978                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44979                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44981                 ret_ref = (uintptr_t)ret_var.inner;
44982                 if (ret_var.is_owned) {
44983                         ret_ref |= 1;
44984                 }
44985         }
44986         return ret_ref;
44987 }
44988
44989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44990         LDKRawInvoice this_arg_conv;
44991         this_arg_conv.inner = (void*)(this_arg & (~1));
44992         this_arg_conv.is_owned = false;
44993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44994         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
44995         int64_t ret_ref = 0;
44996         if ((uintptr_t)ret_var.inner > 4096) {
44997                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44998                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45000                 ret_ref = (uintptr_t)ret_var.inner;
45001                 if (ret_var.is_owned) {
45002                         ret_ref |= 1;
45003                 }
45004         }
45005         return ret_ref;
45006 }
45007
45008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
45009         LDKRawInvoice this_arg_conv;
45010         this_arg_conv.inner = (void*)(this_arg & (~1));
45011         this_arg_conv.is_owned = false;
45012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45013         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
45014         int64_t ret_ref = 0;
45015         if ((uintptr_t)ret_var.inner > 4096) {
45016                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45017                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45019                 ret_ref = (uintptr_t)ret_var.inner;
45020                 if (ret_var.is_owned) {
45021                         ret_ref |= 1;
45022                 }
45023         }
45024         return ret_ref;
45025 }
45026
45027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
45028         LDKRawInvoice this_arg_conv;
45029         this_arg_conv.inner = (void*)(this_arg & (~1));
45030         this_arg_conv.is_owned = false;
45031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45032         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
45033         int64_t ret_ref = 0;
45034         if ((uintptr_t)ret_var.inner > 4096) {
45035                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45036                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45038                 ret_ref = (uintptr_t)ret_var.inner;
45039                 if (ret_var.is_owned) {
45040                         ret_ref |= 1;
45041                 }
45042         }
45043         return ret_ref;
45044 }
45045
45046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
45047         LDKRawInvoice this_arg_conv;
45048         this_arg_conv.inner = (void*)(this_arg & (~1));
45049         this_arg_conv.is_owned = false;
45050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45051         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
45052         int64_t ret_ref = 0;
45053         if ((uintptr_t)ret_var.inner > 4096) {
45054                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45055                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45057                 ret_ref = (uintptr_t)ret_var.inner;
45058                 if (ret_var.is_owned) {
45059                         ret_ref |= 1;
45060                 }
45061         }
45062         return ret_ref;
45063 }
45064
45065 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45066         LDKRawInvoice this_arg_conv;
45067         this_arg_conv.inner = (void*)(this_arg & (~1));
45068         this_arg_conv.is_owned = false;
45069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45070         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
45071         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
45072         return ret_arr;
45073 }
45074
45075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
45076         LDKRawInvoice this_arg_conv;
45077         this_arg_conv.inner = (void*)(this_arg & (~1));
45078         this_arg_conv.is_owned = false;
45079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45080         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
45081         int64_t ret_ref = 0;
45082         if ((uintptr_t)ret_var.inner > 4096) {
45083                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45084                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45085         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45086                 ret_ref = (uintptr_t)ret_var.inner;
45087                 if (ret_var.is_owned) {
45088                         ret_ref |= 1;
45089                 }
45090         }
45091         return ret_ref;
45092 }
45093
45094 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
45095         LDKRawInvoice this_arg_conv;
45096         this_arg_conv.inner = (void*)(this_arg & (~1));
45097         this_arg_conv.is_owned = false;
45098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45099         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
45100         int64_tArray ret_arr = NULL;
45101         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45102         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45103         for (size_t o = 0; o < ret_var.datalen; o++) {
45104                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
45105                 int64_t ret_conv_14_ref = 0;
45106                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45107                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45108                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
45109                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
45110                 if (ret_conv_14_var.is_owned) {
45111                         ret_conv_14_ref |= 1;
45112                 }
45113                 ret_arr_ptr[o] = ret_conv_14_ref;
45114         }
45115         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45116         FREE(ret_var.data);
45117         return ret_arr;
45118 }
45119
45120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
45121         LDKRawInvoice this_arg_conv;
45122         this_arg_conv.inner = (void*)(this_arg & (~1));
45123         this_arg_conv.is_owned = false;
45124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45125         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45126         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
45127         int64_t ret_ref = (uintptr_t)ret_copy;
45128         return ret_ref;
45129 }
45130
45131 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
45132         LDKRawInvoice this_arg_conv;
45133         this_arg_conv.inner = (void*)(this_arg & (~1));
45134         this_arg_conv.is_owned = false;
45135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45136         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
45137         return ret_conv;
45138 }
45139
45140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
45141         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
45142         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
45143         return (int64_t)ret_conv;
45144 }
45145
45146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
45147         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
45148         *ret_conv = PositiveTimestamp_from_system_time(time);
45149         return (int64_t)ret_conv;
45150 }
45151
45152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
45153         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
45154         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
45155         return (int64_t)ret_conv;
45156 }
45157
45158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
45159         LDKPositiveTimestamp this_arg_conv;
45160         this_arg_conv.inner = (void*)(this_arg & (~1));
45161         this_arg_conv.is_owned = false;
45162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45163         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
45164         return ret_val;
45165 }
45166
45167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
45168         LDKPositiveTimestamp this_arg_conv;
45169         this_arg_conv.inner = (void*)(this_arg & (~1));
45170         this_arg_conv.is_owned = false;
45171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45172         int64_t ret_val = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
45173         return ret_val;
45174 }
45175
45176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
45177         LDKPositiveTimestamp this_arg_conv;
45178         this_arg_conv.inner = (void*)(this_arg & (~1));
45179         this_arg_conv.is_owned = false;
45180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45181         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
45182         return ret_val;
45183 }
45184
45185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
45186         LDKInvoice this_arg_conv;
45187         this_arg_conv.inner = (void*)(this_arg & (~1));
45188         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45190         this_arg_conv = Invoice_clone(&this_arg_conv);
45191         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
45192         int64_t ret_ref = 0;
45193         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45194         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45196         ret_ref = (uintptr_t)ret_var.inner;
45197         if (ret_var.is_owned) {
45198                 ret_ref |= 1;
45199         }
45200         return ret_ref;
45201 }
45202
45203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
45204         LDKInvoice this_arg_conv;
45205         this_arg_conv.inner = (void*)(this_arg & (~1));
45206         this_arg_conv.is_owned = false;
45207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45208         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
45209         *ret_conv = Invoice_check_signature(&this_arg_conv);
45210         return (int64_t)ret_conv;
45211 }
45212
45213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
45214         LDKSignedRawInvoice signed_invoice_conv;
45215         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
45216         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
45217         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
45218         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
45219         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
45220         *ret_conv = Invoice_from_signed(signed_invoice_conv);
45221         return (int64_t)ret_conv;
45222 }
45223
45224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
45225         LDKInvoice this_arg_conv;
45226         this_arg_conv.inner = (void*)(this_arg & (~1));
45227         this_arg_conv.is_owned = false;
45228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45229         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
45230         return ret_val;
45231 }
45232
45233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
45234         LDKInvoice this_arg_conv;
45235         this_arg_conv.inner = (void*)(this_arg & (~1));
45236         this_arg_conv.is_owned = false;
45237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45238         int64_t ret_val = Invoice_duration_since_epoch(&this_arg_conv);
45239         return ret_val;
45240 }
45241
45242 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
45243         LDKInvoice this_arg_conv;
45244         this_arg_conv.inner = (void*)(this_arg & (~1));
45245         this_arg_conv.is_owned = false;
45246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45247         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
45248         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
45249         return ret_arr;
45250 }
45251
45252 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45253         LDKInvoice this_arg_conv;
45254         this_arg_conv.inner = (void*)(this_arg & (~1));
45255         this_arg_conv.is_owned = false;
45256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45257         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45258         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
45259         return ret_arr;
45260 }
45261
45262 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45263         LDKInvoice this_arg_conv;
45264         this_arg_conv.inner = (void*)(this_arg & (~1));
45265         this_arg_conv.is_owned = false;
45266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45267         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
45268         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
45269         return ret_arr;
45270 }
45271
45272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
45273         LDKInvoice this_arg_conv;
45274         this_arg_conv.inner = (void*)(this_arg & (~1));
45275         this_arg_conv.is_owned = false;
45276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45277         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
45278         int64_t ret_ref = 0;
45279         if ((uintptr_t)ret_var.inner > 4096) {
45280                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45281                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45283                 ret_ref = (uintptr_t)ret_var.inner;
45284                 if (ret_var.is_owned) {
45285                         ret_ref |= 1;
45286                 }
45287         }
45288         return ret_ref;
45289 }
45290
45291 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45292         LDKInvoice this_arg_conv;
45293         this_arg_conv.inner = (void*)(this_arg & (~1));
45294         this_arg_conv.is_owned = false;
45295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45296         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45297         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
45298         return ret_arr;
45299 }
45300
45301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
45302         LDKInvoice this_arg_conv;
45303         this_arg_conv.inner = (void*)(this_arg & (~1));
45304         this_arg_conv.is_owned = false;
45305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45306         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
45307         return ret_val;
45308 }
45309
45310 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
45311         LDKInvoice this_arg_conv;
45312         this_arg_conv.inner = (void*)(this_arg & (~1));
45313         this_arg_conv.is_owned = false;
45314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45315         jboolean ret_val = Invoice_is_expired(&this_arg_conv);
45316         return ret_val;
45317 }
45318
45319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
45320         LDKInvoice this_arg_conv;
45321         this_arg_conv.inner = (void*)(this_arg & (~1));
45322         this_arg_conv.is_owned = false;
45323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45324         jboolean ret_val = Invoice_would_expire(&this_arg_conv, at_time);
45325         return ret_val;
45326 }
45327
45328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
45329         LDKInvoice this_arg_conv;
45330         this_arg_conv.inner = (void*)(this_arg & (~1));
45331         this_arg_conv.is_owned = false;
45332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45333         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
45334         return ret_val;
45335 }
45336
45337 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
45338         LDKInvoice this_arg_conv;
45339         this_arg_conv.inner = (void*)(this_arg & (~1));
45340         this_arg_conv.is_owned = false;
45341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45342         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
45343         int64_tArray ret_arr = NULL;
45344         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45345         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45346         for (size_t o = 0; o < ret_var.datalen; o++) {
45347                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
45348                 int64_t ret_conv_14_ref = 0;
45349                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45350                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45351                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
45352                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
45353                 if (ret_conv_14_var.is_owned) {
45354                         ret_conv_14_ref |= 1;
45355                 }
45356                 ret_arr_ptr[o] = ret_conv_14_ref;
45357         }
45358         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45359         FREE(ret_var.data);
45360         return ret_arr;
45361 }
45362
45363 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
45364         LDKInvoice this_arg_conv;
45365         this_arg_conv.inner = (void*)(this_arg & (~1));
45366         this_arg_conv.is_owned = false;
45367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45368         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
45369         int64_tArray ret_arr = NULL;
45370         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45371         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45372         for (size_t l = 0; l < ret_var.datalen; l++) {
45373                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
45374                 int64_t ret_conv_11_ref = 0;
45375                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45376                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45377                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
45378                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
45379                 if (ret_conv_11_var.is_owned) {
45380                         ret_conv_11_ref |= 1;
45381                 }
45382                 ret_arr_ptr[l] = ret_conv_11_ref;
45383         }
45384         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45385         FREE(ret_var.data);
45386         return ret_arr;
45387 }
45388
45389 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
45390         LDKInvoice this_arg_conv;
45391         this_arg_conv.inner = (void*)(this_arg & (~1));
45392         this_arg_conv.is_owned = false;
45393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45394         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
45395         return ret_conv;
45396 }
45397
45398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
45399         LDKInvoice this_arg_conv;
45400         this_arg_conv.inner = (void*)(this_arg & (~1));
45401         this_arg_conv.is_owned = false;
45402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45403         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45404         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
45405         int64_t ret_ref = (uintptr_t)ret_copy;
45406         return ret_ref;
45407 }
45408
45409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
45410         LDKStr description_conv = java_to_owned_str(env, description);
45411         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
45412         *ret_conv = Description_new(description_conv);
45413         return (int64_t)ret_conv;
45414 }
45415
45416 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
45417         LDKDescription this_arg_conv;
45418         this_arg_conv.inner = (void*)(this_arg & (~1));
45419         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45421         this_arg_conv = Description_clone(&this_arg_conv);
45422         LDKStr ret_str = Description_into_inner(this_arg_conv);
45423         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45424         Str_free(ret_str);
45425         return ret_conv;
45426 }
45427
45428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
45429         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
45430         int64_t ret_ref = 0;
45431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45434         ret_ref = (uintptr_t)ret_var.inner;
45435         if (ret_var.is_owned) {
45436                 ret_ref |= 1;
45437         }
45438         return ret_ref;
45439 }
45440
45441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
45442         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
45443         int64_t ret_ref = 0;
45444         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45445         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45447         ret_ref = (uintptr_t)ret_var.inner;
45448         if (ret_var.is_owned) {
45449                 ret_ref |= 1;
45450         }
45451         return ret_ref;
45452 }
45453
45454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
45455         LDKExpiryTime this_arg_conv;
45456         this_arg_conv.inner = (void*)(this_arg & (~1));
45457         this_arg_conv.is_owned = false;
45458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45459         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
45460         return ret_val;
45461 }
45462
45463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
45464         LDKExpiryTime this_arg_conv;
45465         this_arg_conv.inner = (void*)(this_arg & (~1));
45466         this_arg_conv.is_owned = false;
45467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45468         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
45469         return ret_val;
45470 }
45471
45472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
45473         LDKRouteHint hops_conv;
45474         hops_conv.inner = (void*)(hops & (~1));
45475         hops_conv.is_owned = (hops & 1) || (hops == 0);
45476         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
45477         hops_conv = RouteHint_clone(&hops_conv);
45478         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
45479         *ret_conv = PrivateRoute_new(hops_conv);
45480         return (int64_t)ret_conv;
45481 }
45482
45483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
45484         LDKPrivateRoute this_arg_conv;
45485         this_arg_conv.inner = (void*)(this_arg & (~1));
45486         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45488         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
45489         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
45490         int64_t ret_ref = 0;
45491         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45492         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45494         ret_ref = (uintptr_t)ret_var.inner;
45495         if (ret_var.is_owned) {
45496                 ret_ref |= 1;
45497         }
45498         return ret_ref;
45499 }
45500
45501 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45502         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
45503         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
45504         return ret_conv;
45505 }
45506
45507 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
45508         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
45509         return ret_conv;
45510 }
45511
45512 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
45513         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
45514         return ret_conv;
45515 }
45516
45517 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
45518         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
45519         return ret_conv;
45520 }
45521
45522 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
45523         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
45524         return ret_conv;
45525 }
45526
45527 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
45528         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
45529         return ret_conv;
45530 }
45531
45532 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45533         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
45534         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
45535         jboolean ret_val = CreationError_eq(a_conv, b_conv);
45536         return ret_val;
45537 }
45538
45539 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
45540         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
45541         LDKStr ret_str = CreationError_to_str(o_conv);
45542         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45543         Str_free(ret_str);
45544         return ret_conv;
45545 }
45546
45547 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45548         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
45549         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
45550         return ret_conv;
45551 }
45552
45553 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
45554         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
45555         return ret_conv;
45556 }
45557
45558 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
45559         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
45560         return ret_conv;
45561 }
45562
45563 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
45564         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
45565         return ret_conv;
45566 }
45567
45568 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
45569         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
45570         return ret_conv;
45571 }
45572
45573 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
45574         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
45575         return ret_conv;
45576 }
45577
45578 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
45579         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
45580         return ret_conv;
45581 }
45582
45583 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
45584         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
45585         return ret_conv;
45586 }
45587
45588 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
45589         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
45590         return ret_conv;
45591 }
45592
45593 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
45594         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
45595         return ret_conv;
45596 }
45597
45598 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
45599         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
45600         return ret_conv;
45601 }
45602
45603 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45604         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
45605         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
45606         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
45607         return ret_val;
45608 }
45609
45610 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
45611         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
45612         LDKStr ret_str = SemanticError_to_str(o_conv);
45613         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45614         Str_free(ret_str);
45615         return ret_conv;
45616 }
45617
45618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45619         if ((this_ptr & 1) != 0) return;
45620         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45621         CHECK_ACCESS(this_ptr_ptr);
45622         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
45623         FREE((void*)this_ptr);
45624         SignOrCreationError_free(this_ptr_conv);
45625 }
45626
45627 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
45628         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45629         *ret_copy = SignOrCreationError_clone(arg);
45630 int64_t ret_ref = (uintptr_t)ret_copy;
45631         return ret_ref;
45632 }
45633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45634         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
45635         int64_t ret_val = SignOrCreationError_clone_ptr(arg_conv);
45636         return ret_val;
45637 }
45638
45639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45640         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
45641         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45642         *ret_copy = SignOrCreationError_clone(orig_conv);
45643         int64_t ret_ref = (uintptr_t)ret_copy;
45644         return ret_ref;
45645 }
45646
45647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
45648         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45649         *ret_copy = SignOrCreationError_sign_error();
45650         int64_t ret_ref = (uintptr_t)ret_copy;
45651         return ret_ref;
45652 }
45653
45654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
45655         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
45656         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45657         *ret_copy = SignOrCreationError_creation_error(a_conv);
45658         int64_t ret_ref = (uintptr_t)ret_copy;
45659         return ret_ref;
45660 }
45661
45662 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45663         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
45664         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
45665         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
45666         return ret_val;
45667 }
45668
45669 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
45670         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
45671         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
45672         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45673         Str_free(ret_str);
45674         return ret_conv;
45675 }
45676
45677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45678         LDKInvoicePayer this_obj_conv;
45679         this_obj_conv.inner = (void*)(this_obj & (~1));
45680         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45682         InvoicePayer_free(this_obj_conv);
45683 }
45684
45685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45686         if ((this_ptr & 1) != 0) return;
45687         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45688         CHECK_ACCESS(this_ptr_ptr);
45689         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
45690         FREE((void*)this_ptr);
45691         Payer_free(this_ptr_conv);
45692 }
45693
45694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45695         if ((this_ptr & 1) != 0) return;
45696         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45697         CHECK_ACCESS(this_ptr_ptr);
45698         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
45699         FREE((void*)this_ptr);
45700         Router_free(this_ptr_conv);
45701 }
45702
45703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45704         LDKRetryAttempts this_obj_conv;
45705         this_obj_conv.inner = (void*)(this_obj & (~1));
45706         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45708         RetryAttempts_free(this_obj_conv);
45709 }
45710
45711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
45712         LDKRetryAttempts this_ptr_conv;
45713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45714         this_ptr_conv.is_owned = false;
45715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45716         int64_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
45717         return ret_val;
45718 }
45719
45720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45721         LDKRetryAttempts this_ptr_conv;
45722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45723         this_ptr_conv.is_owned = false;
45724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45725         RetryAttempts_set_a(&this_ptr_conv, val);
45726 }
45727
45728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
45729         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
45730         int64_t ret_ref = 0;
45731         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45732         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45734         ret_ref = (uintptr_t)ret_var.inner;
45735         if (ret_var.is_owned) {
45736                 ret_ref |= 1;
45737         }
45738         return ret_ref;
45739 }
45740
45741 static inline uintptr_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
45742         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
45743 int64_t ret_ref = 0;
45744 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45745 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45746 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45747 ret_ref = (uintptr_t)ret_var.inner;
45748 if (ret_var.is_owned) {
45749         ret_ref |= 1;
45750 }
45751         return ret_ref;
45752 }
45753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45754         LDKRetryAttempts arg_conv;
45755         arg_conv.inner = (void*)(arg & (~1));
45756         arg_conv.is_owned = false;
45757         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45758         int64_t ret_val = RetryAttempts_clone_ptr(&arg_conv);
45759         return ret_val;
45760 }
45761
45762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45763         LDKRetryAttempts orig_conv;
45764         orig_conv.inner = (void*)(orig & (~1));
45765         orig_conv.is_owned = false;
45766         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45767         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
45768         int64_t ret_ref = 0;
45769         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45770         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45772         ret_ref = (uintptr_t)ret_var.inner;
45773         if (ret_var.is_owned) {
45774                 ret_ref |= 1;
45775         }
45776         return ret_ref;
45777 }
45778
45779 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45780         LDKRetryAttempts a_conv;
45781         a_conv.inner = (void*)(a & (~1));
45782         a_conv.is_owned = false;
45783         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45784         LDKRetryAttempts b_conv;
45785         b_conv.inner = (void*)(b & (~1));
45786         b_conv.is_owned = false;
45787         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45788         jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
45789         return ret_val;
45790 }
45791
45792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1hash(JNIEnv *env, jclass clz, int64_t o) {
45793         LDKRetryAttempts o_conv;
45794         o_conv.inner = (void*)(o & (~1));
45795         o_conv.is_owned = false;
45796         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45797         int64_t ret_val = RetryAttempts_hash(&o_conv);
45798         return ret_val;
45799 }
45800
45801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45802         if ((this_ptr & 1) != 0) return;
45803         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45804         CHECK_ACCESS(this_ptr_ptr);
45805         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
45806         FREE((void*)this_ptr);
45807         PaymentError_free(this_ptr_conv);
45808 }
45809
45810 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
45811         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45812         *ret_copy = PaymentError_clone(arg);
45813 int64_t ret_ref = (uintptr_t)ret_copy;
45814         return ret_ref;
45815 }
45816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45817         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
45818         int64_t ret_val = PaymentError_clone_ptr(arg_conv);
45819         return ret_val;
45820 }
45821
45822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45823         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
45824         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45825         *ret_copy = PaymentError_clone(orig_conv);
45826         int64_t ret_ref = (uintptr_t)ret_copy;
45827         return ret_ref;
45828 }
45829
45830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
45831         LDKStr a_conv = java_to_owned_str(env, a);
45832         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45833         *ret_copy = PaymentError_invoice(a_conv);
45834         int64_t ret_ref = (uintptr_t)ret_copy;
45835         return ret_ref;
45836 }
45837
45838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
45839         LDKLightningError a_conv;
45840         a_conv.inner = (void*)(a & (~1));
45841         a_conv.is_owned = (a & 1) || (a == 0);
45842         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45843         a_conv = LightningError_clone(&a_conv);
45844         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45845         *ret_copy = PaymentError_routing(a_conv);
45846         int64_t ret_ref = (uintptr_t)ret_copy;
45847         return ret_ref;
45848 }
45849
45850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
45851         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
45852         CHECK_ACCESS(a_ptr);
45853         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
45854         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
45855         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45856         *ret_copy = PaymentError_sending(a_conv);
45857         int64_t ret_ref = (uintptr_t)ret_copy;
45858         return ret_ref;
45859 }
45860
45861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1new(JNIEnv *env, jclass clz, int64_t payer, int64_t router, int64_t scorer, int64_t logger, int64_t event_handler, int64_t retry_attempts) {
45862         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
45863         CHECK_ACCESS(payer_ptr);
45864         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
45865         if (payer_conv.free == LDKPayer_JCalls_free) {
45866                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45867                 LDKPayer_JCalls_cloned(&payer_conv);
45868         }
45869         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
45870         CHECK_ACCESS(router_ptr);
45871         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
45872         if (router_conv.free == LDKRouter_JCalls_free) {
45873                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45874                 LDKRouter_JCalls_cloned(&router_conv);
45875         }
45876         LDKMultiThreadedLockableScore scorer_conv;
45877         scorer_conv.inner = (void*)(scorer & (~1));
45878         scorer_conv.is_owned = false;
45879         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
45880         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45881         CHECK_ACCESS(logger_ptr);
45882         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45883         if (logger_conv.free == LDKLogger_JCalls_free) {
45884                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45885                 LDKLogger_JCalls_cloned(&logger_conv);
45886         }
45887         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
45888         CHECK_ACCESS(event_handler_ptr);
45889         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
45890         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
45891                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45892                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
45893         }
45894         LDKRetryAttempts retry_attempts_conv;
45895         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
45896         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
45897         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
45898         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
45899         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
45900         int64_t ret_ref = 0;
45901         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45902         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45904         ret_ref = (uintptr_t)ret_var.inner;
45905         if (ret_var.is_owned) {
45906                 ret_ref |= 1;
45907         }
45908         return ret_ref;
45909 }
45910
45911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
45912         LDKInvoicePayer this_arg_conv;
45913         this_arg_conv.inner = (void*)(this_arg & (~1));
45914         this_arg_conv.is_owned = false;
45915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45916         LDKInvoice invoice_conv;
45917         invoice_conv.inner = (void*)(invoice & (~1));
45918         invoice_conv.is_owned = false;
45919         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
45920         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45921         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
45922         return (int64_t)ret_conv;
45923 }
45924
45925 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) {
45926         LDKInvoicePayer 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         LDKInvoice invoice_conv;
45931         invoice_conv.inner = (void*)(invoice & (~1));
45932         invoice_conv.is_owned = false;
45933         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
45934         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45935         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
45936         return (int64_t)ret_conv;
45937 }
45938
45939 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) {
45940         LDKInvoicePayer this_arg_conv;
45941         this_arg_conv.inner = (void*)(this_arg & (~1));
45942         this_arg_conv.is_owned = false;
45943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45944         LDKPublicKey pubkey_ref;
45945         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
45946         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
45947         LDKThirtyTwoBytes payment_preimage_ref;
45948         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
45949         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
45950         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45951         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
45952         return (int64_t)ret_conv;
45953 }
45954
45955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
45956         LDKInvoicePayer this_arg_conv;
45957         this_arg_conv.inner = (void*)(this_arg & (~1));
45958         this_arg_conv.is_owned = false;
45959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45960         unsigned char payment_hash_arr[32];
45961         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
45962         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
45963         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
45964         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
45965 }
45966
45967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
45968         LDKInvoicePayer this_arg_conv;
45969         this_arg_conv.inner = (void*)(this_arg & (~1));
45970         this_arg_conv.is_owned = false;
45971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45972         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
45973         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
45974         return (int64_t)ret_ret;
45975 }
45976
45977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice(JNIEnv *env, jclass clz, int64_t amt_msat, jstring description, int8_tArray payment_hash, int8_tArray payment_secret, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
45978         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
45979         CHECK_ACCESS(amt_msat_ptr);
45980         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
45981         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
45982         LDKStr description_conv = java_to_owned_str(env, description);
45983         LDKThirtyTwoBytes payment_hash_ref;
45984         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
45985         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
45986         LDKThirtyTwoBytes payment_secret_ref;
45987         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
45988         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
45989         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
45990         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
45991         if (phantom_route_hints_constr.datalen > 0)
45992                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
45993         else
45994                 phantom_route_hints_constr.data = NULL;
45995         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
45996         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
45997                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
45998                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
45999                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
46000                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
46001                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
46002                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
46003                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
46004         }
46005         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
46006         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46007         CHECK_ACCESS(keys_manager_ptr);
46008         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46009         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46010                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46011                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46012         }
46013         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46014         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46015         *ret_conv = create_phantom_invoice(amt_msat_conv, description_conv, payment_hash_ref, payment_secret_ref, phantom_route_hints_constr, keys_manager_conv, network_conv);
46016         return (int64_t)ret_conv;
46017 }
46018
46019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice_1with_1description_1hash(JNIEnv *env, jclass clz, int64_t amt_msat, int64_t description_hash, int8_tArray payment_hash, int8_tArray payment_secret, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
46020         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
46021         CHECK_ACCESS(amt_msat_ptr);
46022         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
46023         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
46024         LDKSha256 description_hash_conv;
46025         description_hash_conv.inner = (void*)(description_hash & (~1));
46026         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
46027         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
46028         description_hash_conv = Sha256_clone(&description_hash_conv);
46029         LDKThirtyTwoBytes payment_hash_ref;
46030         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
46031         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
46032         LDKThirtyTwoBytes payment_secret_ref;
46033         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
46034         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
46035         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
46036         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
46037         if (phantom_route_hints_constr.datalen > 0)
46038                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
46039         else
46040                 phantom_route_hints_constr.data = NULL;
46041         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
46042         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
46043                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
46044                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
46045                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
46046                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
46047                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
46048                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
46049                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
46050         }
46051         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
46052         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46053         CHECK_ACCESS(keys_manager_ptr);
46054         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46055         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46056                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46057                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46058         }
46059         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46060         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46061         *ret_conv = create_phantom_invoice_with_description_hash(amt_msat_conv, description_hash_conv, payment_hash_ref, payment_secret_ref, phantom_route_hints_constr, keys_manager_conv, network_conv);
46062         return (int64_t)ret_conv;
46063 }
46064
46065 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) {
46066         LDKChannelManager channelmanager_conv;
46067         channelmanager_conv.inner = (void*)(channelmanager & (~1));
46068         channelmanager_conv.is_owned = false;
46069         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
46070         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46071         CHECK_ACCESS(keys_manager_ptr);
46072         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46073         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46074                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46075                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46076         }
46077         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46078         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
46079         CHECK_ACCESS(amt_msat_ptr);
46080         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
46081         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
46082         LDKStr description_conv = java_to_owned_str(env, description);
46083         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46084         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
46085         return (int64_t)ret_conv;
46086 }
46087
46088 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) {
46089         LDKChannelManager channelmanager_conv;
46090         channelmanager_conv.inner = (void*)(channelmanager & (~1));
46091         channelmanager_conv.is_owned = false;
46092         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
46093         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46094         CHECK_ACCESS(keys_manager_ptr);
46095         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46096         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46097                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46098                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46099         }
46100         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46101         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
46102         CHECK_ACCESS(amt_msat_ptr);
46103         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
46104         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
46105         LDKSha256 description_hash_conv;
46106         description_hash_conv.inner = (void*)(description_hash & (~1));
46107         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
46108         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
46109         description_hash_conv = Sha256_clone(&description_hash_conv);
46110         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46111         *ret_conv = create_invoice_from_channelmanager_with_description_hash(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_hash_conv);
46112         return (int64_t)ret_conv;
46113 }
46114
46115 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) {
46116         LDKChannelManager channelmanager_conv;
46117         channelmanager_conv.inner = (void*)(channelmanager & (~1));
46118         channelmanager_conv.is_owned = false;
46119         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
46120         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46121         CHECK_ACCESS(keys_manager_ptr);
46122         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46123         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46124                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46125                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46126         }
46127         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46128         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
46129         CHECK_ACCESS(amt_msat_ptr);
46130         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
46131         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
46132         LDKSha256 description_hash_conv;
46133         description_hash_conv.inner = (void*)(description_hash & (~1));
46134         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
46135         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
46136         description_hash_conv = Sha256_clone(&description_hash_conv);
46137         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46138         *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);
46139         return (int64_t)ret_conv;
46140 }
46141
46142 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) {
46143         LDKChannelManager channelmanager_conv;
46144         channelmanager_conv.inner = (void*)(channelmanager & (~1));
46145         channelmanager_conv.is_owned = false;
46146         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
46147         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46148         CHECK_ACCESS(keys_manager_ptr);
46149         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46150         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46151                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46152                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46153         }
46154         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46155         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
46156         CHECK_ACCESS(amt_msat_ptr);
46157         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
46158         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
46159         LDKStr description_conv = java_to_owned_str(env, description);
46160         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46161         *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);
46162         return (int64_t)ret_conv;
46163 }
46164
46165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46166         LDKDefaultRouter this_obj_conv;
46167         this_obj_conv.inner = (void*)(this_obj & (~1));
46168         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46170         DefaultRouter_free(this_obj_conv);
46171 }
46172
46173 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) {
46174         LDKNetworkGraph network_graph_conv;
46175         network_graph_conv.inner = (void*)(network_graph & (~1));
46176         network_graph_conv.is_owned = false;
46177         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46178         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
46179         CHECK_ACCESS(logger_ptr);
46180         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46181         if (logger_conv.free == LDKLogger_JCalls_free) {
46182                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46183                 LDKLogger_JCalls_cloned(&logger_conv);
46184         }
46185         LDKThirtyTwoBytes random_seed_bytes_ref;
46186         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
46187         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
46188         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
46189         int64_t ret_ref = 0;
46190         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46191         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46193         ret_ref = (uintptr_t)ret_var.inner;
46194         if (ret_var.is_owned) {
46195                 ret_ref |= 1;
46196         }
46197         return ret_ref;
46198 }
46199
46200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
46201         LDKDefaultRouter this_arg_conv;
46202         this_arg_conv.inner = (void*)(this_arg & (~1));
46203         this_arg_conv.is_owned = false;
46204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46205         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
46206         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
46207         return (int64_t)ret_ret;
46208 }
46209
46210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
46211         LDKChannelManager this_arg_conv;
46212         this_arg_conv.inner = (void*)(this_arg & (~1));
46213         this_arg_conv.is_owned = false;
46214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46215         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
46216         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
46217         return (int64_t)ret_ret;
46218 }
46219
46220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
46221         LDKStr s_conv = java_to_owned_str(env, s);
46222         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
46223         *ret_conv = SiPrefix_from_str(s_conv);
46224         return (int64_t)ret_conv;
46225 }
46226
46227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
46228         LDKStr s_conv = java_to_owned_str(env, s);
46229         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
46230         *ret_conv = Invoice_from_str(s_conv);
46231         return (int64_t)ret_conv;
46232 }
46233
46234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
46235         LDKStr s_conv = java_to_owned_str(env, s);
46236         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
46237         *ret_conv = SignedRawInvoice_from_str(s_conv);
46238         return (int64_t)ret_conv;
46239 }
46240
46241 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46242         LDKParseError* o_conv = (LDKParseError*)o;
46243         LDKStr ret_str = ParseError_to_str(o_conv);
46244         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46245         Str_free(ret_str);
46246         return ret_conv;
46247 }
46248
46249 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46250         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
46251         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
46252         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46253         Str_free(ret_str);
46254         return ret_conv;
46255 }
46256
46257 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46258         LDKInvoice o_conv;
46259         o_conv.inner = (void*)(o & (~1));
46260         o_conv.is_owned = false;
46261         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46262         LDKStr ret_str = Invoice_to_str(&o_conv);
46263         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46264         Str_free(ret_str);
46265         return ret_conv;
46266 }
46267
46268 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46269         LDKSignedRawInvoice o_conv;
46270         o_conv.inner = (void*)(o & (~1));
46271         o_conv.is_owned = false;
46272         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46273         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
46274         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46275         Str_free(ret_str);
46276         return ret_conv;
46277 }
46278
46279 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46280         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
46281         LDKStr ret_str = Currency_to_str(o_conv);
46282         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46283         Str_free(ret_str);
46284         return ret_conv;
46285 }
46286
46287 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46288         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
46289         LDKStr ret_str = SiPrefix_to_str(o_conv);
46290         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46291         Str_free(ret_str);
46292         return ret_conv;
46293 }
46294