Merge pull request #112 from G8XSU/main
[ldk-java] / src / main / jni / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include <jni.h>
4 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
5 #define int64_t jlong
6 #include "org_ldk_impl_bindings.h"
7 #include <lightning.h>
8 #include <string.h>
9 #include <stdatomic.h>
10 #include <stdlib.h>
11
12 #define LIKELY(v) __builtin_expect(!!(v), 1)
13 #define UNLIKELY(v) __builtin_expect(!!(v), 0)
14
15 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
16 #define MALLOC(a, _) malloc(a)
17 #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
18 #define CHECK_ACCESS(p)
19 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
20 #define DO_ASSERT(a) (void)(a)
21 #define CHECK(a)
22
23 static jmethodID ordinal_meth = NULL;
24 static jmethodID slicedef_meth = NULL;
25 static jclass slicedef_cls = NULL;
26 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
27         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
28         CHECK(ordinal_meth != NULL);
29         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
30         CHECK(slicedef_meth != NULL);
31         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
32         CHECK(slicedef_cls != NULL);
33 }
34
35 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
36         return *((bool*)ptr);
37 }
38 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
39         return *((long*)ptr);
40 }
41 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
42         FREE((void*)ptr);
43 }
44 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
45         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
46         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
47         return ret_arr;
48 }
49 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
50         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
51         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
52         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
53         return ret_arr;
54 }
55 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
56         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
57         vec->datalen = (*env)->GetArrayLength(env, bytes);
58         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
59         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
60         return (uint64_t)vec;
61 }
62 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
63         LDKTransaction *txdata = (LDKTransaction*)ptr;
64         LDKu8slice slice;
65         slice.data = txdata->data;
66         slice.datalen = txdata->datalen;
67         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
68 }
69 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
70         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
71         txdata->datalen = (*env)->GetArrayLength(env, bytes);
72         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
73         txdata->data_is_owned = false;
74         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
75         return (uint64_t)txdata;
76 }
77 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
78         LDKTransaction *tx = (LDKTransaction*)ptr;
79         tx->data_is_owned = true;
80         Transaction_free(*tx);
81         FREE((void*)ptr);
82 }
83 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
84         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
85         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
86         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
87         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
88         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
89         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
90         return (uint64_t)vec->datalen;
91 }
92 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
93         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
94         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
95         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
96         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
97         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
98         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
99         vec->data = NULL;
100         vec->datalen = 0;
101         return (uint64_t)vec;
102 }
103
104 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
105 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
106 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
107 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
108
109 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
110 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
111 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
112
113 typedef jlongArray int64_tArray;
114 typedef jbyteArray int8_tArray;
115
116 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
117         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
118         char* conv_buf = MALLOC(len + 1, "str conv buf");
119         memcpy(conv_buf, chars, len);
120         conv_buf[len] = 0;
121         jstring ret = (*env)->NewStringUTF(env, conv_buf);
122         FREE(conv_buf);
123         return ret;
124 }
125 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
126         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
127         char* newchars = MALLOC(str_len + 1, "String chars");
128         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
129         memcpy(newchars, jchars, str_len);
130         newchars[str_len] = 0;
131         (*env)->ReleaseStringUTFChars(env, str, jchars);
132         LDKStr res = {
133                 .chars = newchars,
134                 .len = str_len,
135                 .chars_is_owned = true
136         };
137         return res;
138 }
139
140 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
141         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
142 }
143 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
144         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
145 }
146 #include "version.c"
147 static jclass arr_of_B_clz = NULL;
148 static jclass arr_of_J_clz = NULL;
149 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
150         arr_of_B_clz = (*env)->FindClass(env, "[B");
151         CHECK(arr_of_B_clz != NULL);
152         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
153         arr_of_J_clz = (*env)->FindClass(env, "[J");
154         CHECK(arr_of_J_clz != NULL);
155         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
156 }
157 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
158 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
159         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
160         if (UNLIKELY((*env)->ExceptionCheck(env))) {
161                 (*env)->ExceptionDescribe(env);
162                 (*env)->FatalError(env, "A call to AccessError.ordinal() from rust threw an exception.");
163         }
164         switch (ord) {
165                 case 0: return LDKAccessError_UnknownChain;
166                 case 1: return LDKAccessError_UnknownTx;
167         }
168         (*env)->FatalError(env, "A call to AccessError.ordinal() from rust returned an invalid value.");
169         abort(); // Unreachable, but will let the compiler know we don't return here
170 }
171 static jclass AccessError_class = NULL;
172 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
173 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
174 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
175         AccessError_class = (*env)->NewGlobalRef(env, clz);
176         CHECK(AccessError_class != NULL);
177         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
178         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
179         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
180         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
181 }
182 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
183         switch (val) {
184                 case LDKAccessError_UnknownChain:
185                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
186                 case LDKAccessError_UnknownTx:
187                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
188                 default: abort();
189         }
190 }
191
192 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_java(JNIEnv *env, jclass clz) {
193         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
194         if (UNLIKELY((*env)->ExceptionCheck(env))) {
195                 (*env)->ExceptionDescribe(env);
196                 (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust threw an exception.");
197         }
198         switch (ord) {
199                 case 0: return LDKCOption_NoneZ_Some;
200                 case 1: return LDKCOption_NoneZ_None;
201         }
202         (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust returned an invalid value.");
203         abort(); // Unreachable, but will let the compiler know we don't return here
204 }
205 static jclass COption_NoneZ_class = NULL;
206 static jfieldID COption_NoneZ_LDKCOption_NoneZ_Some = NULL;
207 static jfieldID COption_NoneZ_LDKCOption_NoneZ_None = NULL;
208 JNIEXPORT void JNICALL Java_org_ldk_enums_COption_1NoneZ_init (JNIEnv *env, jclass clz) {
209         COption_NoneZ_class = (*env)->NewGlobalRef(env, clz);
210         CHECK(COption_NoneZ_class != NULL);
211         COption_NoneZ_LDKCOption_NoneZ_Some = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_Some", "Lorg/ldk/enums/COption_NoneZ;");
212         CHECK(COption_NoneZ_LDKCOption_NoneZ_Some != NULL);
213         COption_NoneZ_LDKCOption_NoneZ_None = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_None", "Lorg/ldk/enums/COption_NoneZ;");
214         CHECK(COption_NoneZ_LDKCOption_NoneZ_None != NULL);
215 }
216 static inline jclass LDKCOption_NoneZ_to_java(JNIEnv *env, LDKCOption_NoneZ val) {
217         switch (val) {
218                 case LDKCOption_NoneZ_Some:
219                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_Some);
220                 case LDKCOption_NoneZ_None:
221                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_None);
222                 default: abort();
223         }
224 }
225
226 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
227         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
228         if (UNLIKELY((*env)->ExceptionCheck(env))) {
229                 (*env)->ExceptionDescribe(env);
230                 (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust threw an exception.");
231         }
232         switch (ord) {
233                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
234                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
235         }
236         (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust returned an invalid value.");
237         abort(); // Unreachable, but will let the compiler know we don't return here
238 }
239 static jclass ChannelMonitorUpdateErr_class = NULL;
240 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
241 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
242 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
243         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
244         CHECK(ChannelMonitorUpdateErr_class != NULL);
245         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
246         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
247         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
248         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
249 }
250 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
251         switch (val) {
252                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
253                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
254                 case LDKChannelMonitorUpdateErr_PermanentFailure:
255                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
256                 default: abort();
257         }
258 }
259
260 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
261         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
262         if (UNLIKELY((*env)->ExceptionCheck(env))) {
263                 (*env)->ExceptionDescribe(env);
264                 (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust threw an exception.");
265         }
266         switch (ord) {
267                 case 0: return LDKConfirmationTarget_Background;
268                 case 1: return LDKConfirmationTarget_Normal;
269                 case 2: return LDKConfirmationTarget_HighPriority;
270         }
271         (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust returned an invalid value.");
272         abort(); // Unreachable, but will let the compiler know we don't return here
273 }
274 static jclass ConfirmationTarget_class = NULL;
275 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
276 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
277 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
278 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
279         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
280         CHECK(ConfirmationTarget_class != NULL);
281         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
282         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
283         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
284         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
285         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
286         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
287 }
288 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
289         switch (val) {
290                 case LDKConfirmationTarget_Background:
291                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
292                 case LDKConfirmationTarget_Normal:
293                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
294                 case LDKConfirmationTarget_HighPriority:
295                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
296                 default: abort();
297         }
298 }
299
300 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
301         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
302         if (UNLIKELY((*env)->ExceptionCheck(env))) {
303                 (*env)->ExceptionDescribe(env);
304                 (*env)->FatalError(env, "A call to CreationError.ordinal() from rust threw an exception.");
305         }
306         switch (ord) {
307                 case 0: return LDKCreationError_DescriptionTooLong;
308                 case 1: return LDKCreationError_RouteTooLong;
309                 case 2: return LDKCreationError_TimestampOutOfBounds;
310                 case 3: return LDKCreationError_InvalidAmount;
311                 case 4: return LDKCreationError_MissingRouteHints;
312         }
313         (*env)->FatalError(env, "A call to CreationError.ordinal() from rust returned an invalid value.");
314         abort(); // Unreachable, but will let the compiler know we don't return here
315 }
316 static jclass CreationError_class = NULL;
317 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
318 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
319 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
320 static jfieldID CreationError_LDKCreationError_InvalidAmount = NULL;
321 static jfieldID CreationError_LDKCreationError_MissingRouteHints = NULL;
322 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
323         CreationError_class = (*env)->NewGlobalRef(env, clz);
324         CHECK(CreationError_class != NULL);
325         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
326         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
327         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
328         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
329         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
330         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
331         CreationError_LDKCreationError_InvalidAmount = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_InvalidAmount", "Lorg/ldk/enums/CreationError;");
332         CHECK(CreationError_LDKCreationError_InvalidAmount != NULL);
333         CreationError_LDKCreationError_MissingRouteHints = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_MissingRouteHints", "Lorg/ldk/enums/CreationError;");
334         CHECK(CreationError_LDKCreationError_MissingRouteHints != NULL);
335 }
336 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
337         switch (val) {
338                 case LDKCreationError_DescriptionTooLong:
339                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
340                 case LDKCreationError_RouteTooLong:
341                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
342                 case LDKCreationError_TimestampOutOfBounds:
343                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
344                 case LDKCreationError_InvalidAmount:
345                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_InvalidAmount);
346                 case LDKCreationError_MissingRouteHints:
347                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_MissingRouteHints);
348                 default: abort();
349         }
350 }
351
352 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
353         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
354         if (UNLIKELY((*env)->ExceptionCheck(env))) {
355                 (*env)->ExceptionDescribe(env);
356                 (*env)->FatalError(env, "A call to Currency.ordinal() from rust threw an exception.");
357         }
358         switch (ord) {
359                 case 0: return LDKCurrency_Bitcoin;
360                 case 1: return LDKCurrency_BitcoinTestnet;
361                 case 2: return LDKCurrency_Regtest;
362                 case 3: return LDKCurrency_Simnet;
363                 case 4: return LDKCurrency_Signet;
364         }
365         (*env)->FatalError(env, "A call to Currency.ordinal() from rust returned an invalid value.");
366         abort(); // Unreachable, but will let the compiler know we don't return here
367 }
368 static jclass Currency_class = NULL;
369 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
370 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
371 static jfieldID Currency_LDKCurrency_Regtest = NULL;
372 static jfieldID Currency_LDKCurrency_Simnet = NULL;
373 static jfieldID Currency_LDKCurrency_Signet = NULL;
374 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
375         Currency_class = (*env)->NewGlobalRef(env, clz);
376         CHECK(Currency_class != NULL);
377         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
378         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
379         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
380         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
381         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
382         CHECK(Currency_LDKCurrency_Regtest != NULL);
383         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
384         CHECK(Currency_LDKCurrency_Simnet != NULL);
385         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
386         CHECK(Currency_LDKCurrency_Signet != NULL);
387 }
388 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
389         switch (val) {
390                 case LDKCurrency_Bitcoin:
391                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
392                 case LDKCurrency_BitcoinTestnet:
393                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
394                 case LDKCurrency_Regtest:
395                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
396                 case LDKCurrency_Simnet:
397                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
398                 case LDKCurrency_Signet:
399                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
400                 default: abort();
401         }
402 }
403
404 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
405         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
406         if (UNLIKELY((*env)->ExceptionCheck(env))) {
407                 (*env)->ExceptionDescribe(env);
408                 (*env)->FatalError(env, "A call to IOError.ordinal() from rust threw an exception.");
409         }
410         switch (ord) {
411                 case 0: return LDKIOError_NotFound;
412                 case 1: return LDKIOError_PermissionDenied;
413                 case 2: return LDKIOError_ConnectionRefused;
414                 case 3: return LDKIOError_ConnectionReset;
415                 case 4: return LDKIOError_ConnectionAborted;
416                 case 5: return LDKIOError_NotConnected;
417                 case 6: return LDKIOError_AddrInUse;
418                 case 7: return LDKIOError_AddrNotAvailable;
419                 case 8: return LDKIOError_BrokenPipe;
420                 case 9: return LDKIOError_AlreadyExists;
421                 case 10: return LDKIOError_WouldBlock;
422                 case 11: return LDKIOError_InvalidInput;
423                 case 12: return LDKIOError_InvalidData;
424                 case 13: return LDKIOError_TimedOut;
425                 case 14: return LDKIOError_WriteZero;
426                 case 15: return LDKIOError_Interrupted;
427                 case 16: return LDKIOError_Other;
428                 case 17: return LDKIOError_UnexpectedEof;
429         }
430         (*env)->FatalError(env, "A call to IOError.ordinal() from rust returned an invalid value.");
431         abort(); // Unreachable, but will let the compiler know we don't return here
432 }
433 static jclass IOError_class = NULL;
434 static jfieldID IOError_LDKIOError_NotFound = NULL;
435 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
436 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
437 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
438 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
439 static jfieldID IOError_LDKIOError_NotConnected = NULL;
440 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
441 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
442 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
443 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
444 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
445 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
446 static jfieldID IOError_LDKIOError_InvalidData = NULL;
447 static jfieldID IOError_LDKIOError_TimedOut = NULL;
448 static jfieldID IOError_LDKIOError_WriteZero = NULL;
449 static jfieldID IOError_LDKIOError_Interrupted = NULL;
450 static jfieldID IOError_LDKIOError_Other = NULL;
451 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
452 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
453         IOError_class = (*env)->NewGlobalRef(env, clz);
454         CHECK(IOError_class != NULL);
455         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
456         CHECK(IOError_LDKIOError_NotFound != NULL);
457         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
458         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
459         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
460         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
461         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
462         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
463         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
464         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
465         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
466         CHECK(IOError_LDKIOError_NotConnected != NULL);
467         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
468         CHECK(IOError_LDKIOError_AddrInUse != NULL);
469         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
470         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
471         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
472         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
473         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
474         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
475         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
476         CHECK(IOError_LDKIOError_WouldBlock != NULL);
477         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
478         CHECK(IOError_LDKIOError_InvalidInput != NULL);
479         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
480         CHECK(IOError_LDKIOError_InvalidData != NULL);
481         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
482         CHECK(IOError_LDKIOError_TimedOut != NULL);
483         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
484         CHECK(IOError_LDKIOError_WriteZero != NULL);
485         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
486         CHECK(IOError_LDKIOError_Interrupted != NULL);
487         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
488         CHECK(IOError_LDKIOError_Other != NULL);
489         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
490         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
491 }
492 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
493         switch (val) {
494                 case LDKIOError_NotFound:
495                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
496                 case LDKIOError_PermissionDenied:
497                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
498                 case LDKIOError_ConnectionRefused:
499                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
500                 case LDKIOError_ConnectionReset:
501                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
502                 case LDKIOError_ConnectionAborted:
503                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
504                 case LDKIOError_NotConnected:
505                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
506                 case LDKIOError_AddrInUse:
507                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
508                 case LDKIOError_AddrNotAvailable:
509                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
510                 case LDKIOError_BrokenPipe:
511                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
512                 case LDKIOError_AlreadyExists:
513                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
514                 case LDKIOError_WouldBlock:
515                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
516                 case LDKIOError_InvalidInput:
517                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
518                 case LDKIOError_InvalidData:
519                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
520                 case LDKIOError_TimedOut:
521                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
522                 case LDKIOError_WriteZero:
523                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
524                 case LDKIOError_Interrupted:
525                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
526                 case LDKIOError_Other:
527                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
528                 case LDKIOError_UnexpectedEof:
529                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
530                 default: abort();
531         }
532 }
533
534 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
535         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
536         if (UNLIKELY((*env)->ExceptionCheck(env))) {
537                 (*env)->ExceptionDescribe(env);
538                 (*env)->FatalError(env, "A call to Level.ordinal() from rust threw an exception.");
539         }
540         switch (ord) {
541                 case 0: return LDKLevel_Gossip;
542                 case 1: return LDKLevel_Trace;
543                 case 2: return LDKLevel_Debug;
544                 case 3: return LDKLevel_Info;
545                 case 4: return LDKLevel_Warn;
546                 case 5: return LDKLevel_Error;
547         }
548         (*env)->FatalError(env, "A call to Level.ordinal() from rust returned an invalid value.");
549         abort(); // Unreachable, but will let the compiler know we don't return here
550 }
551 static jclass Level_class = NULL;
552 static jfieldID Level_LDKLevel_Gossip = NULL;
553 static jfieldID Level_LDKLevel_Trace = NULL;
554 static jfieldID Level_LDKLevel_Debug = NULL;
555 static jfieldID Level_LDKLevel_Info = NULL;
556 static jfieldID Level_LDKLevel_Warn = NULL;
557 static jfieldID Level_LDKLevel_Error = NULL;
558 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
559         Level_class = (*env)->NewGlobalRef(env, clz);
560         CHECK(Level_class != NULL);
561         Level_LDKLevel_Gossip = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Gossip", "Lorg/ldk/enums/Level;");
562         CHECK(Level_LDKLevel_Gossip != NULL);
563         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
564         CHECK(Level_LDKLevel_Trace != NULL);
565         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
566         CHECK(Level_LDKLevel_Debug != NULL);
567         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
568         CHECK(Level_LDKLevel_Info != NULL);
569         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
570         CHECK(Level_LDKLevel_Warn != NULL);
571         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
572         CHECK(Level_LDKLevel_Error != NULL);
573 }
574 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
575         switch (val) {
576                 case LDKLevel_Gossip:
577                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Gossip);
578                 case LDKLevel_Trace:
579                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
580                 case LDKLevel_Debug:
581                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
582                 case LDKLevel_Info:
583                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
584                 case LDKLevel_Warn:
585                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
586                 case LDKLevel_Error:
587                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
588                 default: abort();
589         }
590 }
591
592 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
593         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
594         if (UNLIKELY((*env)->ExceptionCheck(env))) {
595                 (*env)->ExceptionDescribe(env);
596                 (*env)->FatalError(env, "A call to Network.ordinal() from rust threw an exception.");
597         }
598         switch (ord) {
599                 case 0: return LDKNetwork_Bitcoin;
600                 case 1: return LDKNetwork_Testnet;
601                 case 2: return LDKNetwork_Regtest;
602                 case 3: return LDKNetwork_Signet;
603         }
604         (*env)->FatalError(env, "A call to Network.ordinal() from rust returned an invalid value.");
605         abort(); // Unreachable, but will let the compiler know we don't return here
606 }
607 static jclass Network_class = NULL;
608 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
609 static jfieldID Network_LDKNetwork_Testnet = NULL;
610 static jfieldID Network_LDKNetwork_Regtest = NULL;
611 static jfieldID Network_LDKNetwork_Signet = NULL;
612 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
613         Network_class = (*env)->NewGlobalRef(env, clz);
614         CHECK(Network_class != NULL);
615         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
616         CHECK(Network_LDKNetwork_Bitcoin != NULL);
617         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
618         CHECK(Network_LDKNetwork_Testnet != NULL);
619         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
620         CHECK(Network_LDKNetwork_Regtest != NULL);
621         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
622         CHECK(Network_LDKNetwork_Signet != NULL);
623 }
624 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
625         switch (val) {
626                 case LDKNetwork_Bitcoin:
627                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
628                 case LDKNetwork_Testnet:
629                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
630                 case LDKNetwork_Regtest:
631                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
632                 case LDKNetwork_Signet:
633                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
634                 default: abort();
635         }
636 }
637
638 static inline LDKRecipient LDKRecipient_from_java(JNIEnv *env, jclass clz) {
639         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
640         if (UNLIKELY((*env)->ExceptionCheck(env))) {
641                 (*env)->ExceptionDescribe(env);
642                 (*env)->FatalError(env, "A call to Recipient.ordinal() from rust threw an exception.");
643         }
644         switch (ord) {
645                 case 0: return LDKRecipient_Node;
646                 case 1: return LDKRecipient_PhantomNode;
647         }
648         (*env)->FatalError(env, "A call to Recipient.ordinal() from rust returned an invalid value.");
649         abort(); // Unreachable, but will let the compiler know we don't return here
650 }
651 static jclass Recipient_class = NULL;
652 static jfieldID Recipient_LDKRecipient_Node = NULL;
653 static jfieldID Recipient_LDKRecipient_PhantomNode = NULL;
654 JNIEXPORT void JNICALL Java_org_ldk_enums_Recipient_init (JNIEnv *env, jclass clz) {
655         Recipient_class = (*env)->NewGlobalRef(env, clz);
656         CHECK(Recipient_class != NULL);
657         Recipient_LDKRecipient_Node = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_Node", "Lorg/ldk/enums/Recipient;");
658         CHECK(Recipient_LDKRecipient_Node != NULL);
659         Recipient_LDKRecipient_PhantomNode = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_PhantomNode", "Lorg/ldk/enums/Recipient;");
660         CHECK(Recipient_LDKRecipient_PhantomNode != NULL);
661 }
662 static inline jclass LDKRecipient_to_java(JNIEnv *env, LDKRecipient val) {
663         switch (val) {
664                 case LDKRecipient_Node:
665                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_Node);
666                 case LDKRecipient_PhantomNode:
667                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_PhantomNode);
668                 default: abort();
669         }
670 }
671
672 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
673         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
674         if (UNLIKELY((*env)->ExceptionCheck(env))) {
675                 (*env)->ExceptionDescribe(env);
676                 (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust threw an exception.");
677         }
678         switch (ord) {
679                 case 0: return LDKSecp256k1Error_IncorrectSignature;
680                 case 1: return LDKSecp256k1Error_InvalidMessage;
681                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
682                 case 3: return LDKSecp256k1Error_InvalidSignature;
683                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
684                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
685                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
686                 case 7: return LDKSecp256k1Error_InvalidTweak;
687                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
688                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
689                 case 10: return LDKSecp256k1Error_InvalidParityValue;
690         }
691         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
692         abort(); // Unreachable, but will let the compiler know we don't return here
693 }
694 static jclass Secp256k1Error_class = NULL;
695 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
696 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
697 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
698 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
699 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
700 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = NULL;
701 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
702 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
703 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
704 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = NULL;
705 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = NULL;
706 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
707         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
708         CHECK(Secp256k1Error_class != NULL);
709         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
710         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
711         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
712         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
713         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
714         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
715         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
716         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
717         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
718         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
719         Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSharedSecret", "Lorg/ldk/enums/Secp256k1Error;");
720         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret != NULL);
721         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
722         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
723         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
724         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
725         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
726         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
727         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKeySum", "Lorg/ldk/enums/Secp256k1Error;");
728         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum != NULL);
729         Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidParityValue", "Lorg/ldk/enums/Secp256k1Error;");
730         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidParityValue != NULL);
731 }
732 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
733         switch (val) {
734                 case LDKSecp256k1Error_IncorrectSignature:
735                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
736                 case LDKSecp256k1Error_InvalidMessage:
737                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
738                 case LDKSecp256k1Error_InvalidPublicKey:
739                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
740                 case LDKSecp256k1Error_InvalidSignature:
741                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
742                 case LDKSecp256k1Error_InvalidSecretKey:
743                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
744                 case LDKSecp256k1Error_InvalidSharedSecret:
745                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret);
746                 case LDKSecp256k1Error_InvalidRecoveryId:
747                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
748                 case LDKSecp256k1Error_InvalidTweak:
749                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
750                 case LDKSecp256k1Error_NotEnoughMemory:
751                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
752                 case LDKSecp256k1Error_InvalidPublicKeySum:
753                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum);
754                 case LDKSecp256k1Error_InvalidParityValue:
755                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidParityValue);
756                 default: abort();
757         }
758 }
759
760 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
761         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
762         if (UNLIKELY((*env)->ExceptionCheck(env))) {
763                 (*env)->ExceptionDescribe(env);
764                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
765         }
766         switch (ord) {
767                 case 0: return LDKSemanticError_NoPaymentHash;
768                 case 1: return LDKSemanticError_MultiplePaymentHashes;
769                 case 2: return LDKSemanticError_NoDescription;
770                 case 3: return LDKSemanticError_MultipleDescriptions;
771                 case 4: return LDKSemanticError_NoPaymentSecret;
772                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
773                 case 6: return LDKSemanticError_InvalidFeatures;
774                 case 7: return LDKSemanticError_InvalidRecoveryId;
775                 case 8: return LDKSemanticError_InvalidSignature;
776                 case 9: return LDKSemanticError_ImpreciseAmount;
777         }
778         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
779         abort(); // Unreachable, but will let the compiler know we don't return here
780 }
781 static jclass SemanticError_class = NULL;
782 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
783 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
784 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
785 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
786 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
787 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
788 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
789 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
790 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
791 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
792 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
793         SemanticError_class = (*env)->NewGlobalRef(env, clz);
794         CHECK(SemanticError_class != NULL);
795         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
796         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
797         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
798         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
799         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
800         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
801         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
802         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
803         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
804         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
805         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
806         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
807         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
808         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
809         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
810         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
811         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
812         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
813         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
814         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
815 }
816 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
817         switch (val) {
818                 case LDKSemanticError_NoPaymentHash:
819                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
820                 case LDKSemanticError_MultiplePaymentHashes:
821                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
822                 case LDKSemanticError_NoDescription:
823                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
824                 case LDKSemanticError_MultipleDescriptions:
825                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
826                 case LDKSemanticError_NoPaymentSecret:
827                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
828                 case LDKSemanticError_MultiplePaymentSecrets:
829                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
830                 case LDKSemanticError_InvalidFeatures:
831                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
832                 case LDKSemanticError_InvalidRecoveryId:
833                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
834                 case LDKSemanticError_InvalidSignature:
835                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
836                 case LDKSemanticError_ImpreciseAmount:
837                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
838                 default: abort();
839         }
840 }
841
842 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
843         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
844         if (UNLIKELY((*env)->ExceptionCheck(env))) {
845                 (*env)->ExceptionDescribe(env);
846                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
847         }
848         switch (ord) {
849                 case 0: return LDKSiPrefix_Milli;
850                 case 1: return LDKSiPrefix_Micro;
851                 case 2: return LDKSiPrefix_Nano;
852                 case 3: return LDKSiPrefix_Pico;
853         }
854         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
855         abort(); // Unreachable, but will let the compiler know we don't return here
856 }
857 static jclass SiPrefix_class = NULL;
858 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
859 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
860 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
861 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
862 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
863         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
864         CHECK(SiPrefix_class != NULL);
865         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
866         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
867         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
868         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
869         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
870         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
871         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
872         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
873 }
874 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
875         switch (val) {
876                 case LDKSiPrefix_Milli:
877                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
878                 case LDKSiPrefix_Micro:
879                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
880                 case LDKSiPrefix_Nano:
881                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
882                 case LDKSiPrefix_Pico:
883                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
884                 default: abort();
885         }
886 }
887
888 static jclass LDKBech32Error_MissingSeparator_class = NULL;
889 static jmethodID LDKBech32Error_MissingSeparator_meth = NULL;
890 static jclass LDKBech32Error_InvalidChecksum_class = NULL;
891 static jmethodID LDKBech32Error_InvalidChecksum_meth = NULL;
892 static jclass LDKBech32Error_InvalidLength_class = NULL;
893 static jmethodID LDKBech32Error_InvalidLength_meth = NULL;
894 static jclass LDKBech32Error_InvalidChar_class = NULL;
895 static jmethodID LDKBech32Error_InvalidChar_meth = NULL;
896 static jclass LDKBech32Error_InvalidData_class = NULL;
897 static jmethodID LDKBech32Error_InvalidData_meth = NULL;
898 static jclass LDKBech32Error_InvalidPadding_class = NULL;
899 static jmethodID LDKBech32Error_InvalidPadding_meth = NULL;
900 static jclass LDKBech32Error_MixedCase_class = NULL;
901 static jmethodID LDKBech32Error_MixedCase_meth = NULL;
902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBech32Error_init (JNIEnv *env, jclass clz) {
903         LDKBech32Error_MissingSeparator_class =
904                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MissingSeparator"));
905         CHECK(LDKBech32Error_MissingSeparator_class != NULL);
906         LDKBech32Error_MissingSeparator_meth = (*env)->GetMethodID(env, LDKBech32Error_MissingSeparator_class, "<init>", "()V");
907         CHECK(LDKBech32Error_MissingSeparator_meth != NULL);
908         LDKBech32Error_InvalidChecksum_class =
909                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChecksum"));
910         CHECK(LDKBech32Error_InvalidChecksum_class != NULL);
911         LDKBech32Error_InvalidChecksum_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChecksum_class, "<init>", "()V");
912         CHECK(LDKBech32Error_InvalidChecksum_meth != NULL);
913         LDKBech32Error_InvalidLength_class =
914                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidLength"));
915         CHECK(LDKBech32Error_InvalidLength_class != NULL);
916         LDKBech32Error_InvalidLength_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidLength_class, "<init>", "()V");
917         CHECK(LDKBech32Error_InvalidLength_meth != NULL);
918         LDKBech32Error_InvalidChar_class =
919                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChar"));
920         CHECK(LDKBech32Error_InvalidChar_class != NULL);
921         LDKBech32Error_InvalidChar_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChar_class, "<init>", "(I)V");
922         CHECK(LDKBech32Error_InvalidChar_meth != NULL);
923         LDKBech32Error_InvalidData_class =
924                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidData"));
925         CHECK(LDKBech32Error_InvalidData_class != NULL);
926         LDKBech32Error_InvalidData_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidData_class, "<init>", "(B)V");
927         CHECK(LDKBech32Error_InvalidData_meth != NULL);
928         LDKBech32Error_InvalidPadding_class =
929                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidPadding"));
930         CHECK(LDKBech32Error_InvalidPadding_class != NULL);
931         LDKBech32Error_InvalidPadding_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidPadding_class, "<init>", "()V");
932         CHECK(LDKBech32Error_InvalidPadding_meth != NULL);
933         LDKBech32Error_MixedCase_class =
934                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MixedCase"));
935         CHECK(LDKBech32Error_MixedCase_class != NULL);
936         LDKBech32Error_MixedCase_meth = (*env)->GetMethodID(env, LDKBech32Error_MixedCase_class, "<init>", "()V");
937         CHECK(LDKBech32Error_MixedCase_meth != NULL);
938 }
939 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBech32Error_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
940         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
941         switch(obj->tag) {
942                 case LDKBech32Error_MissingSeparator: {
943                         return (*env)->NewObject(env, LDKBech32Error_MissingSeparator_class, LDKBech32Error_MissingSeparator_meth);
944                 }
945                 case LDKBech32Error_InvalidChecksum: {
946                         return (*env)->NewObject(env, LDKBech32Error_InvalidChecksum_class, LDKBech32Error_InvalidChecksum_meth);
947                 }
948                 case LDKBech32Error_InvalidLength: {
949                         return (*env)->NewObject(env, LDKBech32Error_InvalidLength_class, LDKBech32Error_InvalidLength_meth);
950                 }
951                 case LDKBech32Error_InvalidChar: {
952                         int32_t invalid_char_conv = obj->invalid_char;
953                         return (*env)->NewObject(env, LDKBech32Error_InvalidChar_class, LDKBech32Error_InvalidChar_meth, invalid_char_conv);
954                 }
955                 case LDKBech32Error_InvalidData: {
956                         int8_t invalid_data_conv = obj->invalid_data;
957                         return (*env)->NewObject(env, LDKBech32Error_InvalidData_class, LDKBech32Error_InvalidData_meth, invalid_data_conv);
958                 }
959                 case LDKBech32Error_InvalidPadding: {
960                         return (*env)->NewObject(env, LDKBech32Error_InvalidPadding_class, LDKBech32Error_InvalidPadding_meth);
961                 }
962                 case LDKBech32Error_MixedCase: {
963                         return (*env)->NewObject(env, LDKBech32Error_MixedCase_class, LDKBech32Error_MixedCase_meth);
964                 }
965                 default: abort();
966         }
967 }
968 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
969         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
970         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
971         return ret;
972 }
973 struct LDKCVec_u8Z TxOut_get_script_pubkey (struct LDKTxOut* thing) {   return CVec_u8Z_clone(&thing->script_pubkey);}JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxOut_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t thing) {
974         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
975         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
976         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
977         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
978         CVec_u8Z_free(ret_var);
979         return ret_arr;
980 }
981
982 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1get_1value(JNIEnv *env, jclass clz, int64_t thing) {
983         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
984         int64_t ret_conv = TxOut_get_value(thing_conv);
985         return ret_conv;
986 }
987
988 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
989 CHECK(owner->result_ok);
990         return *owner->contents.result;
991 }
992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
993         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
994         CResult_NoneNoneZ_get_ok(owner_conv);
995 }
996
997 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
998 CHECK(!owner->result_ok);
999         return *owner->contents.err;
1000 }
1001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1002         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
1003         CResult_NoneNoneZ_get_err(owner_conv);
1004 }
1005
1006 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1007 CHECK(owner->result_ok);
1008         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
1009 }
1010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1011         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
1012         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
1013         int64_t ret_ref = 0;
1014         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1015         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1017         ret_ref = (uintptr_t)ret_var.inner;
1018         if (ret_var.is_owned) {
1019                 ret_ref |= 1;
1020         }
1021         return ret_ref;
1022 }
1023
1024 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1025 CHECK(!owner->result_ok);
1026         return DecodeError_clone(&*owner->contents.err);
1027 }
1028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1029         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
1030         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
1031         int64_t ret_ref = 0;
1032         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1033         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1035         ret_ref = (uintptr_t)ret_var.inner;
1036         if (ret_var.is_owned) {
1037                 ret_ref |= 1;
1038         }
1039         return ret_ref;
1040 }
1041
1042 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1043 CHECK(owner->result_ok);
1044         return *owner->contents.result;
1045 }
1046 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1047         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
1048         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1049         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes);
1050         return ret_arr;
1051 }
1052
1053 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1054 CHECK(!owner->result_ok);
1055         return *owner->contents.err;
1056 }
1057 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1058         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
1059         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_SecretKeyErrorZ_get_err(owner_conv));
1060         return ret_conv;
1061 }
1062
1063 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1064 CHECK(owner->result_ok);
1065         return *owner->contents.result;
1066 }
1067 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1068         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
1069         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
1070         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
1071         return ret_arr;
1072 }
1073
1074 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1075 CHECK(!owner->result_ok);
1076         return *owner->contents.err;
1077 }
1078 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1079         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
1080         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
1081         return ret_conv;
1082 }
1083
1084 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1085 CHECK(owner->result_ok);
1086         return TxCreationKeys_clone(&*owner->contents.result);
1087 }
1088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1089         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1090         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
1091         int64_t ret_ref = 0;
1092         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1093         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1095         ret_ref = (uintptr_t)ret_var.inner;
1096         if (ret_var.is_owned) {
1097                 ret_ref |= 1;
1098         }
1099         return ret_ref;
1100 }
1101
1102 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1103 CHECK(!owner->result_ok);
1104         return DecodeError_clone(&*owner->contents.err);
1105 }
1106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1107         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1108         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1109         int64_t ret_ref = 0;
1110         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1111         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1113         ret_ref = (uintptr_t)ret_var.inner;
1114         if (ret_var.is_owned) {
1115                 ret_ref |= 1;
1116         }
1117         return ret_ref;
1118 }
1119
1120 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1121 CHECK(owner->result_ok);
1122         return ChannelPublicKeys_clone(&*owner->contents.result);
1123 }
1124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1125         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1126         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1127         int64_t ret_ref = 0;
1128         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1129         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1131         ret_ref = (uintptr_t)ret_var.inner;
1132         if (ret_var.is_owned) {
1133                 ret_ref |= 1;
1134         }
1135         return ret_ref;
1136 }
1137
1138 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1139 CHECK(!owner->result_ok);
1140         return DecodeError_clone(&*owner->contents.err);
1141 }
1142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1143         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1144         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1145         int64_t ret_ref = 0;
1146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1149         ret_ref = (uintptr_t)ret_var.inner;
1150         if (ret_var.is_owned) {
1151                 ret_ref |= 1;
1152         }
1153         return ret_ref;
1154 }
1155
1156 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1157 CHECK(owner->result_ok);
1158         return TxCreationKeys_clone(&*owner->contents.result);
1159 }
1160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1161         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1162         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
1163         int64_t ret_ref = 0;
1164         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1165         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1167         ret_ref = (uintptr_t)ret_var.inner;
1168         if (ret_var.is_owned) {
1169                 ret_ref |= 1;
1170         }
1171         return ret_ref;
1172 }
1173
1174 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1175 CHECK(!owner->result_ok);
1176         return *owner->contents.err;
1177 }
1178 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1179         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1180         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_TxCreationKeysErrorZ_get_err(owner_conv));
1181         return ret_conv;
1182 }
1183
1184 static jclass LDKCOption_u32Z_Some_class = NULL;
1185 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1186 static jclass LDKCOption_u32Z_None_class = NULL;
1187 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1189         LDKCOption_u32Z_Some_class =
1190                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1191         CHECK(LDKCOption_u32Z_Some_class != NULL);
1192         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1193         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1194         LDKCOption_u32Z_None_class =
1195                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1196         CHECK(LDKCOption_u32Z_None_class != NULL);
1197         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1198         CHECK(LDKCOption_u32Z_None_meth != NULL);
1199 }
1200 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1201         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
1202         switch(obj->tag) {
1203                 case LDKCOption_u32Z_Some: {
1204                         int32_t some_conv = obj->some;
1205                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, some_conv);
1206                 }
1207                 case LDKCOption_u32Z_None: {
1208                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1209                 }
1210                 default: abort();
1211         }
1212 }
1213 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1214 CHECK(owner->result_ok);
1215         return HTLCOutputInCommitment_clone(&*owner->contents.result);
1216 }
1217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1218         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1219         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1220         int64_t ret_ref = 0;
1221         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1222         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1224         ret_ref = (uintptr_t)ret_var.inner;
1225         if (ret_var.is_owned) {
1226                 ret_ref |= 1;
1227         }
1228         return ret_ref;
1229 }
1230
1231 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1232 CHECK(!owner->result_ok);
1233         return DecodeError_clone(&*owner->contents.err);
1234 }
1235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1236         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1237         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1238         int64_t ret_ref = 0;
1239         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1240         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1242         ret_ref = (uintptr_t)ret_var.inner;
1243         if (ret_var.is_owned) {
1244                 ret_ref |= 1;
1245         }
1246         return ret_ref;
1247 }
1248
1249 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1250 CHECK(owner->result_ok);
1251         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
1252 }
1253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1254         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1255         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1256         int64_t ret_ref = 0;
1257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1260         ret_ref = (uintptr_t)ret_var.inner;
1261         if (ret_var.is_owned) {
1262                 ret_ref |= 1;
1263         }
1264         return ret_ref;
1265 }
1266
1267 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1268 CHECK(!owner->result_ok);
1269         return DecodeError_clone(&*owner->contents.err);
1270 }
1271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1272         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1273         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1274         int64_t ret_ref = 0;
1275         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1276         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1278         ret_ref = (uintptr_t)ret_var.inner;
1279         if (ret_var.is_owned) {
1280                 ret_ref |= 1;
1281         }
1282         return ret_ref;
1283 }
1284
1285 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1286 CHECK(owner->result_ok);
1287         return ChannelTransactionParameters_clone(&*owner->contents.result);
1288 }
1289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1290         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1291         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1292         int64_t ret_ref = 0;
1293         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1294         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1296         ret_ref = (uintptr_t)ret_var.inner;
1297         if (ret_var.is_owned) {
1298                 ret_ref |= 1;
1299         }
1300         return ret_ref;
1301 }
1302
1303 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1304 CHECK(!owner->result_ok);
1305         return DecodeError_clone(&*owner->contents.err);
1306 }
1307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1308         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1309         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1310         int64_t ret_ref = 0;
1311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1314         ret_ref = (uintptr_t)ret_var.inner;
1315         if (ret_var.is_owned) {
1316                 ret_ref |= 1;
1317         }
1318         return ret_ref;
1319 }
1320
1321 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1322 CHECK(owner->result_ok);
1323         return HolderCommitmentTransaction_clone(&*owner->contents.result);
1324 }
1325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1326         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1327         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1328         int64_t ret_ref = 0;
1329         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1330         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1332         ret_ref = (uintptr_t)ret_var.inner;
1333         if (ret_var.is_owned) {
1334                 ret_ref |= 1;
1335         }
1336         return ret_ref;
1337 }
1338
1339 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1340 CHECK(!owner->result_ok);
1341         return DecodeError_clone(&*owner->contents.err);
1342 }
1343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1344         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1345         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1346         int64_t ret_ref = 0;
1347         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1348         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1350         ret_ref = (uintptr_t)ret_var.inner;
1351         if (ret_var.is_owned) {
1352                 ret_ref |= 1;
1353         }
1354         return ret_ref;
1355 }
1356
1357 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1358 CHECK(owner->result_ok);
1359         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
1360 }
1361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1362         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1363         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1364         int64_t ret_ref = 0;
1365         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1366         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1368         ret_ref = (uintptr_t)ret_var.inner;
1369         if (ret_var.is_owned) {
1370                 ret_ref |= 1;
1371         }
1372         return ret_ref;
1373 }
1374
1375 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1376 CHECK(!owner->result_ok);
1377         return DecodeError_clone(&*owner->contents.err);
1378 }
1379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1380         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1381         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1382         int64_t ret_ref = 0;
1383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1386         ret_ref = (uintptr_t)ret_var.inner;
1387         if (ret_var.is_owned) {
1388                 ret_ref |= 1;
1389         }
1390         return ret_ref;
1391 }
1392
1393 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1394 CHECK(owner->result_ok);
1395         return &*owner->contents.result;
1396 }
1397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1398         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1399         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1400         int64_t ret_ref = 0;
1401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1404         ret_ref = (uintptr_t)ret_var.inner & ~1;
1405         return ret_ref;
1406 }
1407
1408 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1409 CHECK(!owner->result_ok);
1410         return *owner->contents.err;
1411 }
1412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1413         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1414         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1415 }
1416
1417 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1418 CHECK(owner->result_ok);
1419         return CommitmentTransaction_clone(&*owner->contents.result);
1420 }
1421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1422         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1423         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1424         int64_t ret_ref = 0;
1425         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1426         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1428         ret_ref = (uintptr_t)ret_var.inner;
1429         if (ret_var.is_owned) {
1430                 ret_ref |= 1;
1431         }
1432         return ret_ref;
1433 }
1434
1435 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1436 CHECK(!owner->result_ok);
1437         return DecodeError_clone(&*owner->contents.err);
1438 }
1439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1440         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1441         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1442         int64_t ret_ref = 0;
1443         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1444         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1446         ret_ref = (uintptr_t)ret_var.inner;
1447         if (ret_var.is_owned) {
1448                 ret_ref |= 1;
1449         }
1450         return ret_ref;
1451 }
1452
1453 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1454 CHECK(owner->result_ok);
1455         return &*owner->contents.result;
1456 }
1457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1458         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1459         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1460         int64_t ret_ref = 0;
1461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1464         ret_ref = (uintptr_t)ret_var.inner & ~1;
1465         return ret_ref;
1466 }
1467
1468 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1469 CHECK(!owner->result_ok);
1470         return *owner->contents.err;
1471 }
1472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1473         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1474         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1475 }
1476
1477 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1478 CHECK(owner->result_ok);
1479         return *owner->contents.result;
1480 }
1481 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1482         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1483         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1484         jobjectArray ret_arr = NULL;
1485         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1486         ;
1487         for (size_t i = 0; i < ret_var.datalen; i++) {
1488                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1489                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1490                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1491         }
1492         
1493         return ret_arr;
1494 }
1495
1496 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1497 CHECK(!owner->result_ok);
1498         return *owner->contents.err;
1499 }
1500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1501         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1502         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1503 }
1504
1505 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1506 CHECK(owner->result_ok);
1507         return ShutdownScript_clone(&*owner->contents.result);
1508 }
1509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1510         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1511         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1512         int64_t ret_ref = 0;
1513         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1514         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1516         ret_ref = (uintptr_t)ret_var.inner;
1517         if (ret_var.is_owned) {
1518                 ret_ref |= 1;
1519         }
1520         return ret_ref;
1521 }
1522
1523 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1524 CHECK(!owner->result_ok);
1525         return DecodeError_clone(&*owner->contents.err);
1526 }
1527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1528         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1529         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1530         int64_t ret_ref = 0;
1531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1534         ret_ref = (uintptr_t)ret_var.inner;
1535         if (ret_var.is_owned) {
1536                 ret_ref |= 1;
1537         }
1538         return ret_ref;
1539 }
1540
1541 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1542 CHECK(owner->result_ok);
1543         return ShutdownScript_clone(&*owner->contents.result);
1544 }
1545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1546         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1547         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1548         int64_t ret_ref = 0;
1549         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1550         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1552         ret_ref = (uintptr_t)ret_var.inner;
1553         if (ret_var.is_owned) {
1554                 ret_ref |= 1;
1555         }
1556         return ret_ref;
1557 }
1558
1559 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1560 CHECK(!owner->result_ok);
1561         return InvalidShutdownScript_clone(&*owner->contents.err);
1562 }
1563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1564         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1565         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1566         int64_t ret_ref = 0;
1567         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1568         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1570         ret_ref = (uintptr_t)ret_var.inner;
1571         if (ret_var.is_owned) {
1572                 ret_ref |= 1;
1573         }
1574         return ret_ref;
1575 }
1576
1577 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1578 CHECK(owner->result_ok);
1579         return *owner->contents.result;
1580 }
1581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1582         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1583         CResult_NoneErrorZ_get_ok(owner_conv);
1584 }
1585
1586 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1587 CHECK(!owner->result_ok);
1588         return *owner->contents.err;
1589 }
1590 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1591         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1592         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
1593         return ret_conv;
1594 }
1595
1596 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1597 CHECK(owner->result_ok);
1598         return RouteHop_clone(&*owner->contents.result);
1599 }
1600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1601         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1602         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
1603         int64_t ret_ref = 0;
1604         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1605         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1607         ret_ref = (uintptr_t)ret_var.inner;
1608         if (ret_var.is_owned) {
1609                 ret_ref |= 1;
1610         }
1611         return ret_ref;
1612 }
1613
1614 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1615 CHECK(!owner->result_ok);
1616         return DecodeError_clone(&*owner->contents.err);
1617 }
1618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1619         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1620         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1621         int64_t ret_ref = 0;
1622         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1623         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1625         ret_ref = (uintptr_t)ret_var.inner;
1626         if (ret_var.is_owned) {
1627                 ret_ref |= 1;
1628         }
1629         return ret_ref;
1630 }
1631
1632 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1633         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1634         for (size_t i = 0; i < ret.datalen; i++) {
1635                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1636         }
1637         return ret;
1638 }
1639 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1640         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1641         for (size_t i = 0; i < ret.datalen; i++) {
1642                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1643         }
1644         return ret;
1645 }
1646 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1647 CHECK(owner->result_ok);
1648         return Route_clone(&*owner->contents.result);
1649 }
1650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1651         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1652         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1653         int64_t ret_ref = 0;
1654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1657         ret_ref = (uintptr_t)ret_var.inner;
1658         if (ret_var.is_owned) {
1659                 ret_ref |= 1;
1660         }
1661         return ret_ref;
1662 }
1663
1664 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1665 CHECK(!owner->result_ok);
1666         return DecodeError_clone(&*owner->contents.err);
1667 }
1668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1669         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1670         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1671         int64_t ret_ref = 0;
1672         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1673         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1675         ret_ref = (uintptr_t)ret_var.inner;
1676         if (ret_var.is_owned) {
1677                 ret_ref |= 1;
1678         }
1679         return ret_ref;
1680 }
1681
1682 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1683 CHECK(owner->result_ok);
1684         return RouteParameters_clone(&*owner->contents.result);
1685 }
1686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1687         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1688         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1689         int64_t ret_ref = 0;
1690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1693         ret_ref = (uintptr_t)ret_var.inner;
1694         if (ret_var.is_owned) {
1695                 ret_ref |= 1;
1696         }
1697         return ret_ref;
1698 }
1699
1700 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1701 CHECK(!owner->result_ok);
1702         return DecodeError_clone(&*owner->contents.err);
1703 }
1704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1705         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1706         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1707         int64_t ret_ref = 0;
1708         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1709         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1711         ret_ref = (uintptr_t)ret_var.inner;
1712         if (ret_var.is_owned) {
1713                 ret_ref |= 1;
1714         }
1715         return ret_ref;
1716 }
1717
1718 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1719         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1720         for (size_t i = 0; i < ret.datalen; i++) {
1721                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1722         }
1723         return ret;
1724 }
1725 static jclass LDKCOption_u64Z_Some_class = NULL;
1726 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1727 static jclass LDKCOption_u64Z_None_class = NULL;
1728 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1730         LDKCOption_u64Z_Some_class =
1731                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
1732         CHECK(LDKCOption_u64Z_Some_class != NULL);
1733         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1734         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1735         LDKCOption_u64Z_None_class =
1736                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
1737         CHECK(LDKCOption_u64Z_None_class != NULL);
1738         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1739         CHECK(LDKCOption_u64Z_None_meth != NULL);
1740 }
1741 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1742         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1743         switch(obj->tag) {
1744                 case LDKCOption_u64Z_Some: {
1745                         int64_t some_conv = obj->some;
1746                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, some_conv);
1747                 }
1748                 case LDKCOption_u64Z_None: {
1749                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1750                 }
1751                 default: abort();
1752         }
1753 }
1754 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
1755         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
1756         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
1757         return ret;
1758 }
1759 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1760 CHECK(owner->result_ok);
1761         return PaymentParameters_clone(&*owner->contents.result);
1762 }
1763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1764         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1765         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1766         int64_t ret_ref = 0;
1767         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1768         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1770         ret_ref = (uintptr_t)ret_var.inner;
1771         if (ret_var.is_owned) {
1772                 ret_ref |= 1;
1773         }
1774         return ret_ref;
1775 }
1776
1777 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1778 CHECK(!owner->result_ok);
1779         return DecodeError_clone(&*owner->contents.err);
1780 }
1781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1782         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1783         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1784         int64_t ret_ref = 0;
1785         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1786         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1787         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1788         ret_ref = (uintptr_t)ret_var.inner;
1789         if (ret_var.is_owned) {
1790                 ret_ref |= 1;
1791         }
1792         return ret_ref;
1793 }
1794
1795 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1796         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1797         for (size_t i = 0; i < ret.datalen; i++) {
1798                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1799         }
1800         return ret;
1801 }
1802 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1803 CHECK(owner->result_ok);
1804         return RouteHint_clone(&*owner->contents.result);
1805 }
1806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1807         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1808         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1809         int64_t ret_ref = 0;
1810         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1811         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1813         ret_ref = (uintptr_t)ret_var.inner;
1814         if (ret_var.is_owned) {
1815                 ret_ref |= 1;
1816         }
1817         return ret_ref;
1818 }
1819
1820 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1821 CHECK(!owner->result_ok);
1822         return DecodeError_clone(&*owner->contents.err);
1823 }
1824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1825         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1826         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1827         int64_t ret_ref = 0;
1828         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1829         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1830         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1831         ret_ref = (uintptr_t)ret_var.inner;
1832         if (ret_var.is_owned) {
1833                 ret_ref |= 1;
1834         }
1835         return ret_ref;
1836 }
1837
1838 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1839 CHECK(owner->result_ok);
1840         return RouteHintHop_clone(&*owner->contents.result);
1841 }
1842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1843         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1844         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1845         int64_t ret_ref = 0;
1846         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1847         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1849         ret_ref = (uintptr_t)ret_var.inner;
1850         if (ret_var.is_owned) {
1851                 ret_ref |= 1;
1852         }
1853         return ret_ref;
1854 }
1855
1856 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1857 CHECK(!owner->result_ok);
1858         return DecodeError_clone(&*owner->contents.err);
1859 }
1860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1861         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1862         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1863         int64_t ret_ref = 0;
1864         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1865         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1867         ret_ref = (uintptr_t)ret_var.inner;
1868         if (ret_var.is_owned) {
1869                 ret_ref |= 1;
1870         }
1871         return ret_ref;
1872 }
1873
1874 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1875         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1876         for (size_t i = 0; i < ret.datalen; i++) {
1877                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1878         }
1879         return ret;
1880 }
1881 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1882 CHECK(owner->result_ok);
1883         return Route_clone(&*owner->contents.result);
1884 }
1885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1886         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1887         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1888         int64_t ret_ref = 0;
1889         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1890         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1892         ret_ref = (uintptr_t)ret_var.inner;
1893         if (ret_var.is_owned) {
1894                 ret_ref |= 1;
1895         }
1896         return ret_ref;
1897 }
1898
1899 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1900 CHECK(!owner->result_ok);
1901         return LightningError_clone(&*owner->contents.err);
1902 }
1903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1904         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1905         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1906         int64_t ret_ref = 0;
1907         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1908         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1909         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1910         ret_ref = (uintptr_t)ret_var.inner;
1911         if (ret_var.is_owned) {
1912                 ret_ref |= 1;
1913         }
1914         return ret_ref;
1915 }
1916
1917 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
1918 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
1919 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
1920 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
1921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
1922         LDKPaymentPurpose_InvoicePayment_class =
1923                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
1924         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
1925         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
1926         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
1927         LDKPaymentPurpose_SpontaneousPayment_class =
1928                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
1929         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
1930         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
1931         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
1932 }
1933 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1934         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1935         switch(obj->tag) {
1936                 case LDKPaymentPurpose_InvoicePayment: {
1937                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1938                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
1939                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
1940                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
1941                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
1942                 }
1943                 case LDKPaymentPurpose_SpontaneousPayment: {
1944                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
1945                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
1946                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
1947                 }
1948                 default: abort();
1949         }
1950 }
1951 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1952 CHECK(owner->result_ok);
1953         return PaymentPurpose_clone(&*owner->contents.result);
1954 }
1955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1956         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1957         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
1958         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
1959         int64_t ret_ref = (uintptr_t)ret_copy;
1960         return ret_ref;
1961 }
1962
1963 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1964 CHECK(!owner->result_ok);
1965         return DecodeError_clone(&*owner->contents.err);
1966 }
1967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1968         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1969         LDKDecodeError ret_var = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
1970         int64_t ret_ref = 0;
1971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1974         ret_ref = (uintptr_t)ret_var.inner;
1975         if (ret_var.is_owned) {
1976                 ret_ref |= 1;
1977         }
1978         return ret_ref;
1979 }
1980
1981 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
1982 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
1983 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
1984 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
1985 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
1986 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
1987 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
1988 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
1989 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
1990 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
1991 static jclass LDKClosureReason_ProcessingError_class = NULL;
1992 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
1993 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
1994 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
1995 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
1996 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
1997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
1998         LDKClosureReason_CounterpartyForceClosed_class =
1999                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
2000         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
2001         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
2002         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
2003         LDKClosureReason_HolderForceClosed_class =
2004                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
2005         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
2006         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
2007         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
2008         LDKClosureReason_CooperativeClosure_class =
2009                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
2010         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
2011         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
2012         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
2013         LDKClosureReason_CommitmentTxConfirmed_class =
2014                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
2015         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
2016         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
2017         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
2018         LDKClosureReason_FundingTimedOut_class =
2019                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
2020         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
2021         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
2022         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
2023         LDKClosureReason_ProcessingError_class =
2024                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
2025         CHECK(LDKClosureReason_ProcessingError_class != NULL);
2026         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
2027         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
2028         LDKClosureReason_DisconnectedPeer_class =
2029                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
2030         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
2031         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
2032         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
2033         LDKClosureReason_OutdatedChannelManager_class =
2034                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
2035         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
2036         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
2037         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
2038 }
2039 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2040         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
2041         switch(obj->tag) {
2042                 case LDKClosureReason_CounterpartyForceClosed: {
2043                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
2044                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
2045                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
2046                 }
2047                 case LDKClosureReason_HolderForceClosed: {
2048                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
2049                 }
2050                 case LDKClosureReason_CooperativeClosure: {
2051                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
2052                 }
2053                 case LDKClosureReason_CommitmentTxConfirmed: {
2054                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
2055                 }
2056                 case LDKClosureReason_FundingTimedOut: {
2057                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
2058                 }
2059                 case LDKClosureReason_ProcessingError: {
2060                         LDKStr err_str = obj->processing_error.err;
2061                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2062                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
2063                 }
2064                 case LDKClosureReason_DisconnectedPeer: {
2065                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
2066                 }
2067                 case LDKClosureReason_OutdatedChannelManager: {
2068                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
2069                 }
2070                 default: abort();
2071         }
2072 }
2073 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
2074 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
2075 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
2076 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
2077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
2078         LDKCOption_ClosureReasonZ_Some_class =
2079                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
2080         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
2081         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
2082         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
2083         LDKCOption_ClosureReasonZ_None_class =
2084                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
2085         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
2086         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
2087         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
2088 }
2089 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2090         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
2091         switch(obj->tag) {
2092                 case LDKCOption_ClosureReasonZ_Some: {
2093                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2094                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
2095                 }
2096                 case LDKCOption_ClosureReasonZ_None: {
2097                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
2098                 }
2099                 default: abort();
2100         }
2101 }
2102 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2103 CHECK(owner->result_ok);
2104         return COption_ClosureReasonZ_clone(&*owner->contents.result);
2105 }
2106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2107         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2108         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
2109         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
2110         int64_t ret_ref = (uintptr_t)ret_copy;
2111         return ret_ref;
2112 }
2113
2114 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2115 CHECK(!owner->result_ok);
2116         return DecodeError_clone(&*owner->contents.err);
2117 }
2118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2119         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2120         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
2121         int64_t ret_ref = 0;
2122         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2123         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2125         ret_ref = (uintptr_t)ret_var.inner;
2126         if (ret_var.is_owned) {
2127                 ret_ref |= 1;
2128         }
2129         return ret_ref;
2130 }
2131
2132 static jclass LDKHTLCDestination_NextHopChannel_class = NULL;
2133 static jmethodID LDKHTLCDestination_NextHopChannel_meth = NULL;
2134 static jclass LDKHTLCDestination_UnknownNextHop_class = NULL;
2135 static jmethodID LDKHTLCDestination_UnknownNextHop_meth = NULL;
2136 static jclass LDKHTLCDestination_FailedPayment_class = NULL;
2137 static jmethodID LDKHTLCDestination_FailedPayment_meth = NULL;
2138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCDestination_init (JNIEnv *env, jclass clz) {
2139         LDKHTLCDestination_NextHopChannel_class =
2140                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$NextHopChannel"));
2141         CHECK(LDKHTLCDestination_NextHopChannel_class != NULL);
2142         LDKHTLCDestination_NextHopChannel_meth = (*env)->GetMethodID(env, LDKHTLCDestination_NextHopChannel_class, "<init>", "([B[B)V");
2143         CHECK(LDKHTLCDestination_NextHopChannel_meth != NULL);
2144         LDKHTLCDestination_UnknownNextHop_class =
2145                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$UnknownNextHop"));
2146         CHECK(LDKHTLCDestination_UnknownNextHop_class != NULL);
2147         LDKHTLCDestination_UnknownNextHop_meth = (*env)->GetMethodID(env, LDKHTLCDestination_UnknownNextHop_class, "<init>", "(J)V");
2148         CHECK(LDKHTLCDestination_UnknownNextHop_meth != NULL);
2149         LDKHTLCDestination_FailedPayment_class =
2150                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$FailedPayment"));
2151         CHECK(LDKHTLCDestination_FailedPayment_class != NULL);
2152         LDKHTLCDestination_FailedPayment_meth = (*env)->GetMethodID(env, LDKHTLCDestination_FailedPayment_class, "<init>", "([B)V");
2153         CHECK(LDKHTLCDestination_FailedPayment_meth != NULL);
2154 }
2155 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2156         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
2157         switch(obj->tag) {
2158                 case LDKHTLCDestination_NextHopChannel: {
2159                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2160                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->next_hop_channel.node_id.compressed_form);
2161                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2162                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->next_hop_channel.channel_id.data);
2163                         return (*env)->NewObject(env, LDKHTLCDestination_NextHopChannel_class, LDKHTLCDestination_NextHopChannel_meth, node_id_arr, channel_id_arr);
2164                 }
2165                 case LDKHTLCDestination_UnknownNextHop: {
2166                         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
2167                         return (*env)->NewObject(env, LDKHTLCDestination_UnknownNextHop_class, LDKHTLCDestination_UnknownNextHop_meth, requested_forward_scid_conv);
2168                 }
2169                 case LDKHTLCDestination_FailedPayment: {
2170                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2171                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->failed_payment.payment_hash.data);
2172                         return (*env)->NewObject(env, LDKHTLCDestination_FailedPayment_class, LDKHTLCDestination_FailedPayment_meth, payment_hash_arr);
2173                 }
2174                 default: abort();
2175         }
2176 }
2177 static jclass LDKCOption_HTLCDestinationZ_Some_class = NULL;
2178 static jmethodID LDKCOption_HTLCDestinationZ_Some_meth = NULL;
2179 static jclass LDKCOption_HTLCDestinationZ_None_class = NULL;
2180 static jmethodID LDKCOption_HTLCDestinationZ_None_meth = NULL;
2181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1HTLCDestinationZ_init (JNIEnv *env, jclass clz) {
2182         LDKCOption_HTLCDestinationZ_Some_class =
2183                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$Some"));
2184         CHECK(LDKCOption_HTLCDestinationZ_Some_class != NULL);
2185         LDKCOption_HTLCDestinationZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_Some_class, "<init>", "(J)V");
2186         CHECK(LDKCOption_HTLCDestinationZ_Some_meth != NULL);
2187         LDKCOption_HTLCDestinationZ_None_class =
2188                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$None"));
2189         CHECK(LDKCOption_HTLCDestinationZ_None_class != NULL);
2190         LDKCOption_HTLCDestinationZ_None_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_None_class, "<init>", "()V");
2191         CHECK(LDKCOption_HTLCDestinationZ_None_meth != NULL);
2192 }
2193 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1HTLCDestinationZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2194         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)(ptr & ~1);
2195         switch(obj->tag) {
2196                 case LDKCOption_HTLCDestinationZ_Some: {
2197                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2198                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_Some_class, LDKCOption_HTLCDestinationZ_Some_meth, some_ref);
2199                 }
2200                 case LDKCOption_HTLCDestinationZ_None: {
2201                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_None_class, LDKCOption_HTLCDestinationZ_None_meth);
2202                 }
2203                 default: abort();
2204         }
2205 }
2206 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2207 CHECK(owner->result_ok);
2208         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
2209 }
2210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2211         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(owner & ~1);
2212         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
2213         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
2214         int64_t ret_ref = (uintptr_t)ret_copy;
2215         return ret_ref;
2216 }
2217
2218 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2219 CHECK(!owner->result_ok);
2220         return DecodeError_clone(&*owner->contents.err);
2221 }
2222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2223         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(owner & ~1);
2224         LDKDecodeError ret_var = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
2225         int64_t ret_ref = 0;
2226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2229         ret_ref = (uintptr_t)ret_var.inner;
2230         if (ret_var.is_owned) {
2231                 ret_ref |= 1;
2232         }
2233         return ret_ref;
2234 }
2235
2236 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2237 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2238 static jclass LDKNetworkUpdate_ChannelFailure_class = NULL;
2239 static jmethodID LDKNetworkUpdate_ChannelFailure_meth = NULL;
2240 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2241 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2243         LDKNetworkUpdate_ChannelUpdateMessage_class =
2244                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2245         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2246         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2247         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2248         LDKNetworkUpdate_ChannelFailure_class =
2249                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelFailure"));
2250         CHECK(LDKNetworkUpdate_ChannelFailure_class != NULL);
2251         LDKNetworkUpdate_ChannelFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelFailure_class, "<init>", "(JZ)V");
2252         CHECK(LDKNetworkUpdate_ChannelFailure_meth != NULL);
2253         LDKNetworkUpdate_NodeFailure_class =
2254                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2255         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2256         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2257         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2258 }
2259 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2260         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
2261         switch(obj->tag) {
2262                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2263                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2264                         int64_t msg_ref = 0;
2265                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2266                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2267                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2268                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2269                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2270                 }
2271                 case LDKNetworkUpdate_ChannelFailure: {
2272                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
2273                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
2274                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelFailure_class, LDKNetworkUpdate_ChannelFailure_meth, short_channel_id_conv, is_permanent_conv);
2275                 }
2276                 case LDKNetworkUpdate_NodeFailure: {
2277                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2278                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2279                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
2280                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, is_permanent_conv);
2281                 }
2282                 default: abort();
2283         }
2284 }
2285 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2286 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2287 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2288 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2290         LDKCOption_NetworkUpdateZ_Some_class =
2291                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2292         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2293         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2294         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2295         LDKCOption_NetworkUpdateZ_None_class =
2296                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2297         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2298         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2299         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2300 }
2301 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2302         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
2303         switch(obj->tag) {
2304                 case LDKCOption_NetworkUpdateZ_Some: {
2305                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2306                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2307                 }
2308                 case LDKCOption_NetworkUpdateZ_None: {
2309                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2310                 }
2311                 default: abort();
2312         }
2313 }
2314 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2315 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2316 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2317 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2318 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2319 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2321         LDKSpendableOutputDescriptor_StaticOutput_class =
2322                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2323         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2324         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2325         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2326         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2327                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2328         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2329         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2330         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2331         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2332                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2333         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2334         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2335         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2336 }
2337 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2338         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
2339         switch(obj->tag) {
2340                 case LDKSpendableOutputDescriptor_StaticOutput: {
2341                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2342                         int64_t outpoint_ref = 0;
2343                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2344                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2345                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2346                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
2347                         int64_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
2348                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (int64_t)output_ref);
2349                 }
2350                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
2351                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
2352                         int64_t delayed_payment_output_ref = 0;
2353                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2354                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2355                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
2356                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
2357                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
2358                 }
2359                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
2360                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
2361                         int64_t static_payment_output_ref = 0;
2362                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2363                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2364                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
2365                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
2366                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
2367                 }
2368                 default: abort();
2369         }
2370 }
2371 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
2372         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
2373         for (size_t i = 0; i < ret.datalen; i++) {
2374                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
2375         }
2376         return ret;
2377 }
2378 static jclass LDKEvent_FundingGenerationReady_class = NULL;
2379 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
2380 static jclass LDKEvent_PaymentReceived_class = NULL;
2381 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
2382 static jclass LDKEvent_PaymentClaimed_class = NULL;
2383 static jmethodID LDKEvent_PaymentClaimed_meth = NULL;
2384 static jclass LDKEvent_PaymentSent_class = NULL;
2385 static jmethodID LDKEvent_PaymentSent_meth = NULL;
2386 static jclass LDKEvent_PaymentFailed_class = NULL;
2387 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
2388 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
2389 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
2390 static jclass LDKEvent_PaymentPathFailed_class = NULL;
2391 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
2392 static jclass LDKEvent_ProbeSuccessful_class = NULL;
2393 static jmethodID LDKEvent_ProbeSuccessful_meth = NULL;
2394 static jclass LDKEvent_ProbeFailed_class = NULL;
2395 static jmethodID LDKEvent_ProbeFailed_meth = NULL;
2396 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
2397 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
2398 static jclass LDKEvent_SpendableOutputs_class = NULL;
2399 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
2400 static jclass LDKEvent_PaymentForwarded_class = NULL;
2401 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
2402 static jclass LDKEvent_ChannelClosed_class = NULL;
2403 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
2404 static jclass LDKEvent_DiscardFunding_class = NULL;
2405 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
2406 static jclass LDKEvent_OpenChannelRequest_class = NULL;
2407 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
2408 static jclass LDKEvent_HTLCHandlingFailed_class = NULL;
2409 static jmethodID LDKEvent_HTLCHandlingFailed_meth = NULL;
2410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
2411         LDKEvent_FundingGenerationReady_class =
2412                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
2413         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
2414         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([B[BJ[BJ)V");
2415         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
2416         LDKEvent_PaymentReceived_class =
2417                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentReceived"));
2418         CHECK(LDKEvent_PaymentReceived_class != NULL);
2419         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
2420         CHECK(LDKEvent_PaymentReceived_meth != NULL);
2421         LDKEvent_PaymentClaimed_class =
2422                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimed"));
2423         CHECK(LDKEvent_PaymentClaimed_class != NULL);
2424         LDKEvent_PaymentClaimed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimed_class, "<init>", "([BJJ)V");
2425         CHECK(LDKEvent_PaymentClaimed_meth != NULL);
2426         LDKEvent_PaymentSent_class =
2427                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
2428         CHECK(LDKEvent_PaymentSent_class != NULL);
2429         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
2430         CHECK(LDKEvent_PaymentSent_meth != NULL);
2431         LDKEvent_PaymentFailed_class =
2432                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
2433         CHECK(LDKEvent_PaymentFailed_class != NULL);
2434         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
2435         CHECK(LDKEvent_PaymentFailed_meth != NULL);
2436         LDKEvent_PaymentPathSuccessful_class =
2437                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
2438         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
2439         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
2440         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
2441         LDKEvent_PaymentPathFailed_class =
2442                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
2443         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
2444         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
2445         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
2446         LDKEvent_ProbeSuccessful_class =
2447                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeSuccessful"));
2448         CHECK(LDKEvent_ProbeSuccessful_class != NULL);
2449         LDKEvent_ProbeSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_ProbeSuccessful_class, "<init>", "([B[B[J)V");
2450         CHECK(LDKEvent_ProbeSuccessful_meth != NULL);
2451         LDKEvent_ProbeFailed_class =
2452                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeFailed"));
2453         CHECK(LDKEvent_ProbeFailed_class != NULL);
2454         LDKEvent_ProbeFailed_meth = (*env)->GetMethodID(env, LDKEvent_ProbeFailed_class, "<init>", "([B[B[JJ)V");
2455         CHECK(LDKEvent_ProbeFailed_meth != NULL);
2456         LDKEvent_PendingHTLCsForwardable_class =
2457                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
2458         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
2459         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
2460         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
2461         LDKEvent_SpendableOutputs_class =
2462                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
2463         CHECK(LDKEvent_SpendableOutputs_class != NULL);
2464         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
2465         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
2466         LDKEvent_PaymentForwarded_class =
2467                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
2468         CHECK(LDKEvent_PaymentForwarded_class != NULL);
2469         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "([B[BJZ)V");
2470         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
2471         LDKEvent_ChannelClosed_class =
2472                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
2473         CHECK(LDKEvent_ChannelClosed_class != NULL);
2474         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
2475         CHECK(LDKEvent_ChannelClosed_meth != NULL);
2476         LDKEvent_DiscardFunding_class =
2477                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
2478         CHECK(LDKEvent_DiscardFunding_class != NULL);
2479         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
2480         CHECK(LDKEvent_DiscardFunding_meth != NULL);
2481         LDKEvent_OpenChannelRequest_class =
2482                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
2483         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
2484         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
2485         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
2486         LDKEvent_HTLCHandlingFailed_class =
2487                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$HTLCHandlingFailed"));
2488         CHECK(LDKEvent_HTLCHandlingFailed_class != NULL);
2489         LDKEvent_HTLCHandlingFailed_meth = (*env)->GetMethodID(env, LDKEvent_HTLCHandlingFailed_class, "<init>", "([BJ)V");
2490         CHECK(LDKEvent_HTLCHandlingFailed_meth != NULL);
2491 }
2492 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2493         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2494         switch(obj->tag) {
2495                 case LDKEvent_FundingGenerationReady: {
2496                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2497                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
2498                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2499                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->funding_generation_ready.counterparty_node_id.compressed_form);
2500                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
2501                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
2502                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
2503                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
2504                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
2505                         return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, counterparty_node_id_arr, channel_value_satoshis_conv, output_script_arr, user_channel_id_conv);
2506                 }
2507                 case LDKEvent_PaymentReceived: {
2508                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2509                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
2510                         int64_t amount_msat_conv = obj->payment_received.amount_msat;
2511                         int64_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
2512                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
2513                 }
2514                 case LDKEvent_PaymentClaimed: {
2515                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2516                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimed.payment_hash.data);
2517                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
2518                         int64_t purpose_ref = ((uintptr_t)&obj->payment_claimed.purpose) | 1;
2519                         return (*env)->NewObject(env, LDKEvent_PaymentClaimed_class, LDKEvent_PaymentClaimed_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
2520                 }
2521                 case LDKEvent_PaymentSent: {
2522                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2523                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
2524                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2525                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
2526                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2527                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
2528                         int64_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
2529                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
2530                 }
2531                 case LDKEvent_PaymentFailed: {
2532                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2533                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
2534                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2535                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
2536                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
2537                 }
2538                 case LDKEvent_PaymentPathSuccessful: {
2539                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2540                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
2541                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2542                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
2543                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
2544                         int64_tArray path_arr = NULL;
2545                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2546                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2547                         for (size_t k = 0; k < path_var.datalen; k++) {
2548                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2549                                 int64_t path_conv_10_ref = 0;
2550                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2551                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2552                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2553                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2554                                 path_arr_ptr[k] = path_conv_10_ref;
2555                         }
2556                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2557                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2558                 }
2559                 case LDKEvent_PaymentPathFailed: {
2560                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2561                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
2562                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2563                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
2564                         jboolean rejected_by_dest_conv = obj->payment_path_failed.rejected_by_dest;
2565                         int64_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
2566                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
2567                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
2568                         int64_tArray path_arr = NULL;
2569                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2570                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2571                         for (size_t k = 0; k < path_var.datalen; k++) {
2572                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2573                                 int64_t path_conv_10_ref = 0;
2574                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2575                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2576                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2577                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2578                                 path_arr_ptr[k] = path_conv_10_ref;
2579                         }
2580                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2581                         int64_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
2582                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
2583                         int64_t retry_ref = 0;
2584                         if ((uintptr_t)retry_var.inner > 4096) {
2585                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2586                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2587                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
2588                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
2589                         }
2590                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, rejected_by_dest_conv, network_update_ref, all_paths_failed_conv, path_arr, short_channel_id_ref, retry_ref);
2591                 }
2592                 case LDKEvent_ProbeSuccessful: {
2593                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2594                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_successful.payment_id.data);
2595                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2596                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_successful.payment_hash.data);
2597                         LDKCVec_RouteHopZ path_var = obj->probe_successful.path;
2598                         int64_tArray path_arr = NULL;
2599                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2600                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2601                         for (size_t k = 0; k < path_var.datalen; k++) {
2602                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2603                                 int64_t path_conv_10_ref = 0;
2604                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2605                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2606                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2607                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2608                                 path_arr_ptr[k] = path_conv_10_ref;
2609                         }
2610                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2611                         return (*env)->NewObject(env, LDKEvent_ProbeSuccessful_class, LDKEvent_ProbeSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2612                 }
2613                 case LDKEvent_ProbeFailed: {
2614                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2615                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_failed.payment_id.data);
2616                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2617                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_failed.payment_hash.data);
2618                         LDKCVec_RouteHopZ path_var = obj->probe_failed.path;
2619                         int64_tArray path_arr = NULL;
2620                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2621                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2622                         for (size_t k = 0; k < path_var.datalen; k++) {
2623                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2624                                 int64_t path_conv_10_ref = 0;
2625                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2626                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2627                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2628                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2629                                 path_arr_ptr[k] = path_conv_10_ref;
2630                         }
2631                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2632                         int64_t short_channel_id_ref = ((uintptr_t)&obj->probe_failed.short_channel_id) | 1;
2633                         return (*env)->NewObject(env, LDKEvent_ProbeFailed_class, LDKEvent_ProbeFailed_meth, payment_id_arr, payment_hash_arr, path_arr, short_channel_id_ref);
2634                 }
2635                 case LDKEvent_PendingHTLCsForwardable: {
2636                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
2637                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, time_forwardable_conv);
2638                 }
2639                 case LDKEvent_SpendableOutputs: {
2640                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
2641                         int64_tArray outputs_arr = NULL;
2642                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
2643                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
2644                         for (size_t b = 0; b < outputs_var.datalen; b++) {
2645                                 int64_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
2646                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
2647                         }
2648                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
2649                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
2650                 }
2651                 case LDKEvent_PaymentForwarded: {
2652                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
2653                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->payment_forwarded.prev_channel_id.data);
2654                         int8_tArray next_channel_id_arr = (*env)->NewByteArray(env, 32);
2655                         (*env)->SetByteArrayRegion(env, next_channel_id_arr, 0, 32, obj->payment_forwarded.next_channel_id.data);
2656                         int64_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
2657                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
2658                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, prev_channel_id_arr, next_channel_id_arr, fee_earned_msat_ref, claim_from_onchain_tx_conv);
2659                 }
2660                 case LDKEvent_ChannelClosed: {
2661                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2662                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
2663                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
2664                         int64_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
2665                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, user_channel_id_conv, reason_ref);
2666                 }
2667                 case LDKEvent_DiscardFunding: {
2668                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2669                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
2670                         LDKTransaction transaction_var = obj->discard_funding.transaction;
2671                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
2672                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
2673                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
2674                 }
2675                 case LDKEvent_OpenChannelRequest: {
2676                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2677                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
2678                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2679                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
2680                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
2681                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
2682                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
2683                         int64_t channel_type_ref = 0;
2684                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2685                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2686                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
2687                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
2688                         return (*env)->NewObject(env, LDKEvent_OpenChannelRequest_class, LDKEvent_OpenChannelRequest_meth, temporary_channel_id_arr, counterparty_node_id_arr, funding_satoshis_conv, push_msat_conv, channel_type_ref);
2689                 }
2690                 case LDKEvent_HTLCHandlingFailed: {
2691                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
2692                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->htlc_handling_failed.prev_channel_id.data);
2693                         int64_t failed_next_destination_ref = ((uintptr_t)&obj->htlc_handling_failed.failed_next_destination) | 1;
2694                         return (*env)->NewObject(env, LDKEvent_HTLCHandlingFailed_class, LDKEvent_HTLCHandlingFailed_meth, prev_channel_id_arr, failed_next_destination_ref);
2695                 }
2696                 default: abort();
2697         }
2698 }
2699 static jclass LDKCOption_EventZ_Some_class = NULL;
2700 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
2701 static jclass LDKCOption_EventZ_None_class = NULL;
2702 static jmethodID LDKCOption_EventZ_None_meth = NULL;
2703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
2704         LDKCOption_EventZ_Some_class =
2705                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
2706         CHECK(LDKCOption_EventZ_Some_class != NULL);
2707         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
2708         CHECK(LDKCOption_EventZ_Some_meth != NULL);
2709         LDKCOption_EventZ_None_class =
2710                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
2711         CHECK(LDKCOption_EventZ_None_class != NULL);
2712         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
2713         CHECK(LDKCOption_EventZ_None_meth != NULL);
2714 }
2715 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2716         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2717         switch(obj->tag) {
2718                 case LDKCOption_EventZ_Some: {
2719                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2720                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
2721                 }
2722                 case LDKCOption_EventZ_None: {
2723                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
2724                 }
2725                 default: abort();
2726         }
2727 }
2728 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2729 CHECK(owner->result_ok);
2730         return COption_EventZ_clone(&*owner->contents.result);
2731 }
2732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2733         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2734         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
2735         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
2736         int64_t ret_ref = (uintptr_t)ret_copy;
2737         return ret_ref;
2738 }
2739
2740 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2741 CHECK(!owner->result_ok);
2742         return DecodeError_clone(&*owner->contents.err);
2743 }
2744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2745         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2746         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
2747         int64_t ret_ref = 0;
2748         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2749         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2751         ret_ref = (uintptr_t)ret_var.inner;
2752         if (ret_var.is_owned) {
2753                 ret_ref |= 1;
2754         }
2755         return ret_ref;
2756 }
2757
2758 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
2759 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
2760 static jclass LDKErrorAction_IgnoreError_class = NULL;
2761 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
2762 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
2763 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
2764 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
2765 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
2766 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
2767 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
2768 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
2769 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
2770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
2771         LDKErrorAction_DisconnectPeer_class =
2772                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
2773         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2774         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2775         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2776         LDKErrorAction_IgnoreError_class =
2777                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
2778         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2779         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2780         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2781         LDKErrorAction_IgnoreAndLog_class =
2782                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
2783         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
2784         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
2785         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
2786         LDKErrorAction_IgnoreDuplicateGossip_class =
2787                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
2788         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
2789         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
2790         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
2791         LDKErrorAction_SendErrorMessage_class =
2792                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
2793         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2794         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2795         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2796         LDKErrorAction_SendWarningMessage_class =
2797                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
2798         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
2799         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
2800         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
2801 }
2802 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2803         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2804         switch(obj->tag) {
2805                 case LDKErrorAction_DisconnectPeer: {
2806                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2807                         int64_t msg_ref = 0;
2808                         if ((uintptr_t)msg_var.inner > 4096) {
2809                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2810                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2811                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2812                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
2813                         }
2814                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2815                 }
2816                 case LDKErrorAction_IgnoreError: {
2817                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2818                 }
2819                 case LDKErrorAction_IgnoreAndLog: {
2820                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
2821                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
2822                 }
2823                 case LDKErrorAction_IgnoreDuplicateGossip: {
2824                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
2825                 }
2826                 case LDKErrorAction_SendErrorMessage: {
2827                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2828                         int64_t msg_ref = 0;
2829                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2830                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2831                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2832                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2833                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2834                 }
2835                 case LDKErrorAction_SendWarningMessage: {
2836                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2837                         int64_t msg_ref = 0;
2838                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2839                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2840                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2841                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2842                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
2843                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
2844                 }
2845                 default: abort();
2846         }
2847 }
2848 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2849 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2850 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2851 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2852 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2853 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2854 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2855 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2856 static jclass LDKMessageSendEvent_SendChannelReady_class = NULL;
2857 static jmethodID LDKMessageSendEvent_SendChannelReady_meth = NULL;
2858 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2859 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2860 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2861 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2862 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2863 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2864 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2865 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2866 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2867 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2868 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2869 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2870 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2871 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2872 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2873 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2874 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2875 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2876 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
2877 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
2878 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2879 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2880 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2881 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2882 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2883 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2884 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2885 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2886 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
2887 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
2888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2889         LDKMessageSendEvent_SendAcceptChannel_class =
2890                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
2891         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2892         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2893         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2894         LDKMessageSendEvent_SendOpenChannel_class =
2895                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
2896         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2897         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2898         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2899         LDKMessageSendEvent_SendFundingCreated_class =
2900                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
2901         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2902         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2903         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2904         LDKMessageSendEvent_SendFundingSigned_class =
2905                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
2906         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2907         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2908         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2909         LDKMessageSendEvent_SendChannelReady_class =
2910                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReady"));
2911         CHECK(LDKMessageSendEvent_SendChannelReady_class != NULL);
2912         LDKMessageSendEvent_SendChannelReady_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReady_class, "<init>", "([BJ)V");
2913         CHECK(LDKMessageSendEvent_SendChannelReady_meth != NULL);
2914         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2915                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
2916         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2917         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2918         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2919         LDKMessageSendEvent_UpdateHTLCs_class =
2920                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
2921         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2922         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2923         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2924         LDKMessageSendEvent_SendRevokeAndACK_class =
2925                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
2926         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2927         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2928         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2929         LDKMessageSendEvent_SendClosingSigned_class =
2930                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
2931         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2932         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2933         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2934         LDKMessageSendEvent_SendShutdown_class =
2935                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
2936         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2937         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2938         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2939         LDKMessageSendEvent_SendChannelReestablish_class =
2940                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
2941         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2942         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2943         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2944         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2945                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
2946         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2947         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2948         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2949         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2950                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
2951         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2952         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2953         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2954         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2955                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
2956         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2957         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2958         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2959         LDKMessageSendEvent_SendChannelUpdate_class =
2960                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
2961         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
2962         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
2963         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
2964         LDKMessageSendEvent_HandleError_class =
2965                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
2966         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2967         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2968         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2969         LDKMessageSendEvent_SendChannelRangeQuery_class =
2970                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
2971         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2972         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2973         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2974         LDKMessageSendEvent_SendShortIdsQuery_class =
2975                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
2976         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2977         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2978         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2979         LDKMessageSendEvent_SendReplyChannelRange_class =
2980                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
2981         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2982         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2983         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2984         LDKMessageSendEvent_SendGossipTimestampFilter_class =
2985                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
2986         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
2987         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
2988         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
2989 }
2990 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2991         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2992         switch(obj->tag) {
2993                 case LDKMessageSendEvent_SendAcceptChannel: {
2994                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2995                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2996                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2997                         int64_t msg_ref = 0;
2998                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2999                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3000                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3001                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3002                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
3003                 }
3004                 case LDKMessageSendEvent_SendOpenChannel: {
3005                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3006                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
3007                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
3008                         int64_t msg_ref = 0;
3009                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3010                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3011                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3012                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3013                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
3014                 }
3015                 case LDKMessageSendEvent_SendFundingCreated: {
3016                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3017                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
3018                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
3019                         int64_t msg_ref = 0;
3020                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3021                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3022                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3023                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3024                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
3025                 }
3026                 case LDKMessageSendEvent_SendFundingSigned: {
3027                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3028                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
3029                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
3030                         int64_t msg_ref = 0;
3031                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3032                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3033                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3034                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3035                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
3036                 }
3037                 case LDKMessageSendEvent_SendChannelReady: {
3038                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3039                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_ready.node_id.compressed_form);
3040                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
3041                         int64_t msg_ref = 0;
3042                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3043                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3044                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3045                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3046                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReady_class, LDKMessageSendEvent_SendChannelReady_meth, node_id_arr, msg_ref);
3047                 }
3048                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
3049                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3050                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
3051                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
3052                         int64_t msg_ref = 0;
3053                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3054                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3055                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3056                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3057                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
3058                 }
3059                 case LDKMessageSendEvent_UpdateHTLCs: {
3060                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3061                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
3062                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
3063                         int64_t updates_ref = 0;
3064                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3065                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3066                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
3067                         updates_ref = (uintptr_t)updates_var.inner & ~1;
3068                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
3069                 }
3070                 case LDKMessageSendEvent_SendRevokeAndACK: {
3071                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3072                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
3073                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
3074                         int64_t msg_ref = 0;
3075                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3076                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3077                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3078                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3079                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
3080                 }
3081                 case LDKMessageSendEvent_SendClosingSigned: {
3082                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3083                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
3084                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
3085                         int64_t msg_ref = 0;
3086                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3087                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3088                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3089                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3090                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
3091                 }
3092                 case LDKMessageSendEvent_SendShutdown: {
3093                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3094                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
3095                         LDKShutdown msg_var = obj->send_shutdown.msg;
3096                         int64_t msg_ref = 0;
3097                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3098                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3099                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3100                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3101                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
3102                 }
3103                 case LDKMessageSendEvent_SendChannelReestablish: {
3104                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3105                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
3106                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
3107                         int64_t msg_ref = 0;
3108                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3109                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3110                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3111                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3112                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
3113                 }
3114                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
3115                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.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                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
3122                         int64_t update_msg_ref = 0;
3123                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3124                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3125                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3126                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
3127                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
3128                 }
3129                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
3130                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
3131                         int64_t msg_ref = 0;
3132                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3133                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3134                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3135                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3136                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
3137                 }
3138                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
3139                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
3140                         int64_t msg_ref = 0;
3141                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3142                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3143                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3144                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3145                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
3146                 }
3147                 case LDKMessageSendEvent_SendChannelUpdate: {
3148                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3149                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
3150                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
3151                         int64_t msg_ref = 0;
3152                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3153                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3154                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3155                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3156                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
3157                 }
3158                 case LDKMessageSendEvent_HandleError: {
3159                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3160                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
3161                         int64_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
3162                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
3163                 }
3164                 case LDKMessageSendEvent_SendChannelRangeQuery: {
3165                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3166                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
3167                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
3168                         int64_t msg_ref = 0;
3169                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3170                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3171                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3172                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3173                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
3174                 }
3175                 case LDKMessageSendEvent_SendShortIdsQuery: {
3176                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3177                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
3178                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
3179                         int64_t msg_ref = 0;
3180                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3181                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3182                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3183                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3184                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
3185                 }
3186                 case LDKMessageSendEvent_SendReplyChannelRange: {
3187                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3188                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
3189                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3190                         int64_t msg_ref = 0;
3191                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3192                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3193                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3194                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3195                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
3196                 }
3197                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
3198                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3199                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
3200                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
3201                         int64_t msg_ref = 0;
3202                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3203                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3204                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3205                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3206                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
3207                 }
3208                 default: abort();
3209         }
3210 }
3211 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3212         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3213         for (size_t i = 0; i < ret.datalen; i++) {
3214                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3215         }
3216         return ret;
3217 }
3218 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3219 CHECK(owner->result_ok);
3220         return TxOut_clone(&*owner->contents.result);
3221 }
3222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3223         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3224         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3225         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
3226         return (int64_t)ret_ref;
3227 }
3228
3229 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3230 CHECK(!owner->result_ok);
3231         return AccessError_clone(&*owner->contents.err);
3232 }
3233 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3234         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3235         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
3236         return ret_conv;
3237 }
3238
3239 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3240         return owner->a;
3241 }
3242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3243         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
3244         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
3245         return ret_conv;
3246 }
3247
3248 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3249         return owner->b;
3250 }
3251 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3252         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
3253         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
3254         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3255         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3256         return ret_arr;
3257 }
3258
3259 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
3260         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
3261         for (size_t i = 0; i < ret.datalen; i++) {
3262                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
3263         }
3264         return ret;
3265 }
3266 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
3267         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
3268         for (size_t i = 0; i < ret.datalen; i++) {
3269                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3270         }
3271         return ret;
3272 }
3273 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3274 CHECK(owner->result_ok);
3275         return *owner->contents.result;
3276 }
3277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3278         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3279         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
3280 }
3281
3282 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3283 CHECK(!owner->result_ok);
3284         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
3285 }
3286 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3287         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3288         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
3289         return ret_conv;
3290 }
3291
3292 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
3293 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
3294 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
3295 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
3296 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
3297 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
3298 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
3299 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
3300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
3301         LDKMonitorEvent_HTLCEvent_class =
3302                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
3303         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
3304         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
3305         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
3306         LDKMonitorEvent_CommitmentTxConfirmed_class =
3307                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
3308         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
3309         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
3310         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
3311         LDKMonitorEvent_UpdateCompleted_class =
3312                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted"));
3313         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
3314         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
3315         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
3316         LDKMonitorEvent_UpdateFailed_class =
3317                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
3318         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
3319         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
3320         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
3321 }
3322 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3323         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
3324         switch(obj->tag) {
3325                 case LDKMonitorEvent_HTLCEvent: {
3326                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
3327                         int64_t htlc_event_ref = 0;
3328                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3329                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3330                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
3331                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
3332                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
3333                 }
3334                 case LDKMonitorEvent_CommitmentTxConfirmed: {
3335                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
3336                         int64_t commitment_tx_confirmed_ref = 0;
3337                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3338                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3339                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
3340                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
3341                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
3342                 }
3343                 case LDKMonitorEvent_UpdateCompleted: {
3344                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
3345                         int64_t funding_txo_ref = 0;
3346                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3347                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3348                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
3349                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
3350                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
3351                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, monitor_update_id_conv);
3352                 }
3353                 case LDKMonitorEvent_UpdateFailed: {
3354                         LDKOutPoint update_failed_var = obj->update_failed;
3355                         int64_t update_failed_ref = 0;
3356                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3357                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3358                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
3359                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
3360                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
3361                 }
3362                 default: abort();
3363         }
3364 }
3365 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
3366         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
3367         for (size_t i = 0; i < ret.datalen; i++) {
3368                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
3369         }
3370         return ret;
3371 }
3372 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3373         return OutPoint_clone(&owner->a);
3374 }
3375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3376         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
3377         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
3378         int64_t ret_ref = 0;
3379         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3380         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3381         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3382         ret_ref = (uintptr_t)ret_var.inner;
3383         if (ret_var.is_owned) {
3384                 ret_ref |= 1;
3385         }
3386         return ret_ref;
3387 }
3388
3389 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3390         return CVec_MonitorEventZ_clone(&owner->b);
3391 }
3392 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3393         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
3394         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
3395         int64_tArray ret_arr = NULL;
3396         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3397         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3398         for (size_t o = 0; o < ret_var.datalen; o++) {
3399                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3400                 *ret_conv_14_copy = ret_var.data[o];
3401                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
3402                 ret_arr_ptr[o] = ret_conv_14_ref;
3403         }
3404         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3405         FREE(ret_var.data);
3406         return ret_arr;
3407 }
3408
3409 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3410         return owner->c;
3411 }
3412 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
3413         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
3414         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3415         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form);
3416         return ret_arr;
3417 }
3418
3419 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
3420         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
3421         for (size_t i = 0; i < ret.datalen; i++) {
3422                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
3423         }
3424         return ret;
3425 }
3426 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
3427 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
3428 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
3429 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
3430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
3431         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
3432                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some"));
3433         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
3434         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
3435         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
3436         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
3437                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None"));
3438         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
3439         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
3440         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
3441 }
3442 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3443         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
3444         switch(obj->tag) {
3445                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
3446                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
3447                         *some_conv = obj->some;
3448                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
3449                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((int64_t)some_conv));
3450                 }
3451                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
3452                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
3453                 }
3454                 default: abort();
3455         }
3456 }
3457 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3458 CHECK(owner->result_ok);
3459         return FixedPenaltyScorer_clone(&*owner->contents.result);
3460 }
3461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3462         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3463         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3464         int64_t ret_ref = 0;
3465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3468         ret_ref = (uintptr_t)ret_var.inner;
3469         if (ret_var.is_owned) {
3470                 ret_ref |= 1;
3471         }
3472         return ret_ref;
3473 }
3474
3475 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3476 CHECK(!owner->result_ok);
3477         return DecodeError_clone(&*owner->contents.err);
3478 }
3479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3480         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3481         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3482         int64_t ret_ref = 0;
3483         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3484         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3486         ret_ref = (uintptr_t)ret_var.inner;
3487         if (ret_var.is_owned) {
3488                 ret_ref |= 1;
3489         }
3490         return ret_ref;
3491 }
3492
3493 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3494         return owner->a;
3495 }
3496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3497         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
3498         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
3499         return ret_conv;
3500 }
3501
3502 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3503         return owner->b;
3504 }
3505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3506         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
3507         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
3508         return ret_conv;
3509 }
3510
3511 static jclass LDKCOption_C2Tuple_u64u64ZZ_Some_class = NULL;
3512 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_Some_meth = NULL;
3513 static jclass LDKCOption_C2Tuple_u64u64ZZ_None_class = NULL;
3514 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_None_meth = NULL;
3515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1u64u64ZZ_init (JNIEnv *env, jclass clz) {
3516         LDKCOption_C2Tuple_u64u64ZZ_Some_class =
3517                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$Some"));
3518         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_class != NULL);
3519         LDKCOption_C2Tuple_u64u64ZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, "<init>", "(J)V");
3520         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_meth != NULL);
3521         LDKCOption_C2Tuple_u64u64ZZ_None_class =
3522                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$None"));
3523         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_class != NULL);
3524         LDKCOption_C2Tuple_u64u64ZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, "<init>", "()V");
3525         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_meth != NULL);
3526 }
3527 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1u64u64ZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3528         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)(ptr & ~1);
3529         switch(obj->tag) {
3530                 case LDKCOption_C2Tuple_u64u64ZZ_Some: {
3531                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
3532                         *some_conv = obj->some;
3533                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
3534                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, LDKCOption_C2Tuple_u64u64ZZ_Some_meth, ((int64_t)some_conv));
3535                 }
3536                 case LDKCOption_C2Tuple_u64u64ZZ_None: {
3537                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, LDKCOption_C2Tuple_u64u64ZZ_None_meth);
3538                 }
3539                 default: abort();
3540         }
3541 }
3542 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
3543         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
3544         for (size_t i = 0; i < ret.datalen; i++) {
3545                 ret.data[i] = NodeId_clone(&orig->data[i]);
3546         }
3547         return ret;
3548 }
3549 typedef struct LDKLogger_JCalls {
3550         atomic_size_t refcnt;
3551         JavaVM *vm;
3552         jweak o;
3553         jmethodID log_meth;
3554 } LDKLogger_JCalls;
3555 static void LDKLogger_JCalls_free(void* this_arg) {
3556         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3557         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3558                 JNIEnv *env;
3559                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3560                 if (get_jenv_res == JNI_EDETACHED) {
3561                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3562                 } else {
3563                         DO_ASSERT(get_jenv_res == JNI_OK);
3564                 }
3565                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3566                 if (get_jenv_res == JNI_EDETACHED) {
3567                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3568                 }
3569                 FREE(j_calls);
3570         }
3571 }
3572 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
3573         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3574         JNIEnv *env;
3575         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3576         if (get_jenv_res == JNI_EDETACHED) {
3577                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3578         } else {
3579                 DO_ASSERT(get_jenv_res == JNI_OK);
3580         }
3581         LDKRecord record_var = *record;
3582         int64_t record_ref = 0;
3583         record_var = Record_clone(&record_var);
3584         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3585         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3586         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
3587         record_ref = (uintptr_t)record_var.inner;
3588         if (record_var.is_owned) {
3589                 record_ref |= 1;
3590         }
3591         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3592         CHECK(obj != NULL);
3593         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
3594         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3595                 (*env)->ExceptionDescribe(env);
3596                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
3597         }
3598         if (get_jenv_res == JNI_EDETACHED) {
3599                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3600         }
3601 }
3602 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
3603         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
3604         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3605 }
3606 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
3607         jclass c = (*env)->GetObjectClass(env, o);
3608         CHECK(c != NULL);
3609         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3610         atomic_init(&calls->refcnt, 1);
3611         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3612         calls->o = (*env)->NewWeakGlobalRef(env, o);
3613         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
3614         CHECK(calls->log_meth != NULL);
3615
3616         LDKLogger ret = {
3617                 .this_arg = (void*) calls,
3618                 .log = log_LDKLogger_jcall,
3619                 .free = LDKLogger_JCalls_free,
3620         };
3621         return ret;
3622 }
3623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
3624         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3625         *res_ptr = LDKLogger_init(env, clz, o);
3626         return (uint64_t)res_ptr;
3627 }
3628 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3629 CHECK(owner->result_ok);
3630         return &*owner->contents.result;
3631 }
3632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3633         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3634         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
3635         int64_t ret_ref = 0;
3636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3639         ret_ref = (uintptr_t)ret_var.inner & ~1;
3640         return ret_ref;
3641 }
3642
3643 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3644 CHECK(!owner->result_ok);
3645         return DecodeError_clone(&*owner->contents.err);
3646 }
3647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3648         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3649         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
3650         int64_t ret_ref = 0;
3651         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3652         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3654         ret_ref = (uintptr_t)ret_var.inner;
3655         if (ret_var.is_owned) {
3656                 ret_ref |= 1;
3657         }
3658         return ret_ref;
3659 }
3660
3661 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3662 CHECK(owner->result_ok);
3663         return InitFeatures_clone(&*owner->contents.result);
3664 }
3665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3666         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3667         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
3668         int64_t ret_ref = 0;
3669         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3670         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3672         ret_ref = (uintptr_t)ret_var.inner;
3673         if (ret_var.is_owned) {
3674                 ret_ref |= 1;
3675         }
3676         return ret_ref;
3677 }
3678
3679 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3680 CHECK(!owner->result_ok);
3681         return DecodeError_clone(&*owner->contents.err);
3682 }
3683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3684         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3685         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
3686         int64_t ret_ref = 0;
3687         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3688         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3690         ret_ref = (uintptr_t)ret_var.inner;
3691         if (ret_var.is_owned) {
3692                 ret_ref |= 1;
3693         }
3694         return ret_ref;
3695 }
3696
3697 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3698 CHECK(owner->result_ok);
3699         return ChannelFeatures_clone(&*owner->contents.result);
3700 }
3701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3702         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3703         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
3704         int64_t ret_ref = 0;
3705         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3706         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3708         ret_ref = (uintptr_t)ret_var.inner;
3709         if (ret_var.is_owned) {
3710                 ret_ref |= 1;
3711         }
3712         return ret_ref;
3713 }
3714
3715 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3716 CHECK(!owner->result_ok);
3717         return DecodeError_clone(&*owner->contents.err);
3718 }
3719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3720         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3721         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
3722         int64_t ret_ref = 0;
3723         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3724         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3726         ret_ref = (uintptr_t)ret_var.inner;
3727         if (ret_var.is_owned) {
3728                 ret_ref |= 1;
3729         }
3730         return ret_ref;
3731 }
3732
3733 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3734 CHECK(owner->result_ok);
3735         return NodeFeatures_clone(&*owner->contents.result);
3736 }
3737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3738         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3739         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
3740         int64_t ret_ref = 0;
3741         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3742         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3744         ret_ref = (uintptr_t)ret_var.inner;
3745         if (ret_var.is_owned) {
3746                 ret_ref |= 1;
3747         }
3748         return ret_ref;
3749 }
3750
3751 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3752 CHECK(!owner->result_ok);
3753         return DecodeError_clone(&*owner->contents.err);
3754 }
3755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3756         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3757         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3758         int64_t ret_ref = 0;
3759         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3760         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3762         ret_ref = (uintptr_t)ret_var.inner;
3763         if (ret_var.is_owned) {
3764                 ret_ref |= 1;
3765         }
3766         return ret_ref;
3767 }
3768
3769 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3770 CHECK(owner->result_ok);
3771         return InvoiceFeatures_clone(&*owner->contents.result);
3772 }
3773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3774         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3775         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3776         int64_t ret_ref = 0;
3777         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3778         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3779         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3780         ret_ref = (uintptr_t)ret_var.inner;
3781         if (ret_var.is_owned) {
3782                 ret_ref |= 1;
3783         }
3784         return ret_ref;
3785 }
3786
3787 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3788 CHECK(!owner->result_ok);
3789         return DecodeError_clone(&*owner->contents.err);
3790 }
3791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3792         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3793         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3794         int64_t ret_ref = 0;
3795         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3796         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3798         ret_ref = (uintptr_t)ret_var.inner;
3799         if (ret_var.is_owned) {
3800                 ret_ref |= 1;
3801         }
3802         return ret_ref;
3803 }
3804
3805 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3806 CHECK(owner->result_ok);
3807         return ChannelTypeFeatures_clone(&*owner->contents.result);
3808 }
3809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3810         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3811         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3812         int64_t ret_ref = 0;
3813         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3814         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3815         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3816         ret_ref = (uintptr_t)ret_var.inner;
3817         if (ret_var.is_owned) {
3818                 ret_ref |= 1;
3819         }
3820         return ret_ref;
3821 }
3822
3823 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3824 CHECK(!owner->result_ok);
3825         return DecodeError_clone(&*owner->contents.err);
3826 }
3827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3828         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3829         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3830         int64_t ret_ref = 0;
3831         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3832         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3834         ret_ref = (uintptr_t)ret_var.inner;
3835         if (ret_var.is_owned) {
3836                 ret_ref |= 1;
3837         }
3838         return ret_ref;
3839 }
3840
3841 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3842 CHECK(owner->result_ok);
3843         return NodeId_clone(&*owner->contents.result);
3844 }
3845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3846         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3847         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
3848         int64_t ret_ref = 0;
3849         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3850         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3852         ret_ref = (uintptr_t)ret_var.inner;
3853         if (ret_var.is_owned) {
3854                 ret_ref |= 1;
3855         }
3856         return ret_ref;
3857 }
3858
3859 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3860 CHECK(!owner->result_ok);
3861         return DecodeError_clone(&*owner->contents.err);
3862 }
3863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3864         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3865         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
3866         int64_t ret_ref = 0;
3867         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3868         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3870         ret_ref = (uintptr_t)ret_var.inner;
3871         if (ret_var.is_owned) {
3872                 ret_ref |= 1;
3873         }
3874         return ret_ref;
3875 }
3876
3877 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3878 CHECK(owner->result_ok);
3879         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
3880 }
3881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3882         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3883         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
3884         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
3885         int64_t ret_ref = (uintptr_t)ret_copy;
3886         return ret_ref;
3887 }
3888
3889 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3890 CHECK(!owner->result_ok);
3891         return DecodeError_clone(&*owner->contents.err);
3892 }
3893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3894         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3895         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
3896         int64_t ret_ref = 0;
3897         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3898         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3900         ret_ref = (uintptr_t)ret_var.inner;
3901         if (ret_var.is_owned) {
3902                 ret_ref |= 1;
3903         }
3904         return ret_ref;
3905 }
3906
3907 typedef struct LDKAccess_JCalls {
3908         atomic_size_t refcnt;
3909         JavaVM *vm;
3910         jweak o;
3911         jmethodID get_utxo_meth;
3912 } LDKAccess_JCalls;
3913 static void LDKAccess_JCalls_free(void* this_arg) {
3914         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3915         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3916                 JNIEnv *env;
3917                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3918                 if (get_jenv_res == JNI_EDETACHED) {
3919                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3920                 } else {
3921                         DO_ASSERT(get_jenv_res == JNI_OK);
3922                 }
3923                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3924                 if (get_jenv_res == JNI_EDETACHED) {
3925                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3926                 }
3927                 FREE(j_calls);
3928         }
3929 }
3930 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3931         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3932         JNIEnv *env;
3933         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3934         if (get_jenv_res == JNI_EDETACHED) {
3935                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3936         } else {
3937                 DO_ASSERT(get_jenv_res == JNI_OK);
3938         }
3939         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
3940         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
3941         int64_t short_channel_id_conv = short_channel_id;
3942         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3943         CHECK(obj != NULL);
3944         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id_conv);
3945         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3946                 (*env)->ExceptionDescribe(env);
3947                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
3948         }
3949         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3950         CHECK_ACCESS(ret_ptr);
3951         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
3952         FREE((void*)ret);
3953         if (get_jenv_res == JNI_EDETACHED) {
3954                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3955         }
3956         return ret_conv;
3957 }
3958 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
3959         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
3960         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3961 }
3962 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
3963         jclass c = (*env)->GetObjectClass(env, o);
3964         CHECK(c != NULL);
3965         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3966         atomic_init(&calls->refcnt, 1);
3967         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3968         calls->o = (*env)->NewWeakGlobalRef(env, o);
3969         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
3970         CHECK(calls->get_utxo_meth != NULL);
3971
3972         LDKAccess ret = {
3973                 .this_arg = (void*) calls,
3974                 .get_utxo = get_utxo_LDKAccess_jcall,
3975                 .free = LDKAccess_JCalls_free,
3976         };
3977         return ret;
3978 }
3979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
3980         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3981         *res_ptr = LDKAccess_init(env, clz, o);
3982         return (uint64_t)res_ptr;
3983 }
3984 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) {
3985         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3986         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3987         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
3988         unsigned char genesis_hash_arr[32];
3989         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
3990         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
3991         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3992         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3993         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3994         return (int64_t)ret_conv;
3995 }
3996
3997 static jclass LDKCOption_AccessZ_Some_class = NULL;
3998 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
3999 static jclass LDKCOption_AccessZ_None_class = NULL;
4000 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
4001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
4002         LDKCOption_AccessZ_Some_class =
4003                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
4004         CHECK(LDKCOption_AccessZ_Some_class != NULL);
4005         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
4006         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
4007         LDKCOption_AccessZ_None_class =
4008                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
4009         CHECK(LDKCOption_AccessZ_None_class != NULL);
4010         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
4011         CHECK(LDKCOption_AccessZ_None_meth != NULL);
4012 }
4013 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4014         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
4015         switch(obj->tag) {
4016                 case LDKCOption_AccessZ_Some: {
4017                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
4018                         *some_ret = obj->some;
4019                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
4020                         if ((*some_ret).free == LDKAccess_JCalls_free) {
4021                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4022                                 LDKAccess_JCalls_cloned(&(*some_ret));
4023                         }
4024                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (int64_t)some_ret);
4025                 }
4026                 case LDKCOption_AccessZ_None: {
4027                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
4028                 }
4029                 default: abort();
4030         }
4031 }
4032 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4033 CHECK(owner->result_ok);
4034         return *owner->contents.result;
4035 }
4036 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4037         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
4038         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
4039         return ret_conv;
4040 }
4041
4042 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4043 CHECK(!owner->result_ok);
4044         return LightningError_clone(&*owner->contents.err);
4045 }
4046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4047         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
4048         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
4049         int64_t ret_ref = 0;
4050         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4051         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4053         ret_ref = (uintptr_t)ret_var.inner;
4054         if (ret_var.is_owned) {
4055                 ret_ref |= 1;
4056         }
4057         return ret_ref;
4058 }
4059
4060 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4061         return ChannelAnnouncement_clone(&owner->a);
4062 }
4063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4064         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
4065         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
4066         int64_t ret_ref = 0;
4067         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4068         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4070         ret_ref = (uintptr_t)ret_var.inner;
4071         if (ret_var.is_owned) {
4072                 ret_ref |= 1;
4073         }
4074         return ret_ref;
4075 }
4076
4077 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4078         return ChannelUpdate_clone(&owner->b);
4079 }
4080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4081         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
4082         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
4083         int64_t ret_ref = 0;
4084         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4085         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4087         ret_ref = (uintptr_t)ret_var.inner;
4088         if (ret_var.is_owned) {
4089                 ret_ref |= 1;
4090         }
4091         return ret_ref;
4092 }
4093
4094 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4095         return ChannelUpdate_clone(&owner->c);
4096 }
4097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
4098         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
4099         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
4100         int64_t ret_ref = 0;
4101         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4102         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4103         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4104         ret_ref = (uintptr_t)ret_var.inner;
4105         if (ret_var.is_owned) {
4106                 ret_ref |= 1;
4107         }
4108         return ret_ref;
4109 }
4110
4111 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
4112         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
4113         for (size_t i = 0; i < ret.datalen; i++) {
4114                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
4115         }
4116         return ret;
4117 }
4118 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
4119         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
4120         for (size_t i = 0; i < ret.datalen; i++) {
4121                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
4122         }
4123         return ret;
4124 }
4125 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4126 CHECK(owner->result_ok);
4127         return *owner->contents.result;
4128 }
4129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4130         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
4131         CResult_NoneLightningErrorZ_get_ok(owner_conv);
4132 }
4133
4134 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4135 CHECK(!owner->result_ok);
4136         return LightningError_clone(&*owner->contents.err);
4137 }
4138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4139         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
4140         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
4141         int64_t ret_ref = 0;
4142         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4143         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4145         ret_ref = (uintptr_t)ret_var.inner;
4146         if (ret_var.is_owned) {
4147                 ret_ref |= 1;
4148         }
4149         return ret_ref;
4150 }
4151
4152 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4153 CHECK(owner->result_ok);
4154         return ChannelUpdateInfo_clone(&*owner->contents.result);
4155 }
4156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4157         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
4158         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
4159         int64_t ret_ref = 0;
4160         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4161         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4162         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4163         ret_ref = (uintptr_t)ret_var.inner;
4164         if (ret_var.is_owned) {
4165                 ret_ref |= 1;
4166         }
4167         return ret_ref;
4168 }
4169
4170 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4171 CHECK(!owner->result_ok);
4172         return DecodeError_clone(&*owner->contents.err);
4173 }
4174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4175         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
4176         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
4177         int64_t ret_ref = 0;
4178         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4179         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4181         ret_ref = (uintptr_t)ret_var.inner;
4182         if (ret_var.is_owned) {
4183                 ret_ref |= 1;
4184         }
4185         return ret_ref;
4186 }
4187
4188 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4189 CHECK(owner->result_ok);
4190         return ChannelInfo_clone(&*owner->contents.result);
4191 }
4192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4193         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
4194         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
4195         int64_t ret_ref = 0;
4196         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4197         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4198         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4199         ret_ref = (uintptr_t)ret_var.inner;
4200         if (ret_var.is_owned) {
4201                 ret_ref |= 1;
4202         }
4203         return ret_ref;
4204 }
4205
4206 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4207 CHECK(!owner->result_ok);
4208         return DecodeError_clone(&*owner->contents.err);
4209 }
4210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4211         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
4212         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
4213         int64_t ret_ref = 0;
4214         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4215         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4217         ret_ref = (uintptr_t)ret_var.inner;
4218         if (ret_var.is_owned) {
4219                 ret_ref |= 1;
4220         }
4221         return ret_ref;
4222 }
4223
4224 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4225 CHECK(owner->result_ok);
4226         return RoutingFees_clone(&*owner->contents.result);
4227 }
4228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4229         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
4230         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
4231         int64_t ret_ref = 0;
4232         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4233         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4235         ret_ref = (uintptr_t)ret_var.inner;
4236         if (ret_var.is_owned) {
4237                 ret_ref |= 1;
4238         }
4239         return ret_ref;
4240 }
4241
4242 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4243 CHECK(!owner->result_ok);
4244         return DecodeError_clone(&*owner->contents.err);
4245 }
4246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4247         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
4248         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
4249         int64_t ret_ref = 0;
4250         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4251         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4253         ret_ref = (uintptr_t)ret_var.inner;
4254         if (ret_var.is_owned) {
4255                 ret_ref |= 1;
4256         }
4257         return ret_ref;
4258 }
4259
4260 static jclass LDKNetAddress_IPv4_class = NULL;
4261 static jmethodID LDKNetAddress_IPv4_meth = NULL;
4262 static jclass LDKNetAddress_IPv6_class = NULL;
4263 static jmethodID LDKNetAddress_IPv6_meth = NULL;
4264 static jclass LDKNetAddress_OnionV2_class = NULL;
4265 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
4266 static jclass LDKNetAddress_OnionV3_class = NULL;
4267 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
4268 static jclass LDKNetAddress_Hostname_class = NULL;
4269 static jmethodID LDKNetAddress_Hostname_meth = NULL;
4270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
4271         LDKNetAddress_IPv4_class =
4272                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
4273         CHECK(LDKNetAddress_IPv4_class != NULL);
4274         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
4275         CHECK(LDKNetAddress_IPv4_meth != NULL);
4276         LDKNetAddress_IPv6_class =
4277                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
4278         CHECK(LDKNetAddress_IPv6_class != NULL);
4279         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
4280         CHECK(LDKNetAddress_IPv6_meth != NULL);
4281         LDKNetAddress_OnionV2_class =
4282                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
4283         CHECK(LDKNetAddress_OnionV2_class != NULL);
4284         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
4285         CHECK(LDKNetAddress_OnionV2_meth != NULL);
4286         LDKNetAddress_OnionV3_class =
4287                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
4288         CHECK(LDKNetAddress_OnionV3_class != NULL);
4289         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
4290         CHECK(LDKNetAddress_OnionV3_meth != NULL);
4291         LDKNetAddress_Hostname_class =
4292                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$Hostname"));
4293         CHECK(LDKNetAddress_Hostname_class != NULL);
4294         LDKNetAddress_Hostname_meth = (*env)->GetMethodID(env, LDKNetAddress_Hostname_class, "<init>", "(JS)V");
4295         CHECK(LDKNetAddress_Hostname_meth != NULL);
4296 }
4297 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4298         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4299         switch(obj->tag) {
4300                 case LDKNetAddress_IPv4: {
4301                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
4302                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
4303                         int16_t port_conv = obj->i_pv4.port;
4304                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, port_conv);
4305                 }
4306                 case LDKNetAddress_IPv6: {
4307                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
4308                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
4309                         int16_t port_conv = obj->i_pv6.port;
4310                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, port_conv);
4311                 }
4312                 case LDKNetAddress_OnionV2: {
4313                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
4314                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
4315                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
4316                 }
4317                 case LDKNetAddress_OnionV3: {
4318                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
4319                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
4320                         int16_t checksum_conv = obj->onion_v3.checksum;
4321                         int8_t version_conv = obj->onion_v3.version;
4322                         int16_t port_conv = obj->onion_v3.port;
4323                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, checksum_conv, version_conv, port_conv);
4324                 }
4325                 case LDKNetAddress_Hostname: {
4326                         LDKHostname hostname_var = obj->hostname.hostname;
4327                         int64_t hostname_ref = 0;
4328                         CHECK((((uintptr_t)hostname_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4329                         CHECK((((uintptr_t)&hostname_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4330                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
4331                         hostname_ref = (uintptr_t)hostname_var.inner & ~1;
4332                         int16_t port_conv = obj->hostname.port;
4333                         return (*env)->NewObject(env, LDKNetAddress_Hostname_class, LDKNetAddress_Hostname_meth, hostname_ref, port_conv);
4334                 }
4335                 default: abort();
4336         }
4337 }
4338 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4339         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4340         for (size_t i = 0; i < ret.datalen; i++) {
4341                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4342         }
4343         return ret;
4344 }
4345 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4346 CHECK(owner->result_ok);
4347         return NodeAnnouncementInfo_clone(&*owner->contents.result);
4348 }
4349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4350         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
4351         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
4352         int64_t ret_ref = 0;
4353         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4354         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4356         ret_ref = (uintptr_t)ret_var.inner;
4357         if (ret_var.is_owned) {
4358                 ret_ref |= 1;
4359         }
4360         return ret_ref;
4361 }
4362
4363 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4364 CHECK(!owner->result_ok);
4365         return DecodeError_clone(&*owner->contents.err);
4366 }
4367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4368         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
4369         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
4370         int64_t ret_ref = 0;
4371         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4372         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4374         ret_ref = (uintptr_t)ret_var.inner;
4375         if (ret_var.is_owned) {
4376                 ret_ref |= 1;
4377         }
4378         return ret_ref;
4379 }
4380
4381 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4382 CHECK(owner->result_ok);
4383         return NodeAlias_clone(&*owner->contents.result);
4384 }
4385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4386         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
4387         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
4388         int64_t ret_ref = 0;
4389         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4390         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4392         ret_ref = (uintptr_t)ret_var.inner;
4393         if (ret_var.is_owned) {
4394                 ret_ref |= 1;
4395         }
4396         return ret_ref;
4397 }
4398
4399 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4400 CHECK(!owner->result_ok);
4401         return DecodeError_clone(&*owner->contents.err);
4402 }
4403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4404         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
4405         LDKDecodeError ret_var = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
4406         int64_t ret_ref = 0;
4407         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4408         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4410         ret_ref = (uintptr_t)ret_var.inner;
4411         if (ret_var.is_owned) {
4412                 ret_ref |= 1;
4413         }
4414         return ret_ref;
4415 }
4416
4417 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4418 CHECK(owner->result_ok);
4419         return NodeInfo_clone(&*owner->contents.result);
4420 }
4421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4422         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
4423         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
4424         int64_t ret_ref = 0;
4425         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4426         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4428         ret_ref = (uintptr_t)ret_var.inner;
4429         if (ret_var.is_owned) {
4430                 ret_ref |= 1;
4431         }
4432         return ret_ref;
4433 }
4434
4435 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4436 CHECK(!owner->result_ok);
4437         return DecodeError_clone(&*owner->contents.err);
4438 }
4439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4440         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
4441         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
4442         int64_t ret_ref = 0;
4443         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4444         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4446         ret_ref = (uintptr_t)ret_var.inner;
4447         if (ret_var.is_owned) {
4448                 ret_ref |= 1;
4449         }
4450         return ret_ref;
4451 }
4452
4453 static inline struct LDKNetworkGraph *CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4454 CHECK(owner->result_ok);
4455         return &*owner->contents.result;
4456 }
4457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4458         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
4459         LDKNetworkGraph ret_var = *CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
4460         int64_t ret_ref = 0;
4461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4464         ret_ref = (uintptr_t)ret_var.inner & ~1;
4465         return ret_ref;
4466 }
4467
4468 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4469 CHECK(!owner->result_ok);
4470         return DecodeError_clone(&*owner->contents.err);
4471 }
4472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4473         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
4474         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
4475         int64_t ret_ref = 0;
4476         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4477         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4479         ret_ref = (uintptr_t)ret_var.inner;
4480         if (ret_var.is_owned) {
4481                 ret_ref |= 1;
4482         }
4483         return ret_ref;
4484 }
4485
4486 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
4487 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
4488 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
4489 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
4490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
4491         LDKCOption_CVec_NetAddressZZ_Some_class =
4492                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
4493         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
4494         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
4495         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
4496         LDKCOption_CVec_NetAddressZZ_None_class =
4497                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
4498         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
4499         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
4500         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
4501 }
4502 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4503         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
4504         switch(obj->tag) {
4505                 case LDKCOption_CVec_NetAddressZZ_Some: {
4506                         LDKCVec_NetAddressZ some_var = obj->some;
4507                         int64_tArray some_arr = NULL;
4508                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
4509                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
4510                         for (size_t m = 0; m < some_var.datalen; m++) {
4511                                 int64_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
4512                                 some_arr_ptr[m] = some_conv_12_ref;
4513                         }
4514                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
4515                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
4516                 }
4517                 case LDKCOption_CVec_NetAddressZZ_None: {
4518                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
4519                 }
4520                 default: abort();
4521         }
4522 }
4523 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4524 CHECK(owner->result_ok);
4525         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
4526 }
4527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4528         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4529         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4530         int64_t ret_ref = 0;
4531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4534         ret_ref = (uintptr_t)ret_var.inner;
4535         if (ret_var.is_owned) {
4536                 ret_ref |= 1;
4537         }
4538         return ret_ref;
4539 }
4540
4541 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4542 CHECK(!owner->result_ok);
4543         return DecodeError_clone(&*owner->contents.err);
4544 }
4545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4546         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4547         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4548         int64_t ret_ref = 0;
4549         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4550         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4552         ret_ref = (uintptr_t)ret_var.inner;
4553         if (ret_var.is_owned) {
4554                 ret_ref |= 1;
4555         }
4556         return ret_ref;
4557 }
4558
4559 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4560 CHECK(owner->result_ok);
4561         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
4562 }
4563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4564         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4565         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4566         int64_t ret_ref = 0;
4567         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4568         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4570         ret_ref = (uintptr_t)ret_var.inner;
4571         if (ret_var.is_owned) {
4572                 ret_ref |= 1;
4573         }
4574         return ret_ref;
4575 }
4576
4577 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4578 CHECK(!owner->result_ok);
4579         return DecodeError_clone(&*owner->contents.err);
4580 }
4581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4582         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4583         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4584         int64_t ret_ref = 0;
4585         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4586         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4588         ret_ref = (uintptr_t)ret_var.inner;
4589         if (ret_var.is_owned) {
4590                 ret_ref |= 1;
4591         }
4592         return ret_ref;
4593 }
4594
4595 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4596 CHECK(owner->result_ok);
4597         return SpendableOutputDescriptor_clone(&*owner->contents.result);
4598 }
4599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4600         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
4601         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
4602         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4603         int64_t ret_ref = (uintptr_t)ret_copy;
4604         return ret_ref;
4605 }
4606
4607 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4608 CHECK(!owner->result_ok);
4609         return DecodeError_clone(&*owner->contents.err);
4610 }
4611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4612         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
4613         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4614         int64_t ret_ref = 0;
4615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4618         ret_ref = (uintptr_t)ret_var.inner;
4619         if (ret_var.is_owned) {
4620                 ret_ref |= 1;
4621         }
4622         return ret_ref;
4623 }
4624
4625 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
4626         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
4627         for (size_t i = 0; i < ret.datalen; i++) {
4628                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4629         }
4630         return ret;
4631 }
4632 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4633         return owner->a;
4634 }
4635 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4636         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
4637         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4638         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
4639         return ret_arr;
4640 }
4641
4642 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4643         return owner->b;
4644 }
4645 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4646         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
4647         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
4648         jobjectArray ret_arr = NULL;
4649         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
4650         ;
4651         for (size_t i = 0; i < ret_var.datalen; i++) {
4652                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
4653                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
4654                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
4655         }
4656         
4657         return ret_arr;
4658 }
4659
4660 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
4661 CHECK(owner->result_ok);
4662         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
4663 }
4664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4665         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
4666         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
4667         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
4668         return ((int64_t)ret_conv);
4669 }
4670
4671 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
4672 CHECK(!owner->result_ok);
4673         return *owner->contents.err;
4674 }
4675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4676         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
4677         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
4678 }
4679
4680 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
4681 CHECK(owner->result_ok);
4682         return *owner->contents.result;
4683 }
4684 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4685         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
4686         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4687         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
4688         return ret_arr;
4689 }
4690
4691 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
4692 CHECK(!owner->result_ok);
4693         return *owner->contents.err;
4694 }
4695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4696         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
4697         CResult_SignatureNoneZ_get_err(owner_conv);
4698 }
4699
4700 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
4701         return owner->a;
4702 }
4703 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4704         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
4705         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4706         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
4707         return ret_arr;
4708 }
4709
4710 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
4711         return owner->b;
4712 }
4713 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4714         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
4715         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4716         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
4717         return ret_arr;
4718 }
4719
4720 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
4721 CHECK(owner->result_ok);
4722         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
4723 }
4724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4725         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
4726         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
4727         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
4728         return ((int64_t)ret_conv);
4729 }
4730
4731 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
4732 CHECK(!owner->result_ok);
4733         return *owner->contents.err;
4734 }
4735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4736         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
4737         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
4738 }
4739
4740 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
4741 CHECK(owner->result_ok);
4742         return *owner->contents.result;
4743 }
4744 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4745         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
4746         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4747         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
4748         return ret_arr;
4749 }
4750
4751 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
4752 CHECK(!owner->result_ok);
4753         return *owner->contents.err;
4754 }
4755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4756         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
4757         CResult_SecretKeyNoneZ_get_err(owner_conv);
4758 }
4759
4760 typedef struct LDKBaseSign_JCalls {
4761         atomic_size_t refcnt;
4762         JavaVM *vm;
4763         jweak o;
4764         jmethodID get_per_commitment_point_meth;
4765         jmethodID release_commitment_secret_meth;
4766         jmethodID validate_holder_commitment_meth;
4767         jmethodID channel_keys_id_meth;
4768         jmethodID sign_counterparty_commitment_meth;
4769         jmethodID validate_counterparty_revocation_meth;
4770         jmethodID sign_holder_commitment_and_htlcs_meth;
4771         jmethodID sign_justice_revoked_output_meth;
4772         jmethodID sign_justice_revoked_htlc_meth;
4773         jmethodID sign_counterparty_htlc_transaction_meth;
4774         jmethodID sign_closing_transaction_meth;
4775         jmethodID sign_channel_announcement_meth;
4776         jmethodID ready_channel_meth;
4777 } LDKBaseSign_JCalls;
4778 static void LDKBaseSign_JCalls_free(void* this_arg) {
4779         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4780         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4781                 JNIEnv *env;
4782                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4783                 if (get_jenv_res == JNI_EDETACHED) {
4784                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4785                 } else {
4786                         DO_ASSERT(get_jenv_res == JNI_OK);
4787                 }
4788                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4789                 if (get_jenv_res == JNI_EDETACHED) {
4790                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4791                 }
4792                 FREE(j_calls);
4793         }
4794 }
4795 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
4796         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4797         JNIEnv *env;
4798         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4799         if (get_jenv_res == JNI_EDETACHED) {
4800                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4801         } else {
4802                 DO_ASSERT(get_jenv_res == JNI_OK);
4803         }
4804         int64_t idx_conv = idx;
4805         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4806         CHECK(obj != NULL);
4807         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx_conv);
4808         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4809                 (*env)->ExceptionDescribe(env);
4810                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
4811         }
4812         LDKPublicKey ret_ref;
4813         CHECK((*env)->GetArrayLength(env, ret) == 33);
4814         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
4815         if (get_jenv_res == JNI_EDETACHED) {
4816                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4817         }
4818         return ret_ref;
4819 }
4820 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
4821         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4822         JNIEnv *env;
4823         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4824         if (get_jenv_res == JNI_EDETACHED) {
4825                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4826         } else {
4827                 DO_ASSERT(get_jenv_res == JNI_OK);
4828         }
4829         int64_t idx_conv = idx;
4830         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4831         CHECK(obj != NULL);
4832         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx_conv);
4833         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4834                 (*env)->ExceptionDescribe(env);
4835                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
4836         }
4837         LDKThirtyTwoBytes ret_ref;
4838         CHECK((*env)->GetArrayLength(env, ret) == 32);
4839         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4840         if (get_jenv_res == JNI_EDETACHED) {
4841                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4842         }
4843         return ret_ref;
4844 }
4845 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
4846         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4847         JNIEnv *env;
4848         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4849         if (get_jenv_res == JNI_EDETACHED) {
4850                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4851         } else {
4852                 DO_ASSERT(get_jenv_res == JNI_OK);
4853         }
4854         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
4855         int64_t holder_tx_ref = 0;
4856         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
4857         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4858         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4859         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
4860         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
4861         if (holder_tx_var.is_owned) {
4862                 holder_tx_ref |= 1;
4863         }
4864         LDKCVec_PaymentPreimageZ preimages_var = preimages;
4865         jobjectArray preimages_arr = NULL;
4866         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
4867         ;
4868         for (size_t i = 0; i < preimages_var.datalen; i++) {
4869                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
4870                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
4871                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
4872         }
4873         
4874         FREE(preimages_var.data);
4875         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4876         CHECK(obj != NULL);
4877         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
4878         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4879                 (*env)->ExceptionDescribe(env);
4880                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
4881         }
4882         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4883         CHECK_ACCESS(ret_ptr);
4884         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4885         FREE((void*)ret);
4886         if (get_jenv_res == JNI_EDETACHED) {
4887                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4888         }
4889         return ret_conv;
4890 }
4891 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
4892         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4893         JNIEnv *env;
4894         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4895         if (get_jenv_res == JNI_EDETACHED) {
4896                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4897         } else {
4898                 DO_ASSERT(get_jenv_res == JNI_OK);
4899         }
4900         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4901         CHECK(obj != NULL);
4902         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
4903         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4904                 (*env)->ExceptionDescribe(env);
4905                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
4906         }
4907         LDKThirtyTwoBytes ret_ref;
4908         CHECK((*env)->GetArrayLength(env, ret) == 32);
4909         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4910         if (get_jenv_res == JNI_EDETACHED) {
4911                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4912         }
4913         return ret_ref;
4914 }
4915 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
4916         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4917         JNIEnv *env;
4918         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4919         if (get_jenv_res == JNI_EDETACHED) {
4920                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4921         } else {
4922                 DO_ASSERT(get_jenv_res == JNI_OK);
4923         }
4924         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
4925         int64_t commitment_tx_ref = 0;
4926         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
4927         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4928         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4929         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
4930         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
4931         if (commitment_tx_var.is_owned) {
4932                 commitment_tx_ref |= 1;
4933         }
4934         LDKCVec_PaymentPreimageZ preimages_var = preimages;
4935         jobjectArray preimages_arr = NULL;
4936         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
4937         ;
4938         for (size_t i = 0; i < preimages_var.datalen; i++) {
4939                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
4940                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
4941                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
4942         }
4943         
4944         FREE(preimages_var.data);
4945         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4946         CHECK(obj != NULL);
4947         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
4948         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4949                 (*env)->ExceptionDescribe(env);
4950                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
4951         }
4952         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4953         CHECK_ACCESS(ret_ptr);
4954         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
4955         FREE((void*)ret);
4956         if (get_jenv_res == JNI_EDETACHED) {
4957                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4958         }
4959         return ret_conv;
4960 }
4961 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
4962         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4963         JNIEnv *env;
4964         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4965         if (get_jenv_res == JNI_EDETACHED) {
4966                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4967         } else {
4968                 DO_ASSERT(get_jenv_res == JNI_OK);
4969         }
4970         int64_t idx_conv = idx;
4971         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
4972         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
4973         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4974         CHECK(obj != NULL);
4975         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx_conv, secret_arr);
4976         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4977                 (*env)->ExceptionDescribe(env);
4978                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
4979         }
4980         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4981         CHECK_ACCESS(ret_ptr);
4982         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4983         FREE((void*)ret);
4984         if (get_jenv_res == JNI_EDETACHED) {
4985                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4986         }
4987         return ret_conv;
4988 }
4989 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
4990         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4991         JNIEnv *env;
4992         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4993         if (get_jenv_res == JNI_EDETACHED) {
4994                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4995         } else {
4996                 DO_ASSERT(get_jenv_res == JNI_OK);
4997         }
4998         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
4999         int64_t commitment_tx_ref = 0;
5000         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
5001         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5002         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5003         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
5004         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
5005         if (commitment_tx_var.is_owned) {
5006                 commitment_tx_ref |= 1;
5007         }
5008         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5009         CHECK(obj != NULL);
5010         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
5011         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5012                 (*env)->ExceptionDescribe(env);
5013                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
5014         }
5015         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5016         CHECK_ACCESS(ret_ptr);
5017         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
5018         FREE((void*)ret);
5019         if (get_jenv_res == JNI_EDETACHED) {
5020                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5021         }
5022         return ret_conv;
5023 }
5024 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]) {
5025         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5026         JNIEnv *env;
5027         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5028         if (get_jenv_res == JNI_EDETACHED) {
5029                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5030         } else {
5031                 DO_ASSERT(get_jenv_res == JNI_OK);
5032         }
5033         LDKTransaction justice_tx_var = justice_tx;
5034         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
5035         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
5036         Transaction_free(justice_tx_var);
5037         int64_t input_conv = input;
5038         int64_t amount_conv = amount;
5039         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
5040         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
5041         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5042         CHECK(obj != NULL);
5043         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input_conv, amount_conv, per_commitment_key_arr);
5044         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5045                 (*env)->ExceptionDescribe(env);
5046                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
5047         }
5048         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5049         CHECK_ACCESS(ret_ptr);
5050         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5051         FREE((void*)ret);
5052         if (get_jenv_res == JNI_EDETACHED) {
5053                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5054         }
5055         return ret_conv;
5056 }
5057 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) {
5058         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5059         JNIEnv *env;
5060         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5061         if (get_jenv_res == JNI_EDETACHED) {
5062                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5063         } else {
5064                 DO_ASSERT(get_jenv_res == JNI_OK);
5065         }
5066         LDKTransaction justice_tx_var = justice_tx;
5067         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
5068         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
5069         Transaction_free(justice_tx_var);
5070         int64_t input_conv = input;
5071         int64_t amount_conv = amount;
5072         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
5073         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
5074         LDKHTLCOutputInCommitment htlc_var = *htlc;
5075         int64_t htlc_ref = 0;
5076         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
5077         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5078         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5079         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
5080         htlc_ref = (uintptr_t)htlc_var.inner;
5081         if (htlc_var.is_owned) {
5082                 htlc_ref |= 1;
5083         }
5084         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5085         CHECK(obj != NULL);
5086         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input_conv, amount_conv, per_commitment_key_arr, htlc_ref);
5087         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5088                 (*env)->ExceptionDescribe(env);
5089                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
5090         }
5091         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5092         CHECK_ACCESS(ret_ptr);
5093         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5094         FREE((void*)ret);
5095         if (get_jenv_res == JNI_EDETACHED) {
5096                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5097         }
5098         return ret_conv;
5099 }
5100 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) {
5101         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5102         JNIEnv *env;
5103         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5104         if (get_jenv_res == JNI_EDETACHED) {
5105                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5106         } else {
5107                 DO_ASSERT(get_jenv_res == JNI_OK);
5108         }
5109         LDKTransaction htlc_tx_var = htlc_tx;
5110         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
5111         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
5112         Transaction_free(htlc_tx_var);
5113         int64_t input_conv = input;
5114         int64_t amount_conv = amount;
5115         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
5116         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
5117         LDKHTLCOutputInCommitment htlc_var = *htlc;
5118         int64_t htlc_ref = 0;
5119         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
5120         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5121         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5122         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
5123         htlc_ref = (uintptr_t)htlc_var.inner;
5124         if (htlc_var.is_owned) {
5125                 htlc_ref |= 1;
5126         }
5127         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5128         CHECK(obj != NULL);
5129         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input_conv, amount_conv, per_commitment_point_arr, htlc_ref);
5130         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5131                 (*env)->ExceptionDescribe(env);
5132                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
5133         }
5134         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5135         CHECK_ACCESS(ret_ptr);
5136         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5137         FREE((void*)ret);
5138         if (get_jenv_res == JNI_EDETACHED) {
5139                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5140         }
5141         return ret_conv;
5142 }
5143 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
5144         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5145         JNIEnv *env;
5146         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5147         if (get_jenv_res == JNI_EDETACHED) {
5148                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5149         } else {
5150                 DO_ASSERT(get_jenv_res == JNI_OK);
5151         }
5152         LDKClosingTransaction closing_tx_var = *closing_tx;
5153         int64_t closing_tx_ref = 0;
5154         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
5155         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5156         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5157         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
5158         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
5159         if (closing_tx_var.is_owned) {
5160                 closing_tx_ref |= 1;
5161         }
5162         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5163         CHECK(obj != NULL);
5164         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
5165         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5166                 (*env)->ExceptionDescribe(env);
5167                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
5168         }
5169         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5170         CHECK_ACCESS(ret_ptr);
5171         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5172         FREE((void*)ret);
5173         if (get_jenv_res == JNI_EDETACHED) {
5174                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5175         }
5176         return ret_conv;
5177 }
5178 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
5179         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5180         JNIEnv *env;
5181         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5182         if (get_jenv_res == JNI_EDETACHED) {
5183                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5184         } else {
5185                 DO_ASSERT(get_jenv_res == JNI_OK);
5186         }
5187         LDKUnsignedChannelAnnouncement msg_var = *msg;
5188         int64_t msg_ref = 0;
5189         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
5190         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5191         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5192         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
5193         msg_ref = (uintptr_t)msg_var.inner;
5194         if (msg_var.is_owned) {
5195                 msg_ref |= 1;
5196         }
5197         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5198         CHECK(obj != NULL);
5199         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
5200         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5201                 (*env)->ExceptionDescribe(env);
5202                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
5203         }
5204         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5205         CHECK_ACCESS(ret_ptr);
5206         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
5207         FREE((void*)ret);
5208         if (get_jenv_res == JNI_EDETACHED) {
5209                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5210         }
5211         return ret_conv;
5212 }
5213 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
5214         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5215         JNIEnv *env;
5216         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5217         if (get_jenv_res == JNI_EDETACHED) {
5218                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5219         } else {
5220                 DO_ASSERT(get_jenv_res == JNI_OK);
5221         }
5222         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
5223         int64_t channel_parameters_ref = 0;
5224         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
5225         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5226         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5227         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
5228         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
5229         if (channel_parameters_var.is_owned) {
5230                 channel_parameters_ref |= 1;
5231         }
5232         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5233         CHECK(obj != NULL);
5234         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
5235         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5236                 (*env)->ExceptionDescribe(env);
5237                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
5238         }
5239         if (get_jenv_res == JNI_EDETACHED) {
5240                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5241         }
5242 }
5243 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5244         jclass c = (*env)->GetObjectClass(env, o);
5245         CHECK(c != NULL);
5246         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
5247         atomic_init(&calls->refcnt, 1);
5248         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5249         calls->o = (*env)->NewWeakGlobalRef(env, o);
5250         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
5251         CHECK(calls->get_per_commitment_point_meth != NULL);
5252         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
5253         CHECK(calls->release_commitment_secret_meth != NULL);
5254         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
5255         CHECK(calls->validate_holder_commitment_meth != NULL);
5256         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
5257         CHECK(calls->channel_keys_id_meth != NULL);
5258         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
5259         CHECK(calls->sign_counterparty_commitment_meth != NULL);
5260         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
5261         CHECK(calls->validate_counterparty_revocation_meth != NULL);
5262         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
5263         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
5264         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
5265         CHECK(calls->sign_justice_revoked_output_meth != NULL);
5266         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
5267         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
5268         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
5269         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
5270         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
5271         CHECK(calls->sign_closing_transaction_meth != NULL);
5272         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
5273         CHECK(calls->sign_channel_announcement_meth != NULL);
5274         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
5275         CHECK(calls->ready_channel_meth != NULL);
5276
5277         LDKChannelPublicKeys pubkeys_conv;
5278         pubkeys_conv.inner = (void*)(pubkeys & (~1));
5279         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
5280         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5281
5282         LDKBaseSign ret = {
5283                 .this_arg = (void*) calls,
5284                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
5285                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
5286                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
5287                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
5288                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
5289                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
5290                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
5291                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
5292                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
5293                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
5294                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
5295                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
5296                 .ready_channel = ready_channel_LDKBaseSign_jcall,
5297                 .free = LDKBaseSign_JCalls_free,
5298                 .pubkeys = pubkeys_conv,
5299                 .set_pubkeys = NULL,
5300         };
5301         return ret;
5302 }
5303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5304         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
5305         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
5306         return (uint64_t)res_ptr;
5307 }
5308 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) {
5309         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5310         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5311         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5312         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5313         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
5314         return ret_arr;
5315 }
5316
5317 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
5318         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5319         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5320         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5321         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5322         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
5323         return ret_arr;
5324 }
5325
5326 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) {
5327         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5328         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5329         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5330         LDKHolderCommitmentTransaction holder_tx_conv;
5331         holder_tx_conv.inner = (void*)(holder_tx & (~1));
5332         holder_tx_conv.is_owned = false;
5333         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
5334         LDKCVec_PaymentPreimageZ preimages_constr;
5335         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5336         if (preimages_constr.datalen > 0)
5337                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5338         else
5339                 preimages_constr.data = NULL;
5340         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5341                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5342                 LDKThirtyTwoBytes preimages_conv_8_ref;
5343                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5344                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5345                 preimages_constr.data[i] = preimages_conv_8_ref;
5346         }
5347         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5348         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
5349         return (int64_t)ret_conv;
5350 }
5351
5352 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
5353         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5354         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5355         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5356         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5357         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
5358         return ret_arr;
5359 }
5360
5361 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) {
5362         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5363         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5364         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5365         LDKCommitmentTransaction commitment_tx_conv;
5366         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
5367         commitment_tx_conv.is_owned = false;
5368         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5369         LDKCVec_PaymentPreimageZ preimages_constr;
5370         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5371         if (preimages_constr.datalen > 0)
5372                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5373         else
5374                 preimages_constr.data = NULL;
5375         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5376                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5377                 LDKThirtyTwoBytes preimages_conv_8_ref;
5378                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5379                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5380                 preimages_constr.data[i] = preimages_conv_8_ref;
5381         }
5382         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5383         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
5384         return (int64_t)ret_conv;
5385 }
5386
5387 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) {
5388         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5389         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5390         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5391         unsigned char secret_arr[32];
5392         CHECK((*env)->GetArrayLength(env, secret) == 32);
5393         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
5394         unsigned char (*secret_ref)[32] = &secret_arr;
5395         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5396         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
5397         return (int64_t)ret_conv;
5398 }
5399
5400 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) {
5401         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5402         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5403         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5404         LDKHolderCommitmentTransaction commitment_tx_conv;
5405         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
5406         commitment_tx_conv.is_owned = false;
5407         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5408         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5409         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
5410         return (int64_t)ret_conv;
5411 }
5412
5413 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) {
5414         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5415         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5416         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5417         LDKTransaction justice_tx_ref;
5418         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5419         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5420         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5421         justice_tx_ref.data_is_owned = true;
5422         unsigned char per_commitment_key_arr[32];
5423         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5424         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5425         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5426         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5427         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
5428         return (int64_t)ret_conv;
5429 }
5430
5431 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) {
5432         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5433         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5434         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5435         LDKTransaction justice_tx_ref;
5436         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5437         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5438         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5439         justice_tx_ref.data_is_owned = true;
5440         unsigned char per_commitment_key_arr[32];
5441         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5442         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5443         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5444         LDKHTLCOutputInCommitment htlc_conv;
5445         htlc_conv.inner = (void*)(htlc & (~1));
5446         htlc_conv.is_owned = false;
5447         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5448         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5449         *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);
5450         return (int64_t)ret_conv;
5451 }
5452
5453 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) {
5454         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5455         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5456         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5457         LDKTransaction htlc_tx_ref;
5458         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
5459         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
5460         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
5461         htlc_tx_ref.data_is_owned = true;
5462         LDKPublicKey per_commitment_point_ref;
5463         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
5464         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
5465         LDKHTLCOutputInCommitment htlc_conv;
5466         htlc_conv.inner = (void*)(htlc & (~1));
5467         htlc_conv.is_owned = false;
5468         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5469         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5470         *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);
5471         return (int64_t)ret_conv;
5472 }
5473
5474 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) {
5475         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5476         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5477         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5478         LDKClosingTransaction closing_tx_conv;
5479         closing_tx_conv.inner = (void*)(closing_tx & (~1));
5480         closing_tx_conv.is_owned = false;
5481         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
5482         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5483         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
5484         return (int64_t)ret_conv;
5485 }
5486
5487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
5488         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5489         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5490         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5491         LDKUnsignedChannelAnnouncement msg_conv;
5492         msg_conv.inner = (void*)(msg & (~1));
5493         msg_conv.is_owned = false;
5494         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
5495         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
5496         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
5497         return (int64_t)ret_conv;
5498 }
5499
5500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
5501         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5502         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5503         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5504         LDKChannelTransactionParameters channel_parameters_conv;
5505         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
5506         channel_parameters_conv.is_owned = false;
5507         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
5508         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
5509 }
5510
5511 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
5512         if (this_arg->set_pubkeys != NULL)
5513                 this_arg->set_pubkeys(this_arg);
5514         return this_arg->pubkeys;
5515 }
5516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
5517         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5518         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5519         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5520         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
5521         int64_t ret_ref = 0;
5522         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5523         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5525         ret_ref = (uintptr_t)ret_var.inner;
5526         if (ret_var.is_owned) {
5527                 ret_ref |= 1;
5528         }
5529         return ret_ref;
5530 }
5531
5532 typedef struct LDKSign_JCalls {
5533         atomic_size_t refcnt;
5534         JavaVM *vm;
5535         jweak o;
5536         LDKBaseSign_JCalls* BaseSign;
5537         jmethodID write_meth;
5538 } LDKSign_JCalls;
5539 static void LDKSign_JCalls_free(void* this_arg) {
5540         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5541         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5542                 JNIEnv *env;
5543                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5544                 if (get_jenv_res == JNI_EDETACHED) {
5545                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5546                 } else {
5547                         DO_ASSERT(get_jenv_res == JNI_OK);
5548                 }
5549                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5550                 if (get_jenv_res == JNI_EDETACHED) {
5551                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5552                 }
5553                 FREE(j_calls);
5554         }
5555 }
5556 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
5557         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5558         JNIEnv *env;
5559         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5560         if (get_jenv_res == JNI_EDETACHED) {
5561                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5562         } else {
5563                 DO_ASSERT(get_jenv_res == JNI_OK);
5564         }
5565         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5566         CHECK(obj != NULL);
5567         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
5568         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5569                 (*env)->ExceptionDescribe(env);
5570                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
5571         }
5572         LDKCVec_u8Z ret_ref;
5573         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5574         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5575         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5576         if (get_jenv_res == JNI_EDETACHED) {
5577                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5578         }
5579         return ret_ref;
5580 }
5581 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
5582         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
5583         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5584         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
5585 }
5586 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5587         jclass c = (*env)->GetObjectClass(env, o);
5588         CHECK(c != NULL);
5589         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
5590         atomic_init(&calls->refcnt, 1);
5591         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5592         calls->o = (*env)->NewWeakGlobalRef(env, o);
5593         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
5594         CHECK(calls->write_meth != NULL);
5595
5596         LDKChannelPublicKeys pubkeys_conv;
5597         pubkeys_conv.inner = (void*)(pubkeys & (~1));
5598         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
5599         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5600
5601         LDKSign ret = {
5602                 .this_arg = (void*) calls,
5603                 .write = write_LDKSign_jcall,
5604                 .cloned = LDKSign_JCalls_cloned,
5605                 .free = LDKSign_JCalls_free,
5606                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
5607         };
5608         calls->BaseSign = ret.BaseSign.this_arg;
5609         return ret;
5610 }
5611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5612         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
5613         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
5614         return (uint64_t)res_ptr;
5615 }
5616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
5617         LDKSign *inp = (LDKSign *)(arg & ~1);
5618         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
5619         DO_ASSERT((res_ptr & 1) == 0);
5620         return (int64_t)(res_ptr | 1);
5621 }
5622 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
5623         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5624         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5625         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
5626         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5627         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5628         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5629         CVec_u8Z_free(ret_var);
5630         return ret_arr;
5631 }
5632
5633 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5634 CHECK(owner->result_ok);
5635         return Sign_clone(&*owner->contents.result);
5636 }
5637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5638         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5639         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5640         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
5641         return (int64_t)ret_ret;
5642 }
5643
5644 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5645 CHECK(!owner->result_ok);
5646         return DecodeError_clone(&*owner->contents.err);
5647 }
5648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5649         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5650         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
5651         int64_t ret_ref = 0;
5652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5655         ret_ref = (uintptr_t)ret_var.inner;
5656         if (ret_var.is_owned) {
5657                 ret_ref |= 1;
5658         }
5659         return ret_ref;
5660 }
5661
5662 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5663 CHECK(owner->result_ok);
5664         return *owner->contents.result;
5665 }
5666 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5667         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5668         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
5669         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
5670         return ret_arr;
5671 }
5672
5673 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5674 CHECK(!owner->result_ok);
5675         return *owner->contents.err;
5676 }
5677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5678         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5679         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
5680 }
5681
5682 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
5683         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
5684         for (size_t i = 0; i < ret.datalen; i++) {
5685                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
5686         }
5687         return ret;
5688 }
5689 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5690 CHECK(owner->result_ok);
5691         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
5692 }
5693 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5694         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5695         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
5696         jobjectArray ret_arr = NULL;
5697         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
5698         ;
5699         for (size_t i = 0; i < ret_var.datalen; i++) {
5700                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
5701                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
5702                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
5703                 CVec_u8Z_free(ret_conv_8_var);
5704                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
5705         }
5706         
5707         FREE(ret_var.data);
5708         return ret_arr;
5709 }
5710
5711 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5712 CHECK(!owner->result_ok);
5713         return *owner->contents.err;
5714 }
5715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5716         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5717         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
5718 }
5719
5720 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5721 CHECK(owner->result_ok);
5722         return InMemorySigner_clone(&*owner->contents.result);
5723 }
5724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5725         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5726         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
5727         int64_t ret_ref = 0;
5728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5731         ret_ref = (uintptr_t)ret_var.inner;
5732         if (ret_var.is_owned) {
5733                 ret_ref |= 1;
5734         }
5735         return ret_ref;
5736 }
5737
5738 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5739 CHECK(!owner->result_ok);
5740         return DecodeError_clone(&*owner->contents.err);
5741 }
5742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5743         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5744         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
5745         int64_t ret_ref = 0;
5746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5749         ret_ref = (uintptr_t)ret_var.inner;
5750         if (ret_var.is_owned) {
5751                 ret_ref |= 1;
5752         }
5753         return ret_ref;
5754 }
5755
5756 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
5757         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
5758         for (size_t i = 0; i < ret.datalen; i++) {
5759                 ret.data[i] = TxOut_clone(&orig->data[i]);
5760         }
5761         return ret;
5762 }
5763 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5764 CHECK(owner->result_ok);
5765         return *owner->contents.result;
5766 }
5767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5768         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5769         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
5770         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5771         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5772         return ret_arr;
5773 }
5774
5775 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5776 CHECK(!owner->result_ok);
5777         return *owner->contents.err;
5778 }
5779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5780         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5781         CResult_TransactionNoneZ_get_err(owner_conv);
5782 }
5783
5784 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5785         return ThirtyTwoBytes_clone(&owner->a);
5786 }
5787 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5788         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5789         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5790         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
5791         return ret_arr;
5792 }
5793
5794 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5795         return ChannelMonitor_clone(&owner->b);
5796 }
5797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5798         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5799         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
5800         int64_t ret_ref = 0;
5801         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5802         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5804         ret_ref = (uintptr_t)ret_var.inner;
5805         if (ret_var.is_owned) {
5806                 ret_ref |= 1;
5807         }
5808         return ret_ref;
5809 }
5810
5811 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
5812         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
5813         for (size_t i = 0; i < ret.datalen; i++) {
5814                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
5815         }
5816         return ret;
5817 }
5818 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
5819 CHECK(owner->result_ok);
5820         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
5821 }
5822 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5823         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
5824         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
5825         int64_tArray ret_arr = NULL;
5826         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5827         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5828         for (size_t j = 0; j < ret_var.datalen; j++) {
5829                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5830                 *ret_conv_35_conv = ret_var.data[j];
5831                 ret_arr_ptr[j] = ((int64_t)ret_conv_35_conv);
5832         }
5833         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5834         FREE(ret_var.data);
5835         return ret_arr;
5836 }
5837
5838 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
5839 CHECK(!owner->result_ok);
5840         return *owner->contents.err;
5841 }
5842 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5843         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
5844         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
5845         return ret_conv;
5846 }
5847
5848 static jclass LDKCOption_u16Z_Some_class = NULL;
5849 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
5850 static jclass LDKCOption_u16Z_None_class = NULL;
5851 static jmethodID LDKCOption_u16Z_None_meth = NULL;
5852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
5853         LDKCOption_u16Z_Some_class =
5854                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
5855         CHECK(LDKCOption_u16Z_Some_class != NULL);
5856         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
5857         CHECK(LDKCOption_u16Z_Some_meth != NULL);
5858         LDKCOption_u16Z_None_class =
5859                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
5860         CHECK(LDKCOption_u16Z_None_class != NULL);
5861         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
5862         CHECK(LDKCOption_u16Z_None_meth != NULL);
5863 }
5864 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5865         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
5866         switch(obj->tag) {
5867                 case LDKCOption_u16Z_Some: {
5868                         int16_t some_conv = obj->some;
5869                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, some_conv);
5870                 }
5871                 case LDKCOption_u16Z_None: {
5872                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
5873                 }
5874                 default: abort();
5875         }
5876 }
5877 static jclass LDKAPIError_APIMisuseError_class = NULL;
5878 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
5879 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
5880 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
5881 static jclass LDKAPIError_RouteError_class = NULL;
5882 static jmethodID LDKAPIError_RouteError_meth = NULL;
5883 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
5884 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
5885 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
5886 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
5887 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
5888 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
5889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
5890         LDKAPIError_APIMisuseError_class =
5891                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
5892         CHECK(LDKAPIError_APIMisuseError_class != NULL);
5893         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
5894         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
5895         LDKAPIError_FeeRateTooHigh_class =
5896                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
5897         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
5898         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
5899         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
5900         LDKAPIError_RouteError_class =
5901                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
5902         CHECK(LDKAPIError_RouteError_class != NULL);
5903         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
5904         CHECK(LDKAPIError_RouteError_meth != NULL);
5905         LDKAPIError_ChannelUnavailable_class =
5906                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
5907         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
5908         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
5909         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
5910         LDKAPIError_MonitorUpdateFailed_class =
5911                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed"));
5912         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
5913         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
5914         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
5915         LDKAPIError_IncompatibleShutdownScript_class =
5916                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
5917         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
5918         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
5919         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
5920 }
5921 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5922         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5923         switch(obj->tag) {
5924                 case LDKAPIError_APIMisuseError: {
5925                         LDKStr err_str = obj->api_misuse_error.err;
5926                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5927                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
5928                 }
5929                 case LDKAPIError_FeeRateTooHigh: {
5930                         LDKStr err_str = obj->fee_rate_too_high.err;
5931                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5932                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
5933                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, feerate_conv);
5934                 }
5935                 case LDKAPIError_RouteError: {
5936                         LDKStr err_str = obj->route_error.err;
5937                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5938                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
5939                 }
5940                 case LDKAPIError_ChannelUnavailable: {
5941                         LDKStr err_str = obj->channel_unavailable.err;
5942                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5943                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
5944                 }
5945                 case LDKAPIError_MonitorUpdateFailed: {
5946                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
5947                 }
5948                 case LDKAPIError_IncompatibleShutdownScript: {
5949                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
5950                         int64_t script_ref = 0;
5951                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5952                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5953                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
5954                         script_ref = (uintptr_t)script_var.inner & ~1;
5955                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
5956                 }
5957                 default: abort();
5958         }
5959 }
5960 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5961 CHECK(owner->result_ok);
5962         return *owner->contents.result;
5963 }
5964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5965         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5966         CResult_NoneAPIErrorZ_get_ok(owner_conv);
5967 }
5968
5969 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5970 CHECK(!owner->result_ok);
5971         return APIError_clone(&*owner->contents.err);
5972 }
5973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5974         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5975         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5976         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
5977         int64_t ret_ref = (uintptr_t)ret_copy;
5978         return ret_ref;
5979 }
5980
5981 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
5982         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
5983         for (size_t i = 0; i < ret.datalen; i++) {
5984                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
5985         }
5986         return ret;
5987 }
5988 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
5989         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
5990         for (size_t i = 0; i < ret.datalen; i++) {
5991                 ret.data[i] = APIError_clone(&orig->data[i]);
5992         }
5993         return ret;
5994 }
5995 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
5996 CHECK(owner->result_ok);
5997         return ThirtyTwoBytes_clone(&*owner->contents.result);
5998 }
5999 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6000         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
6001         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6002         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
6003         return ret_arr;
6004 }
6005
6006 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6007 CHECK(!owner->result_ok);
6008         return APIError_clone(&*owner->contents.err);
6009 }
6010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6011         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
6012         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6013         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
6014         int64_t ret_ref = (uintptr_t)ret_copy;
6015         return ret_ref;
6016 }
6017
6018 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
6019 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
6020 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
6021 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
6022 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
6023 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
6024 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
6025 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
6026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
6027         LDKPaymentSendFailure_ParameterError_class =
6028                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
6029         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
6030         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
6031         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
6032         LDKPaymentSendFailure_PathParameterError_class =
6033                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
6034         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
6035         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
6036         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
6037         LDKPaymentSendFailure_AllFailedRetrySafe_class =
6038                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
6039         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
6040         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
6041         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
6042         LDKPaymentSendFailure_PartialFailure_class =
6043                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
6044         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
6045         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
6046         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
6047 }
6048 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6049         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
6050         switch(obj->tag) {
6051                 case LDKPaymentSendFailure_ParameterError: {
6052                         int64_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
6053                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
6054                 }
6055                 case LDKPaymentSendFailure_PathParameterError: {
6056                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
6057                         int64_tArray path_parameter_error_arr = NULL;
6058                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
6059                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
6060                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
6061                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6062                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
6063                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
6064                                 path_parameter_error_arr_ptr[w] = (int64_t)path_parameter_error_conv_22_conv;
6065                         }
6066                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
6067                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
6068                 }
6069                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
6070                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
6071                         int64_tArray all_failed_retry_safe_arr = NULL;
6072                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
6073                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
6074                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
6075                                 int64_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
6076                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
6077                         }
6078                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
6079                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
6080                 }
6081                 case LDKPaymentSendFailure_PartialFailure: {
6082                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
6083                         int64_tArray results_arr = NULL;
6084                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
6085                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
6086                         for (size_t w = 0; w < results_var.datalen; w++) {
6087                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6088                                 *results_conv_22_conv = results_var.data[w];
6089                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
6090                                 results_arr_ptr[w] = (int64_t)results_conv_22_conv;
6091                         }
6092                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
6093                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
6094                         int64_t failed_paths_retry_ref = 0;
6095                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
6096                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6097                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6098                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
6099                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
6100                         }
6101                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
6102                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
6103                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
6104                 }
6105                 default: abort();
6106         }
6107 }
6108 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6109 CHECK(owner->result_ok);
6110         return ThirtyTwoBytes_clone(&*owner->contents.result);
6111 }
6112 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6113         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
6114         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6115         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data);
6116         return ret_arr;
6117 }
6118
6119 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6120 CHECK(!owner->result_ok);
6121         return PaymentSendFailure_clone(&*owner->contents.err);
6122 }
6123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6124         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
6125         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6126         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
6127         int64_t ret_ref = (uintptr_t)ret_copy;
6128         return ret_ref;
6129 }
6130
6131 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6132 CHECK(owner->result_ok);
6133         return *owner->contents.result;
6134 }
6135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6136         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
6137         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
6138 }
6139
6140 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6141 CHECK(!owner->result_ok);
6142         return PaymentSendFailure_clone(&*owner->contents.err);
6143 }
6144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6145         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
6146         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6147         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
6148         int64_t ret_ref = (uintptr_t)ret_copy;
6149         return ret_ref;
6150 }
6151
6152 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6153         return ThirtyTwoBytes_clone(&owner->a);
6154 }
6155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6156         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
6157         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6158         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
6159         return ret_arr;
6160 }
6161
6162 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6163         return ThirtyTwoBytes_clone(&owner->b);
6164 }
6165 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6166         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
6167         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6168         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
6169         return ret_arr;
6170 }
6171
6172 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6173 CHECK(owner->result_ok);
6174         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
6175 }
6176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6177         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
6178         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
6179         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
6180         return ((int64_t)ret_conv);
6181 }
6182
6183 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6184 CHECK(!owner->result_ok);
6185         return PaymentSendFailure_clone(&*owner->contents.err);
6186 }
6187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6188         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
6189         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6190         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
6191         int64_t ret_ref = (uintptr_t)ret_copy;
6192         return ret_ref;
6193 }
6194
6195 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
6196         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
6197         for (size_t i = 0; i < ret.datalen; i++) {
6198                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
6199         }
6200         return ret;
6201 }
6202 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6203         return ThirtyTwoBytes_clone(&owner->a);
6204 }
6205 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6206         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
6207         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6208         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
6209         return ret_arr;
6210 }
6211
6212 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6213         return ThirtyTwoBytes_clone(&owner->b);
6214 }
6215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6216         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
6217         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6218         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
6219         return ret_arr;
6220 }
6221
6222 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6223 CHECK(owner->result_ok);
6224         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6225 }
6226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6227         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
6228         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6229         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
6230         return ((int64_t)ret_conv);
6231 }
6232
6233 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6234 CHECK(!owner->result_ok);
6235         return *owner->contents.err;
6236 }
6237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6238         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
6239         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
6240 }
6241
6242 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6243 CHECK(owner->result_ok);
6244         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6245 }
6246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6247         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
6248         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6249         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
6250         return ((int64_t)ret_conv);
6251 }
6252
6253 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6254 CHECK(!owner->result_ok);
6255         return APIError_clone(&*owner->contents.err);
6256 }
6257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6258         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
6259         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6260         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
6261         int64_t ret_ref = (uintptr_t)ret_copy;
6262         return ret_ref;
6263 }
6264
6265 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6266 CHECK(owner->result_ok);
6267         return ThirtyTwoBytes_clone(&*owner->contents.result);
6268 }
6269 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6270         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
6271         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6272         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
6273         return ret_arr;
6274 }
6275
6276 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6277 CHECK(!owner->result_ok);
6278         return *owner->contents.err;
6279 }
6280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6281         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
6282         CResult_PaymentSecretNoneZ_get_err(owner_conv);
6283 }
6284
6285 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6286 CHECK(owner->result_ok);
6287         return ThirtyTwoBytes_clone(&*owner->contents.result);
6288 }
6289 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6290         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
6291         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6292         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
6293         return ret_arr;
6294 }
6295
6296 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6297 CHECK(!owner->result_ok);
6298         return APIError_clone(&*owner->contents.err);
6299 }
6300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6301         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
6302         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6303         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
6304         int64_t ret_ref = (uintptr_t)ret_copy;
6305         return ret_ref;
6306 }
6307
6308 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6309 CHECK(owner->result_ok);
6310         return ThirtyTwoBytes_clone(&*owner->contents.result);
6311 }
6312 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6313         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6314         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6315         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
6316         return ret_arr;
6317 }
6318
6319 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6320 CHECK(!owner->result_ok);
6321         return APIError_clone(&*owner->contents.err);
6322 }
6323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6324         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6325         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6326         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
6327         int64_t ret_ref = (uintptr_t)ret_copy;
6328         return ret_ref;
6329 }
6330
6331 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6332 CHECK(owner->result_ok);
6333         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
6334 }
6335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6336         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
6337         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
6338         int64_t ret_ref = 0;
6339         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6340         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6342         ret_ref = (uintptr_t)ret_var.inner;
6343         if (ret_var.is_owned) {
6344                 ret_ref |= 1;
6345         }
6346         return ret_ref;
6347 }
6348
6349 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6350 CHECK(!owner->result_ok);
6351         return DecodeError_clone(&*owner->contents.err);
6352 }
6353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6354         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
6355         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
6356         int64_t ret_ref = 0;
6357         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6358         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6360         ret_ref = (uintptr_t)ret_var.inner;
6361         if (ret_var.is_owned) {
6362                 ret_ref |= 1;
6363         }
6364         return ret_ref;
6365 }
6366
6367 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6368 CHECK(owner->result_ok);
6369         return ChannelCounterparty_clone(&*owner->contents.result);
6370 }
6371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6372         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
6373         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
6374         int64_t ret_ref = 0;
6375         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6376         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6378         ret_ref = (uintptr_t)ret_var.inner;
6379         if (ret_var.is_owned) {
6380                 ret_ref |= 1;
6381         }
6382         return ret_ref;
6383 }
6384
6385 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6386 CHECK(!owner->result_ok);
6387         return DecodeError_clone(&*owner->contents.err);
6388 }
6389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6390         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
6391         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
6392         int64_t ret_ref = 0;
6393         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6394         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6396         ret_ref = (uintptr_t)ret_var.inner;
6397         if (ret_var.is_owned) {
6398                 ret_ref |= 1;
6399         }
6400         return ret_ref;
6401 }
6402
6403 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6404 CHECK(owner->result_ok);
6405         return ChannelDetails_clone(&*owner->contents.result);
6406 }
6407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6408         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
6409         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
6410         int64_t ret_ref = 0;
6411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6414         ret_ref = (uintptr_t)ret_var.inner;
6415         if (ret_var.is_owned) {
6416                 ret_ref |= 1;
6417         }
6418         return ret_ref;
6419 }
6420
6421 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6422 CHECK(!owner->result_ok);
6423         return DecodeError_clone(&*owner->contents.err);
6424 }
6425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6426         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
6427         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
6428         int64_t ret_ref = 0;
6429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6432         ret_ref = (uintptr_t)ret_var.inner;
6433         if (ret_var.is_owned) {
6434                 ret_ref |= 1;
6435         }
6436         return ret_ref;
6437 }
6438
6439 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6440 CHECK(owner->result_ok);
6441         return PhantomRouteHints_clone(&*owner->contents.result);
6442 }
6443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6444         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
6445         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
6446         int64_t ret_ref = 0;
6447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6450         ret_ref = (uintptr_t)ret_var.inner;
6451         if (ret_var.is_owned) {
6452                 ret_ref |= 1;
6453         }
6454         return ret_ref;
6455 }
6456
6457 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6458 CHECK(!owner->result_ok);
6459         return DecodeError_clone(&*owner->contents.err);
6460 }
6461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6462         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
6463         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
6464         int64_t ret_ref = 0;
6465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6468         ret_ref = (uintptr_t)ret_var.inner;
6469         if (ret_var.is_owned) {
6470                 ret_ref |= 1;
6471         }
6472         return ret_ref;
6473 }
6474
6475 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
6476         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
6477         for (size_t i = 0; i < ret.datalen; i++) {
6478                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
6479         }
6480         return ret;
6481 }
6482 typedef struct LDKWatch_JCalls {
6483         atomic_size_t refcnt;
6484         JavaVM *vm;
6485         jweak o;
6486         jmethodID watch_channel_meth;
6487         jmethodID update_channel_meth;
6488         jmethodID release_pending_monitor_events_meth;
6489 } LDKWatch_JCalls;
6490 static void LDKWatch_JCalls_free(void* this_arg) {
6491         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6492         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6493                 JNIEnv *env;
6494                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6495                 if (get_jenv_res == JNI_EDETACHED) {
6496                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6497                 } else {
6498                         DO_ASSERT(get_jenv_res == JNI_OK);
6499                 }
6500                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6501                 if (get_jenv_res == JNI_EDETACHED) {
6502                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6503                 }
6504                 FREE(j_calls);
6505         }
6506 }
6507 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
6508         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6509         JNIEnv *env;
6510         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6511         if (get_jenv_res == JNI_EDETACHED) {
6512                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6513         } else {
6514                 DO_ASSERT(get_jenv_res == JNI_OK);
6515         }
6516         LDKOutPoint funding_txo_var = funding_txo;
6517         int64_t funding_txo_ref = 0;
6518         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6519         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6520         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6521         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
6522         if (funding_txo_var.is_owned) {
6523                 funding_txo_ref |= 1;
6524         }
6525         LDKChannelMonitor monitor_var = monitor;
6526         int64_t monitor_ref = 0;
6527         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6528         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6529         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
6530         monitor_ref = (uintptr_t)monitor_var.inner;
6531         if (monitor_var.is_owned) {
6532                 monitor_ref |= 1;
6533         }
6534         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6535         CHECK(obj != NULL);
6536         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
6537         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6538                 (*env)->ExceptionDescribe(env);
6539                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
6540         }
6541         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6542         CHECK_ACCESS(ret_ptr);
6543         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6544         FREE((void*)ret);
6545         if (get_jenv_res == JNI_EDETACHED) {
6546                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6547         }
6548         return ret_conv;
6549 }
6550 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
6551         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6552         JNIEnv *env;
6553         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6554         if (get_jenv_res == JNI_EDETACHED) {
6555                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6556         } else {
6557                 DO_ASSERT(get_jenv_res == JNI_OK);
6558         }
6559         LDKOutPoint funding_txo_var = funding_txo;
6560         int64_t funding_txo_ref = 0;
6561         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6562         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6563         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6564         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
6565         if (funding_txo_var.is_owned) {
6566                 funding_txo_ref |= 1;
6567         }
6568         LDKChannelMonitorUpdate update_var = update;
6569         int64_t update_ref = 0;
6570         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6571         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6572         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
6573         update_ref = (uintptr_t)update_var.inner;
6574         if (update_var.is_owned) {
6575                 update_ref |= 1;
6576         }
6577         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6578         CHECK(obj != NULL);
6579         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
6580         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6581                 (*env)->ExceptionDescribe(env);
6582                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
6583         }
6584         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6585         CHECK_ACCESS(ret_ptr);
6586         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6587         FREE((void*)ret);
6588         if (get_jenv_res == JNI_EDETACHED) {
6589                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6590         }
6591         return ret_conv;
6592 }
6593 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
6594         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6595         JNIEnv *env;
6596         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6597         if (get_jenv_res == JNI_EDETACHED) {
6598                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6599         } else {
6600                 DO_ASSERT(get_jenv_res == JNI_OK);
6601         }
6602         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6603         CHECK(obj != NULL);
6604         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
6605         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6606                 (*env)->ExceptionDescribe(env);
6607                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
6608         }
6609         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
6610         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6611         if (ret_constr.datalen > 0)
6612                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
6613         else
6614                 ret_constr.data = NULL;
6615         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6616         for (size_t x = 0; x < ret_constr.datalen; x++) {
6617                 int64_t ret_conv_49 = ret_vals[x];
6618                 void* ret_conv_49_ptr = (void*)(((uintptr_t)ret_conv_49) & ~1);
6619                 CHECK_ACCESS(ret_conv_49_ptr);
6620                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
6621                 FREE((void*)ret_conv_49);
6622                 ret_constr.data[x] = ret_conv_49_conv;
6623         }
6624         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6625         if (get_jenv_res == JNI_EDETACHED) {
6626                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6627         }
6628         return ret_constr;
6629 }
6630 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
6631         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
6632         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6633 }
6634 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
6635         jclass c = (*env)->GetObjectClass(env, o);
6636         CHECK(c != NULL);
6637         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
6638         atomic_init(&calls->refcnt, 1);
6639         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6640         calls->o = (*env)->NewWeakGlobalRef(env, o);
6641         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
6642         CHECK(calls->watch_channel_meth != NULL);
6643         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
6644         CHECK(calls->update_channel_meth != NULL);
6645         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
6646         CHECK(calls->release_pending_monitor_events_meth != NULL);
6647
6648         LDKWatch ret = {
6649                 .this_arg = (void*) calls,
6650                 .watch_channel = watch_channel_LDKWatch_jcall,
6651                 .update_channel = update_channel_LDKWatch_jcall,
6652                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
6653                 .free = LDKWatch_JCalls_free,
6654         };
6655         return ret;
6656 }
6657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
6658         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
6659         *res_ptr = LDKWatch_init(env, clz, o);
6660         return (uint64_t)res_ptr;
6661 }
6662 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) {
6663         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6664         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6665         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6666         LDKOutPoint funding_txo_conv;
6667         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6668         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6669         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6670         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6671         LDKChannelMonitor monitor_conv;
6672         monitor_conv.inner = (void*)(monitor & (~1));
6673         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
6674         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
6675         monitor_conv = ChannelMonitor_clone(&monitor_conv);
6676         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6677         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
6678         return (int64_t)ret_conv;
6679 }
6680
6681 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) {
6682         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6683         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6684         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6685         LDKOutPoint funding_txo_conv;
6686         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6687         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6688         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6689         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6690         LDKChannelMonitorUpdate update_conv;
6691         update_conv.inner = (void*)(update & (~1));
6692         update_conv.is_owned = (update & 1) || (update == 0);
6693         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
6694         update_conv = ChannelMonitorUpdate_clone(&update_conv);
6695         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6696         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
6697         return (int64_t)ret_conv;
6698 }
6699
6700 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6701         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6702         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6703         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6704         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
6705         int64_tArray ret_arr = NULL;
6706         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6707         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6708         for (size_t x = 0; x < ret_var.datalen; x++) {
6709                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
6710                 *ret_conv_49_conv = ret_var.data[x];
6711                 ret_arr_ptr[x] = ((int64_t)ret_conv_49_conv);
6712         }
6713         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6714         FREE(ret_var.data);
6715         return ret_arr;
6716 }
6717
6718 typedef struct LDKBroadcasterInterface_JCalls {
6719         atomic_size_t refcnt;
6720         JavaVM *vm;
6721         jweak o;
6722         jmethodID broadcast_transaction_meth;
6723 } LDKBroadcasterInterface_JCalls;
6724 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
6725         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6726         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6727                 JNIEnv *env;
6728                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6729                 if (get_jenv_res == JNI_EDETACHED) {
6730                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6731                 } else {
6732                         DO_ASSERT(get_jenv_res == JNI_OK);
6733                 }
6734                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6735                 if (get_jenv_res == JNI_EDETACHED) {
6736                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6737                 }
6738                 FREE(j_calls);
6739         }
6740 }
6741 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
6742         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6743         JNIEnv *env;
6744         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6745         if (get_jenv_res == JNI_EDETACHED) {
6746                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6747         } else {
6748                 DO_ASSERT(get_jenv_res == JNI_OK);
6749         }
6750         LDKTransaction tx_var = tx;
6751         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
6752         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
6753         Transaction_free(tx_var);
6754         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6755         CHECK(obj != NULL);
6756         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
6757         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6758                 (*env)->ExceptionDescribe(env);
6759                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
6760         }
6761         if (get_jenv_res == JNI_EDETACHED) {
6762                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6763         }
6764 }
6765 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
6766         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
6767         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6768 }
6769 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
6770         jclass c = (*env)->GetObjectClass(env, o);
6771         CHECK(c != NULL);
6772         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
6773         atomic_init(&calls->refcnt, 1);
6774         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6775         calls->o = (*env)->NewWeakGlobalRef(env, o);
6776         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
6777         CHECK(calls->broadcast_transaction_meth != NULL);
6778
6779         LDKBroadcasterInterface ret = {
6780                 .this_arg = (void*) calls,
6781                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
6782                 .free = LDKBroadcasterInterface_JCalls_free,
6783         };
6784         return ret;
6785 }
6786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
6787         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
6788         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
6789         return (uint64_t)res_ptr;
6790 }
6791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
6792         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6793         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6794         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
6795         LDKTransaction tx_ref;
6796         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
6797         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
6798         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
6799         tx_ref.data_is_owned = true;
6800         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
6801 }
6802
6803 typedef struct LDKKeysInterface_JCalls {
6804         atomic_size_t refcnt;
6805         JavaVM *vm;
6806         jweak o;
6807         jmethodID get_node_secret_meth;
6808         jmethodID get_destination_script_meth;
6809         jmethodID get_shutdown_scriptpubkey_meth;
6810         jmethodID get_channel_signer_meth;
6811         jmethodID get_secure_random_bytes_meth;
6812         jmethodID read_chan_signer_meth;
6813         jmethodID sign_invoice_meth;
6814         jmethodID get_inbound_payment_key_material_meth;
6815 } LDKKeysInterface_JCalls;
6816 static void LDKKeysInterface_JCalls_free(void* this_arg) {
6817         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6818         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6819                 JNIEnv *env;
6820                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6821                 if (get_jenv_res == JNI_EDETACHED) {
6822                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6823                 } else {
6824                         DO_ASSERT(get_jenv_res == JNI_OK);
6825                 }
6826                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6827                 if (get_jenv_res == JNI_EDETACHED) {
6828                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6829                 }
6830                 FREE(j_calls);
6831         }
6832 }
6833 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
6834         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6835         JNIEnv *env;
6836         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6837         if (get_jenv_res == JNI_EDETACHED) {
6838                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6839         } else {
6840                 DO_ASSERT(get_jenv_res == JNI_OK);
6841         }
6842         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
6843         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6844         CHECK(obj != NULL);
6845         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
6846         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6847                 (*env)->ExceptionDescribe(env);
6848                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
6849         }
6850         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6851         CHECK_ACCESS(ret_ptr);
6852         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
6853         FREE((void*)ret);
6854         if (get_jenv_res == JNI_EDETACHED) {
6855                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6856         }
6857         return ret_conv;
6858 }
6859 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
6860         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6861         JNIEnv *env;
6862         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6863         if (get_jenv_res == JNI_EDETACHED) {
6864                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6865         } else {
6866                 DO_ASSERT(get_jenv_res == JNI_OK);
6867         }
6868         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6869         CHECK(obj != NULL);
6870         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
6871         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6872                 (*env)->ExceptionDescribe(env);
6873                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
6874         }
6875         LDKCVec_u8Z ret_ref;
6876         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6877         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6878         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6879         if (get_jenv_res == JNI_EDETACHED) {
6880                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6881         }
6882         return ret_ref;
6883 }
6884 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
6885         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6886         JNIEnv *env;
6887         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6888         if (get_jenv_res == JNI_EDETACHED) {
6889                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6890         } else {
6891                 DO_ASSERT(get_jenv_res == JNI_OK);
6892         }
6893         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6894         CHECK(obj != NULL);
6895         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
6896         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6897                 (*env)->ExceptionDescribe(env);
6898                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
6899         }
6900         LDKShutdownScript ret_conv;
6901         ret_conv.inner = (void*)(ret & (~1));
6902         ret_conv.is_owned = (ret & 1) || (ret == 0);
6903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
6904         if (get_jenv_res == JNI_EDETACHED) {
6905                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6906         }
6907         return ret_conv;
6908 }
6909 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
6910         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6911         JNIEnv *env;
6912         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6913         if (get_jenv_res == JNI_EDETACHED) {
6914                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6915         } else {
6916                 DO_ASSERT(get_jenv_res == JNI_OK);
6917         }
6918         jboolean inbound_conv = inbound;
6919         int64_t channel_value_satoshis_conv = channel_value_satoshis;
6920         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6921         CHECK(obj != NULL);
6922         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound_conv, channel_value_satoshis_conv);
6923         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6924                 (*env)->ExceptionDescribe(env);
6925                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
6926         }
6927         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6928         CHECK_ACCESS(ret_ptr);
6929         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
6930         FREE((void*)ret);
6931         if (get_jenv_res == JNI_EDETACHED) {
6932                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6933         }
6934         return ret_conv;
6935 }
6936 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
6937         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6938         JNIEnv *env;
6939         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6940         if (get_jenv_res == JNI_EDETACHED) {
6941                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6942         } else {
6943                 DO_ASSERT(get_jenv_res == JNI_OK);
6944         }
6945         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6946         CHECK(obj != NULL);
6947         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
6948         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6949                 (*env)->ExceptionDescribe(env);
6950                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
6951         }
6952         LDKThirtyTwoBytes ret_ref;
6953         CHECK((*env)->GetArrayLength(env, ret) == 32);
6954         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
6955         if (get_jenv_res == JNI_EDETACHED) {
6956                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6957         }
6958         return ret_ref;
6959 }
6960 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
6961         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6962         JNIEnv *env;
6963         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6964         if (get_jenv_res == JNI_EDETACHED) {
6965                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6966         } else {
6967                 DO_ASSERT(get_jenv_res == JNI_OK);
6968         }
6969         LDKu8slice reader_var = reader;
6970         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
6971         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
6972         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6973         CHECK(obj != NULL);
6974         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
6975         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6976                 (*env)->ExceptionDescribe(env);
6977                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
6978         }
6979         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6980         CHECK_ACCESS(ret_ptr);
6981         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
6982         FREE((void*)ret);
6983         if (get_jenv_res == JNI_EDETACHED) {
6984                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6985         }
6986         return ret_conv;
6987 }
6988 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
6989         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6990         JNIEnv *env;
6991         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6992         if (get_jenv_res == JNI_EDETACHED) {
6993                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6994         } else {
6995                 DO_ASSERT(get_jenv_res == JNI_OK);
6996         }
6997         LDKu8slice hrp_bytes_var = hrp_bytes;
6998         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
6999         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
7000         LDKCVec_u5Z invoice_data_var = invoice_data;
7001         jobjectArray invoice_data_arr = NULL;
7002         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
7003         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
7004         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
7005                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
7006                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
7007         }
7008         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
7009         FREE(invoice_data_var.data);
7010         jclass receipient_conv = LDKRecipient_to_java(env, receipient);
7011         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7012         CHECK(obj != NULL);
7013         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
7014         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7015                 (*env)->ExceptionDescribe(env);
7016                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
7017         }
7018         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
7019         CHECK_ACCESS(ret_ptr);
7020         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
7021         FREE((void*)ret);
7022         if (get_jenv_res == JNI_EDETACHED) {
7023                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7024         }
7025         return ret_conv;
7026 }
7027 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
7028         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7029         JNIEnv *env;
7030         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7031         if (get_jenv_res == JNI_EDETACHED) {
7032                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7033         } else {
7034                 DO_ASSERT(get_jenv_res == JNI_OK);
7035         }
7036         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7037         CHECK(obj != NULL);
7038         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
7039         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7040                 (*env)->ExceptionDescribe(env);
7041                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
7042         }
7043         LDKThirtyTwoBytes ret_ref;
7044         CHECK((*env)->GetArrayLength(env, ret) == 32);
7045         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7046         if (get_jenv_res == JNI_EDETACHED) {
7047                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7048         }
7049         return ret_ref;
7050 }
7051 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
7052         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
7053         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7054 }
7055 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
7056         jclass c = (*env)->GetObjectClass(env, o);
7057         CHECK(c != NULL);
7058         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
7059         atomic_init(&calls->refcnt, 1);
7060         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7061         calls->o = (*env)->NewWeakGlobalRef(env, o);
7062         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
7063         CHECK(calls->get_node_secret_meth != NULL);
7064         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
7065         CHECK(calls->get_destination_script_meth != NULL);
7066         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
7067         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
7068         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
7069         CHECK(calls->get_channel_signer_meth != NULL);
7070         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
7071         CHECK(calls->get_secure_random_bytes_meth != NULL);
7072         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
7073         CHECK(calls->read_chan_signer_meth != NULL);
7074         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
7075         CHECK(calls->sign_invoice_meth != NULL);
7076         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
7077         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
7078
7079         LDKKeysInterface ret = {
7080                 .this_arg = (void*) calls,
7081                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
7082                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
7083                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
7084                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
7085                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
7086                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
7087                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
7088                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
7089                 .free = LDKKeysInterface_JCalls_free,
7090         };
7091         return ret;
7092 }
7093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
7094         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
7095         *res_ptr = LDKKeysInterface_init(env, clz, o);
7096         return (uint64_t)res_ptr;
7097 }
7098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
7099         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7100         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7101         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7102         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7103         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
7104         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
7105         return (int64_t)ret_conv;
7106 }
7107
7108 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
7109         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7110         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7111         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7112         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
7113         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7114         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7115         CVec_u8Z_free(ret_var);
7116         return ret_arr;
7117 }
7118
7119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
7120         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7121         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7122         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7123         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
7124         int64_t ret_ref = 0;
7125         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7126         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7127         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7128         ret_ref = (uintptr_t)ret_var.inner;
7129         if (ret_var.is_owned) {
7130                 ret_ref |= 1;
7131         }
7132         return ret_ref;
7133 }
7134
7135 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) {
7136         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7137         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7138         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7139         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
7140         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
7141         return (int64_t)ret_ret;
7142 }
7143
7144 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
7145         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7146         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7147         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7148         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7149         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
7150         return ret_arr;
7151 }
7152
7153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
7154         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7155         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7156         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7157         LDKu8slice reader_ref;
7158         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
7159         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
7160         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7161         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
7162         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
7163         return (int64_t)ret_conv;
7164 }
7165
7166 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) {
7167         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7168         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7169         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7170         LDKu8slice hrp_bytes_ref;
7171         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
7172         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
7173         LDKCVec_u5Z invoice_data_constr;
7174         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
7175         if (invoice_data_constr.datalen > 0)
7176                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
7177         else
7178                 invoice_data_constr.data = NULL;
7179         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
7180         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
7181                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
7182                 
7183                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
7184         }
7185         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
7186         LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
7187         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7188         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
7189         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
7190         return (int64_t)ret_conv;
7191 }
7192
7193 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
7194         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7195         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7196         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7197         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7198         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
7199         return ret_arr;
7200 }
7201
7202 typedef struct LDKFeeEstimator_JCalls {
7203         atomic_size_t refcnt;
7204         JavaVM *vm;
7205         jweak o;
7206         jmethodID get_est_sat_per_1000_weight_meth;
7207 } LDKFeeEstimator_JCalls;
7208 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
7209         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7210         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7211                 JNIEnv *env;
7212                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7213                 if (get_jenv_res == JNI_EDETACHED) {
7214                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7215                 } else {
7216                         DO_ASSERT(get_jenv_res == JNI_OK);
7217                 }
7218                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7219                 if (get_jenv_res == JNI_EDETACHED) {
7220                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7221                 }
7222                 FREE(j_calls);
7223         }
7224 }
7225 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
7226         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7227         JNIEnv *env;
7228         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7229         if (get_jenv_res == JNI_EDETACHED) {
7230                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7231         } else {
7232                 DO_ASSERT(get_jenv_res == JNI_OK);
7233         }
7234         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
7235         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7236         CHECK(obj != NULL);
7237         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
7238         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7239                 (*env)->ExceptionDescribe(env);
7240                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
7241         }
7242         if (get_jenv_res == JNI_EDETACHED) {
7243                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7244         }
7245         return ret;
7246 }
7247 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
7248         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
7249         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7250 }
7251 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
7252         jclass c = (*env)->GetObjectClass(env, o);
7253         CHECK(c != NULL);
7254         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
7255         atomic_init(&calls->refcnt, 1);
7256         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7257         calls->o = (*env)->NewWeakGlobalRef(env, o);
7258         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
7259         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
7260
7261         LDKFeeEstimator ret = {
7262                 .this_arg = (void*) calls,
7263                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
7264                 .free = LDKFeeEstimator_JCalls_free,
7265         };
7266         return ret;
7267 }
7268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
7269         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
7270         *res_ptr = LDKFeeEstimator_init(env, clz, o);
7271         return (uint64_t)res_ptr;
7272 }
7273 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) {
7274         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7275         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7276         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
7277         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
7278         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
7279         return ret_conv;
7280 }
7281
7282 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7283         return ThirtyTwoBytes_clone(&owner->a);
7284 }
7285 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7286         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
7287         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7288         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
7289         return ret_arr;
7290 }
7291
7292 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7293         return &owner->b;
7294 }
7295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7296         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
7297         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
7298         int64_t ret_ref = 0;
7299         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7300         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7302         ret_ref = (uintptr_t)ret_var.inner & ~1;
7303         return ret_ref;
7304 }
7305
7306 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7307 CHECK(owner->result_ok);
7308         return &*owner->contents.result;
7309 }
7310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7311         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
7312         int64_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
7313         return ret_ret;
7314 }
7315
7316 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7317 CHECK(!owner->result_ok);
7318         return DecodeError_clone(&*owner->contents.err);
7319 }
7320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7321         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
7322         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
7323         int64_t ret_ref = 0;
7324         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7325         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7327         ret_ref = (uintptr_t)ret_var.inner;
7328         if (ret_var.is_owned) {
7329                 ret_ref |= 1;
7330         }
7331         return ret_ref;
7332 }
7333
7334 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7335 CHECK(owner->result_ok);
7336         return ChannelConfig_clone(&*owner->contents.result);
7337 }
7338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7339         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
7340         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
7341         int64_t ret_ref = 0;
7342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7345         ret_ref = (uintptr_t)ret_var.inner;
7346         if (ret_var.is_owned) {
7347                 ret_ref |= 1;
7348         }
7349         return ret_ref;
7350 }
7351
7352 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7353 CHECK(!owner->result_ok);
7354         return DecodeError_clone(&*owner->contents.err);
7355 }
7356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7357         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
7358         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
7359         int64_t ret_ref = 0;
7360         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7361         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7363         ret_ref = (uintptr_t)ret_var.inner;
7364         if (ret_var.is_owned) {
7365                 ret_ref |= 1;
7366         }
7367         return ret_ref;
7368 }
7369
7370 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7371 CHECK(owner->result_ok);
7372         return OutPoint_clone(&*owner->contents.result);
7373 }
7374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7375         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
7376         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
7377         int64_t ret_ref = 0;
7378         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7379         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7381         ret_ref = (uintptr_t)ret_var.inner;
7382         if (ret_var.is_owned) {
7383                 ret_ref |= 1;
7384         }
7385         return ret_ref;
7386 }
7387
7388 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7389 CHECK(!owner->result_ok);
7390         return DecodeError_clone(&*owner->contents.err);
7391 }
7392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7393         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
7394         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
7395         int64_t ret_ref = 0;
7396         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7397         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7398         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7399         ret_ref = (uintptr_t)ret_var.inner;
7400         if (ret_var.is_owned) {
7401                 ret_ref |= 1;
7402         }
7403         return ret_ref;
7404 }
7405
7406 typedef struct LDKType_JCalls {
7407         atomic_size_t refcnt;
7408         JavaVM *vm;
7409         jweak o;
7410         jmethodID type_id_meth;
7411         jmethodID debug_str_meth;
7412         jmethodID write_meth;
7413 } LDKType_JCalls;
7414 static void LDKType_JCalls_free(void* this_arg) {
7415         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7416         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7417                 JNIEnv *env;
7418                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7419                 if (get_jenv_res == JNI_EDETACHED) {
7420                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7421                 } else {
7422                         DO_ASSERT(get_jenv_res == JNI_OK);
7423                 }
7424                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7425                 if (get_jenv_res == JNI_EDETACHED) {
7426                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7427                 }
7428                 FREE(j_calls);
7429         }
7430 }
7431 uint16_t type_id_LDKType_jcall(const void* this_arg) {
7432         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7433         JNIEnv *env;
7434         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7435         if (get_jenv_res == JNI_EDETACHED) {
7436                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7437         } else {
7438                 DO_ASSERT(get_jenv_res == JNI_OK);
7439         }
7440         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7441         CHECK(obj != NULL);
7442         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
7443         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7444                 (*env)->ExceptionDescribe(env);
7445                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
7446         }
7447         if (get_jenv_res == JNI_EDETACHED) {
7448                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7449         }
7450         return ret;
7451 }
7452 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
7453         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7454         JNIEnv *env;
7455         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7456         if (get_jenv_res == JNI_EDETACHED) {
7457                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7458         } else {
7459                 DO_ASSERT(get_jenv_res == JNI_OK);
7460         }
7461         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7462         CHECK(obj != NULL);
7463         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
7464         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7465                 (*env)->ExceptionDescribe(env);
7466                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
7467         }
7468         LDKStr ret_conv = java_to_owned_str(env, ret);
7469         if (get_jenv_res == JNI_EDETACHED) {
7470                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7471         }
7472         return ret_conv;
7473 }
7474 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
7475         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7476         JNIEnv *env;
7477         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7478         if (get_jenv_res == JNI_EDETACHED) {
7479                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7480         } else {
7481                 DO_ASSERT(get_jenv_res == JNI_OK);
7482         }
7483         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7484         CHECK(obj != NULL);
7485         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
7486         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7487                 (*env)->ExceptionDescribe(env);
7488                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
7489         }
7490         LDKCVec_u8Z ret_ref;
7491         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
7492         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7493         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
7494         if (get_jenv_res == JNI_EDETACHED) {
7495                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7496         }
7497         return ret_ref;
7498 }
7499 static void LDKType_JCalls_cloned(LDKType* new_obj) {
7500         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
7501         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7502 }
7503 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
7504         jclass c = (*env)->GetObjectClass(env, o);
7505         CHECK(c != NULL);
7506         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
7507         atomic_init(&calls->refcnt, 1);
7508         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7509         calls->o = (*env)->NewWeakGlobalRef(env, o);
7510         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
7511         CHECK(calls->type_id_meth != NULL);
7512         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
7513         CHECK(calls->debug_str_meth != NULL);
7514         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
7515         CHECK(calls->write_meth != NULL);
7516
7517         LDKType ret = {
7518                 .this_arg = (void*) calls,
7519                 .type_id = type_id_LDKType_jcall,
7520                 .debug_str = debug_str_LDKType_jcall,
7521                 .write = write_LDKType_jcall,
7522                 .cloned = LDKType_JCalls_cloned,
7523                 .free = LDKType_JCalls_free,
7524         };
7525         return ret;
7526 }
7527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
7528         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
7529         *res_ptr = LDKType_init(env, clz, o);
7530         return (uint64_t)res_ptr;
7531 }
7532 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
7533         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7534         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7535         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7536         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
7537         return ret_conv;
7538 }
7539
7540 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
7541         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7542         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7543         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7544         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
7545         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
7546         Str_free(ret_str);
7547         return ret_conv;
7548 }
7549
7550 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
7551         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7552         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7553         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7554         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
7555         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7556         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7557         CVec_u8Z_free(ret_var);
7558         return ret_arr;
7559 }
7560
7561 static jclass LDKCOption_TypeZ_Some_class = NULL;
7562 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
7563 static jclass LDKCOption_TypeZ_None_class = NULL;
7564 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
7565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
7566         LDKCOption_TypeZ_Some_class =
7567                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
7568         CHECK(LDKCOption_TypeZ_Some_class != NULL);
7569         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
7570         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
7571         LDKCOption_TypeZ_None_class =
7572                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
7573         CHECK(LDKCOption_TypeZ_None_class != NULL);
7574         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
7575         CHECK(LDKCOption_TypeZ_None_meth != NULL);
7576 }
7577 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7578         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
7579         switch(obj->tag) {
7580                 case LDKCOption_TypeZ_Some: {
7581                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
7582                         *some_ret = Type_clone(&obj->some);
7583                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (int64_t)some_ret);
7584                 }
7585                 case LDKCOption_TypeZ_None: {
7586                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
7587                 }
7588                 default: abort();
7589         }
7590 }
7591 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7592 CHECK(owner->result_ok);
7593         return COption_TypeZ_clone(&*owner->contents.result);
7594 }
7595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7596         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
7597         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
7598         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
7599         int64_t ret_ref = (uintptr_t)ret_copy;
7600         return ret_ref;
7601 }
7602
7603 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7604 CHECK(!owner->result_ok);
7605         return DecodeError_clone(&*owner->contents.err);
7606 }
7607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7608         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
7609         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
7610         int64_t ret_ref = 0;
7611         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7612         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7614         ret_ref = (uintptr_t)ret_var.inner;
7615         if (ret_var.is_owned) {
7616                 ret_ref |= 1;
7617         }
7618         return ret_ref;
7619 }
7620
7621 static jclass LDKPaymentError_Invoice_class = NULL;
7622 static jmethodID LDKPaymentError_Invoice_meth = NULL;
7623 static jclass LDKPaymentError_Routing_class = NULL;
7624 static jmethodID LDKPaymentError_Routing_meth = NULL;
7625 static jclass LDKPaymentError_Sending_class = NULL;
7626 static jmethodID LDKPaymentError_Sending_meth = NULL;
7627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
7628         LDKPaymentError_Invoice_class =
7629                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
7630         CHECK(LDKPaymentError_Invoice_class != NULL);
7631         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
7632         CHECK(LDKPaymentError_Invoice_meth != NULL);
7633         LDKPaymentError_Routing_class =
7634                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
7635         CHECK(LDKPaymentError_Routing_class != NULL);
7636         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
7637         CHECK(LDKPaymentError_Routing_meth != NULL);
7638         LDKPaymentError_Sending_class =
7639                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
7640         CHECK(LDKPaymentError_Sending_class != NULL);
7641         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
7642         CHECK(LDKPaymentError_Sending_meth != NULL);
7643 }
7644 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7645         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
7646         switch(obj->tag) {
7647                 case LDKPaymentError_Invoice: {
7648                         LDKStr invoice_str = obj->invoice;
7649                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
7650                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
7651                 }
7652                 case LDKPaymentError_Routing: {
7653                         LDKLightningError routing_var = obj->routing;
7654                         int64_t routing_ref = 0;
7655                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7656                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7657                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
7658                         routing_ref = (uintptr_t)routing_var.inner & ~1;
7659                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
7660                 }
7661                 case LDKPaymentError_Sending: {
7662                         int64_t sending_ref = ((uintptr_t)&obj->sending) | 1;
7663                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
7664                 }
7665                 default: abort();
7666         }
7667 }
7668 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
7669 CHECK(owner->result_ok);
7670         return ThirtyTwoBytes_clone(&*owner->contents.result);
7671 }
7672 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7673         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
7674         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7675         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
7676         return ret_arr;
7677 }
7678
7679 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
7680 CHECK(!owner->result_ok);
7681         return PaymentError_clone(&*owner->contents.err);
7682 }
7683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7684         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
7685         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
7686         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
7687         int64_t ret_ref = (uintptr_t)ret_copy;
7688         return ret_ref;
7689 }
7690
7691 static jclass LDKParseError_Bech32Error_class = NULL;
7692 static jmethodID LDKParseError_Bech32Error_meth = NULL;
7693 static jclass LDKParseError_ParseAmountError_class = NULL;
7694 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
7695 static jclass LDKParseError_MalformedSignature_class = NULL;
7696 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
7697 static jclass LDKParseError_BadPrefix_class = NULL;
7698 static jmethodID LDKParseError_BadPrefix_meth = NULL;
7699 static jclass LDKParseError_UnknownCurrency_class = NULL;
7700 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
7701 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
7702 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
7703 static jclass LDKParseError_MalformedHRP_class = NULL;
7704 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
7705 static jclass LDKParseError_TooShortDataPart_class = NULL;
7706 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
7707 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
7708 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
7709 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
7710 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
7711 static jclass LDKParseError_PaddingError_class = NULL;
7712 static jmethodID LDKParseError_PaddingError_meth = NULL;
7713 static jclass LDKParseError_IntegerOverflowError_class = NULL;
7714 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
7715 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
7716 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
7717 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
7718 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
7719 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
7720 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
7721 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
7722 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
7723 static jclass LDKParseError_InvalidSliceLength_class = NULL;
7724 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
7725 static jclass LDKParseError_Skip_class = NULL;
7726 static jmethodID LDKParseError_Skip_meth = NULL;
7727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
7728         LDKParseError_Bech32Error_class =
7729                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
7730         CHECK(LDKParseError_Bech32Error_class != NULL);
7731         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
7732         CHECK(LDKParseError_Bech32Error_meth != NULL);
7733         LDKParseError_ParseAmountError_class =
7734                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
7735         CHECK(LDKParseError_ParseAmountError_class != NULL);
7736         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
7737         CHECK(LDKParseError_ParseAmountError_meth != NULL);
7738         LDKParseError_MalformedSignature_class =
7739                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
7740         CHECK(LDKParseError_MalformedSignature_class != NULL);
7741         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
7742         CHECK(LDKParseError_MalformedSignature_meth != NULL);
7743         LDKParseError_BadPrefix_class =
7744                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
7745         CHECK(LDKParseError_BadPrefix_class != NULL);
7746         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
7747         CHECK(LDKParseError_BadPrefix_meth != NULL);
7748         LDKParseError_UnknownCurrency_class =
7749                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
7750         CHECK(LDKParseError_UnknownCurrency_class != NULL);
7751         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
7752         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
7753         LDKParseError_UnknownSiPrefix_class =
7754                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
7755         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
7756         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
7757         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
7758         LDKParseError_MalformedHRP_class =
7759                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
7760         CHECK(LDKParseError_MalformedHRP_class != NULL);
7761         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
7762         CHECK(LDKParseError_MalformedHRP_meth != NULL);
7763         LDKParseError_TooShortDataPart_class =
7764                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
7765         CHECK(LDKParseError_TooShortDataPart_class != NULL);
7766         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
7767         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
7768         LDKParseError_UnexpectedEndOfTaggedFields_class =
7769                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
7770         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
7771         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
7772         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
7773         LDKParseError_DescriptionDecodeError_class =
7774                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
7775         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
7776         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
7777         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
7778         LDKParseError_PaddingError_class =
7779                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
7780         CHECK(LDKParseError_PaddingError_class != NULL);
7781         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
7782         CHECK(LDKParseError_PaddingError_meth != NULL);
7783         LDKParseError_IntegerOverflowError_class =
7784                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
7785         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
7786         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
7787         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
7788         LDKParseError_InvalidSegWitProgramLength_class =
7789                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
7790         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
7791         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
7792         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
7793         LDKParseError_InvalidPubKeyHashLength_class =
7794                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
7795         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
7796         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
7797         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
7798         LDKParseError_InvalidScriptHashLength_class =
7799                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
7800         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
7801         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
7802         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
7803         LDKParseError_InvalidRecoveryId_class =
7804                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
7805         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
7806         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
7807         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
7808         LDKParseError_InvalidSliceLength_class =
7809                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
7810         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
7811         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
7812         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
7813         LDKParseError_Skip_class =
7814                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
7815         CHECK(LDKParseError_Skip_class != NULL);
7816         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
7817         CHECK(LDKParseError_Skip_meth != NULL);
7818 }
7819 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7820         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
7821         switch(obj->tag) {
7822                 case LDKParseError_Bech32Error: {
7823                         int64_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
7824                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
7825                 }
7826                 case LDKParseError_ParseAmountError: {
7827                         /*obj->parse_amount_error*/
7828                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
7829                 }
7830                 case LDKParseError_MalformedSignature: {
7831                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
7832                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
7833                 }
7834                 case LDKParseError_BadPrefix: {
7835                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
7836                 }
7837                 case LDKParseError_UnknownCurrency: {
7838                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
7839                 }
7840                 case LDKParseError_UnknownSiPrefix: {
7841                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
7842                 }
7843                 case LDKParseError_MalformedHRP: {
7844                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
7845                 }
7846                 case LDKParseError_TooShortDataPart: {
7847                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
7848                 }
7849                 case LDKParseError_UnexpectedEndOfTaggedFields: {
7850                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
7851                 }
7852                 case LDKParseError_DescriptionDecodeError: {
7853                         /*obj->description_decode_error*/
7854                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
7855                 }
7856                 case LDKParseError_PaddingError: {
7857                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
7858                 }
7859                 case LDKParseError_IntegerOverflowError: {
7860                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
7861                 }
7862                 case LDKParseError_InvalidSegWitProgramLength: {
7863                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
7864                 }
7865                 case LDKParseError_InvalidPubKeyHashLength: {
7866                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
7867                 }
7868                 case LDKParseError_InvalidScriptHashLength: {
7869                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
7870                 }
7871                 case LDKParseError_InvalidRecoveryId: {
7872                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
7873                 }
7874                 case LDKParseError_InvalidSliceLength: {
7875                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
7876                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
7877                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
7878                 }
7879                 case LDKParseError_Skip: {
7880                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
7881                 }
7882                 default: abort();
7883         }
7884 }
7885 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
7886 CHECK(owner->result_ok);
7887         return SiPrefix_clone(&*owner->contents.result);
7888 }
7889 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7890         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
7891         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
7892         return ret_conv;
7893 }
7894
7895 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
7896 CHECK(!owner->result_ok);
7897         return ParseError_clone(&*owner->contents.err);
7898 }
7899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7900         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
7901         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7902         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
7903         int64_t ret_ref = (uintptr_t)ret_copy;
7904         return ret_ref;
7905 }
7906
7907 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
7908 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
7909 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
7910 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
7911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
7912         LDKParseOrSemanticError_ParseError_class =
7913                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
7914         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
7915         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
7916         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
7917         LDKParseOrSemanticError_SemanticError_class =
7918                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
7919         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
7920         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
7921         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
7922 }
7923 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7924         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
7925         switch(obj->tag) {
7926                 case LDKParseOrSemanticError_ParseError: {
7927                         int64_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
7928                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
7929                 }
7930                 case LDKParseOrSemanticError_SemanticError: {
7931                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
7932                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
7933                 }
7934                 default: abort();
7935         }
7936 }
7937 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7938 CHECK(owner->result_ok);
7939         return Invoice_clone(&*owner->contents.result);
7940 }
7941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7942         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7943         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
7944         int64_t ret_ref = 0;
7945         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7946         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7948         ret_ref = (uintptr_t)ret_var.inner;
7949         if (ret_var.is_owned) {
7950                 ret_ref |= 1;
7951         }
7952         return ret_ref;
7953 }
7954
7955 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7956 CHECK(!owner->result_ok);
7957         return ParseOrSemanticError_clone(&*owner->contents.err);
7958 }
7959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7960         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7961         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
7962         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
7963         int64_t ret_ref = (uintptr_t)ret_copy;
7964         return ret_ref;
7965 }
7966
7967 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7968 CHECK(owner->result_ok);
7969         return SignedRawInvoice_clone(&*owner->contents.result);
7970 }
7971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7972         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7973         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
7974         int64_t ret_ref = 0;
7975         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7976         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7978         ret_ref = (uintptr_t)ret_var.inner;
7979         if (ret_var.is_owned) {
7980                 ret_ref |= 1;
7981         }
7982         return ret_ref;
7983 }
7984
7985 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7986 CHECK(!owner->result_ok);
7987         return ParseError_clone(&*owner->contents.err);
7988 }
7989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7990         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7991         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7992         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
7993         int64_t ret_ref = (uintptr_t)ret_copy;
7994         return ret_ref;
7995 }
7996
7997 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7998         return RawInvoice_clone(&owner->a);
7999 }
8000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8001         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
8002         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
8003         int64_t ret_ref = 0;
8004         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8005         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8007         ret_ref = (uintptr_t)ret_var.inner;
8008         if (ret_var.is_owned) {
8009                 ret_ref |= 1;
8010         }
8011         return ret_ref;
8012 }
8013
8014 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
8015         return ThirtyTwoBytes_clone(&owner->b);
8016 }
8017 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8018         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
8019         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8020         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
8021         return ret_arr;
8022 }
8023
8024 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
8025         return InvoiceSignature_clone(&owner->c);
8026 }
8027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
8028         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
8029         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
8030         int64_t ret_ref = 0;
8031         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8032         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8034         ret_ref = (uintptr_t)ret_var.inner;
8035         if (ret_var.is_owned) {
8036                 ret_ref |= 1;
8037         }
8038         return ret_ref;
8039 }
8040
8041 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
8042 CHECK(owner->result_ok);
8043         return PayeePubKey_clone(&*owner->contents.result);
8044 }
8045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8046         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
8047         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
8048         int64_t ret_ref = 0;
8049         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8050         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8052         ret_ref = (uintptr_t)ret_var.inner;
8053         if (ret_var.is_owned) {
8054                 ret_ref |= 1;
8055         }
8056         return ret_ref;
8057 }
8058
8059 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
8060 CHECK(!owner->result_ok);
8061         return *owner->contents.err;
8062 }
8063 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8064         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
8065         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
8066         return ret_conv;
8067 }
8068
8069 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
8070         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
8071         for (size_t i = 0; i < ret.datalen; i++) {
8072                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
8073         }
8074         return ret;
8075 }
8076 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
8077 CHECK(owner->result_ok);
8078         return PositiveTimestamp_clone(&*owner->contents.result);
8079 }
8080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8081         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
8082         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
8083         int64_t ret_ref = 0;
8084         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8085         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8087         ret_ref = (uintptr_t)ret_var.inner;
8088         if (ret_var.is_owned) {
8089                 ret_ref |= 1;
8090         }
8091         return ret_ref;
8092 }
8093
8094 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
8095 CHECK(!owner->result_ok);
8096         return CreationError_clone(&*owner->contents.err);
8097 }
8098 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8099         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
8100         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
8101         return ret_conv;
8102 }
8103
8104 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
8105 CHECK(owner->result_ok);
8106         return *owner->contents.result;
8107 }
8108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8109         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
8110         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
8111 }
8112
8113 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
8114 CHECK(!owner->result_ok);
8115         return SemanticError_clone(&*owner->contents.err);
8116 }
8117 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8118         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
8119         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
8120         return ret_conv;
8121 }
8122
8123 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
8124 CHECK(owner->result_ok);
8125         return Invoice_clone(&*owner->contents.result);
8126 }
8127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8128         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
8129         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
8130         int64_t ret_ref = 0;
8131         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8132         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8134         ret_ref = (uintptr_t)ret_var.inner;
8135         if (ret_var.is_owned) {
8136                 ret_ref |= 1;
8137         }
8138         return ret_ref;
8139 }
8140
8141 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
8142 CHECK(!owner->result_ok);
8143         return SemanticError_clone(&*owner->contents.err);
8144 }
8145 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8146         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
8147         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
8148         return ret_conv;
8149 }
8150
8151 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
8152 CHECK(owner->result_ok);
8153         return Description_clone(&*owner->contents.result);
8154 }
8155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8156         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
8157         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
8158         int64_t ret_ref = 0;
8159         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8160         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8162         ret_ref = (uintptr_t)ret_var.inner;
8163         if (ret_var.is_owned) {
8164                 ret_ref |= 1;
8165         }
8166         return ret_ref;
8167 }
8168
8169 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
8170 CHECK(!owner->result_ok);
8171         return CreationError_clone(&*owner->contents.err);
8172 }
8173 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8174         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
8175         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
8176         return ret_conv;
8177 }
8178
8179 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
8180 CHECK(owner->result_ok);
8181         return PrivateRoute_clone(&*owner->contents.result);
8182 }
8183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8184         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
8185         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
8186         int64_t ret_ref = 0;
8187         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8188         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8190         ret_ref = (uintptr_t)ret_var.inner;
8191         if (ret_var.is_owned) {
8192                 ret_ref |= 1;
8193         }
8194         return ret_ref;
8195 }
8196
8197 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
8198 CHECK(!owner->result_ok);
8199         return CreationError_clone(&*owner->contents.err);
8200 }
8201 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8202         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
8203         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
8204         return ret_conv;
8205 }
8206
8207 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8208 CHECK(owner->result_ok);
8209         return *owner->contents.result;
8210 }
8211 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8212         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
8213         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
8214         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8215         return ret_conv;
8216 }
8217
8218 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8219 CHECK(!owner->result_ok);
8220         return *owner->contents.err;
8221 }
8222 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8223         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
8224         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
8225         return ret_conv;
8226 }
8227
8228 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8229 CHECK(owner->result_ok);
8230         return ChannelMonitorUpdate_clone(&*owner->contents.result);
8231 }
8232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8233         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
8234         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
8235         int64_t ret_ref = 0;
8236         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8237         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8239         ret_ref = (uintptr_t)ret_var.inner;
8240         if (ret_var.is_owned) {
8241                 ret_ref |= 1;
8242         }
8243         return ret_ref;
8244 }
8245
8246 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8247 CHECK(!owner->result_ok);
8248         return DecodeError_clone(&*owner->contents.err);
8249 }
8250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8251         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
8252         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
8253         int64_t ret_ref = 0;
8254         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8255         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8257         ret_ref = (uintptr_t)ret_var.inner;
8258         if (ret_var.is_owned) {
8259                 ret_ref |= 1;
8260         }
8261         return ret_ref;
8262 }
8263
8264 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
8265 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
8266 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
8267 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
8268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
8269         LDKCOption_MonitorEventZ_Some_class =
8270                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
8271         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
8272         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
8273         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
8274         LDKCOption_MonitorEventZ_None_class =
8275                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
8276         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
8277         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
8278         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
8279 }
8280 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8281         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
8282         switch(obj->tag) {
8283                 case LDKCOption_MonitorEventZ_Some: {
8284                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
8285                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
8286                 }
8287                 case LDKCOption_MonitorEventZ_None: {
8288                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
8289                 }
8290                 default: abort();
8291         }
8292 }
8293 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8294 CHECK(owner->result_ok);
8295         return COption_MonitorEventZ_clone(&*owner->contents.result);
8296 }
8297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8298         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
8299         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
8300         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
8301         int64_t ret_ref = (uintptr_t)ret_copy;
8302         return ret_ref;
8303 }
8304
8305 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8306 CHECK(!owner->result_ok);
8307         return DecodeError_clone(&*owner->contents.err);
8308 }
8309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8310         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
8311         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
8312         int64_t ret_ref = 0;
8313         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8314         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8316         ret_ref = (uintptr_t)ret_var.inner;
8317         if (ret_var.is_owned) {
8318                 ret_ref |= 1;
8319         }
8320         return ret_ref;
8321 }
8322
8323 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8324 CHECK(owner->result_ok);
8325         return HTLCUpdate_clone(&*owner->contents.result);
8326 }
8327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8328         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
8329         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
8330         int64_t ret_ref = 0;
8331         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8332         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8334         ret_ref = (uintptr_t)ret_var.inner;
8335         if (ret_var.is_owned) {
8336                 ret_ref |= 1;
8337         }
8338         return ret_ref;
8339 }
8340
8341 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8342 CHECK(!owner->result_ok);
8343         return DecodeError_clone(&*owner->contents.err);
8344 }
8345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8346         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
8347         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
8348         int64_t ret_ref = 0;
8349         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8350         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8352         ret_ref = (uintptr_t)ret_var.inner;
8353         if (ret_var.is_owned) {
8354                 ret_ref |= 1;
8355         }
8356         return ret_ref;
8357 }
8358
8359 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8360         return OutPoint_clone(&owner->a);
8361 }
8362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8363         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
8364         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
8365         int64_t ret_ref = 0;
8366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8369         ret_ref = (uintptr_t)ret_var.inner;
8370         if (ret_var.is_owned) {
8371                 ret_ref |= 1;
8372         }
8373         return ret_ref;
8374 }
8375
8376 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8377         return CVec_u8Z_clone(&owner->b);
8378 }
8379 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8380         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
8381         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
8382         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8383         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8384         CVec_u8Z_free(ret_var);
8385         return ret_arr;
8386 }
8387
8388 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8389         return owner->a;
8390 }
8391 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8392         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
8393         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
8394         return ret_conv;
8395 }
8396
8397 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8398         return CVec_u8Z_clone(&owner->b);
8399 }
8400 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8401         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
8402         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
8403         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8404         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8405         CVec_u8Z_free(ret_var);
8406         return ret_arr;
8407 }
8408
8409 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
8410         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
8411         for (size_t i = 0; i < ret.datalen; i++) {
8412                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
8413         }
8414         return ret;
8415 }
8416 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8417         return ThirtyTwoBytes_clone(&owner->a);
8418 }
8419 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8420         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
8421         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8422         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
8423         return ret_arr;
8424 }
8425
8426 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8427         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
8428 }
8429 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8430         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
8431         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
8432         int64_tArray ret_arr = NULL;
8433         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8434         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8435         for (size_t v = 0; v < ret_var.datalen; v++) {
8436                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8437                 *ret_conv_21_conv = ret_var.data[v];
8438                 ret_arr_ptr[v] = ((int64_t)ret_conv_21_conv);
8439         }
8440         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8441         FREE(ret_var.data);
8442         return ret_arr;
8443 }
8444
8445 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
8446         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 };
8447         for (size_t i = 0; i < ret.datalen; i++) {
8448                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
8449         }
8450         return ret;
8451 }
8452 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
8453         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
8454         for (size_t i = 0; i < ret.datalen; i++) {
8455                 ret.data[i] = Event_clone(&orig->data[i]);
8456         }
8457         return ret;
8458 }
8459 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8460         return owner->a;
8461 }
8462 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8463         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
8464         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
8465         return ret_conv;
8466 }
8467
8468 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8469         return TxOut_clone(&owner->b);
8470 }
8471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8472         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
8473         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8474         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
8475         return (int64_t)ret_ref;
8476 }
8477
8478 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
8479         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
8480         for (size_t i = 0; i < ret.datalen; i++) {
8481                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
8482         }
8483         return ret;
8484 }
8485 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8486         return ThirtyTwoBytes_clone(&owner->a);
8487 }
8488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8489         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
8490         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8491         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
8492         return ret_arr;
8493 }
8494
8495 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8496         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
8497 }
8498 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8499         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
8500         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
8501         int64_tArray ret_arr = NULL;
8502         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8503         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8504         for (size_t u = 0; u < ret_var.datalen; u++) {
8505                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8506                 *ret_conv_20_conv = ret_var.data[u];
8507                 ret_arr_ptr[u] = ((int64_t)ret_conv_20_conv);
8508         }
8509         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8510         FREE(ret_var.data);
8511         return ret_arr;
8512 }
8513
8514 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
8515         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 };
8516         for (size_t i = 0; i < ret.datalen; i++) {
8517                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
8518         }
8519         return ret;
8520 }
8521 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
8522 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
8523 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
8524 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
8525 static jclass LDKBalance_ContentiousClaimable_class = NULL;
8526 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
8527 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
8528 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
8529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
8530         LDKBalance_ClaimableOnChannelClose_class =
8531                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
8532         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
8533         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
8534         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
8535         LDKBalance_ClaimableAwaitingConfirmations_class =
8536                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
8537         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
8538         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
8539         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
8540         LDKBalance_ContentiousClaimable_class =
8541                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
8542         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
8543         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
8544         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
8545         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
8546                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout"));
8547         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
8548         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
8549         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
8550 }
8551 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8552         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
8553         switch(obj->tag) {
8554                 case LDKBalance_ClaimableOnChannelClose: {
8555                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
8556                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, claimable_amount_satoshis_conv);
8557                 }
8558                 case LDKBalance_ClaimableAwaitingConfirmations: {
8559                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
8560                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
8561                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, claimable_amount_satoshis_conv, confirmation_height_conv);
8562                 }
8563                 case LDKBalance_ContentiousClaimable: {
8564                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
8565                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
8566                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, claimable_amount_satoshis_conv, timeout_height_conv);
8567                 }
8568                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
8569                         int64_t claimable_amount_satoshis_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
8570                         int32_t claimable_height_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
8571                         return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, claimable_amount_satoshis_conv, claimable_height_conv);
8572                 }
8573                 default: abort();
8574         }
8575 }
8576 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
8577         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
8578         for (size_t i = 0; i < ret.datalen; i++) {
8579                 ret.data[i] = Balance_clone(&orig->data[i]);
8580         }
8581         return ret;
8582 }
8583 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8584 CHECK(owner->result_ok);
8585         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
8586 }
8587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8588         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
8589         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
8590         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
8591         return ((int64_t)ret_conv);
8592 }
8593
8594 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8595 CHECK(!owner->result_ok);
8596         return DecodeError_clone(&*owner->contents.err);
8597 }
8598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8599         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
8600         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
8601         int64_t ret_ref = 0;
8602         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8603         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8605         ret_ref = (uintptr_t)ret_var.inner;
8606         if (ret_var.is_owned) {
8607                 ret_ref |= 1;
8608         }
8609         return ret_ref;
8610 }
8611
8612 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8613         return owner->a;
8614 }
8615 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8616         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
8617         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
8618         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
8619         return ret_arr;
8620 }
8621
8622 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8623         return Type_clone(&owner->b);
8624 }
8625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8626         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
8627         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
8628         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
8629         return (int64_t)ret_ret;
8630 }
8631
8632 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
8633         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
8634         for (size_t i = 0; i < ret.datalen; i++) {
8635                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
8636         }
8637         return ret;
8638 }
8639 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
8640 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
8641 static jclass LDKCOption_NetAddressZ_None_class = NULL;
8642 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
8643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
8644         LDKCOption_NetAddressZ_Some_class =
8645                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
8646         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
8647         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
8648         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
8649         LDKCOption_NetAddressZ_None_class =
8650                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
8651         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
8652         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
8653         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
8654 }
8655 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8656         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
8657         switch(obj->tag) {
8658                 case LDKCOption_NetAddressZ_Some: {
8659                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
8660                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
8661                 }
8662                 case LDKCOption_NetAddressZ_None: {
8663                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
8664                 }
8665                 default: abort();
8666         }
8667 }
8668 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8669 CHECK(owner->result_ok);
8670         return CVec_u8Z_clone(&*owner->contents.result);
8671 }
8672 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8673         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
8674         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
8675         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8676         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8677         CVec_u8Z_free(ret_var);
8678         return ret_arr;
8679 }
8680
8681 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8682 CHECK(!owner->result_ok);
8683         return PeerHandleError_clone(&*owner->contents.err);
8684 }
8685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8686         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
8687         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
8688         int64_t ret_ref = 0;
8689         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8690         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8692         ret_ref = (uintptr_t)ret_var.inner;
8693         if (ret_var.is_owned) {
8694                 ret_ref |= 1;
8695         }
8696         return ret_ref;
8697 }
8698
8699 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8700 CHECK(owner->result_ok);
8701         return *owner->contents.result;
8702 }
8703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8704         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
8705         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
8706 }
8707
8708 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8709 CHECK(!owner->result_ok);
8710         return PeerHandleError_clone(&*owner->contents.err);
8711 }
8712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8713         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
8714         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
8715         int64_t ret_ref = 0;
8716         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8717         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8719         ret_ref = (uintptr_t)ret_var.inner;
8720         if (ret_var.is_owned) {
8721                 ret_ref |= 1;
8722         }
8723         return ret_ref;
8724 }
8725
8726 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8727 CHECK(owner->result_ok);
8728         return *owner->contents.result;
8729 }
8730 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8731         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
8732         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
8733         return ret_conv;
8734 }
8735
8736 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8737 CHECK(!owner->result_ok);
8738         return PeerHandleError_clone(&*owner->contents.err);
8739 }
8740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8741         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
8742         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
8743         int64_t ret_ref = 0;
8744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8747         ret_ref = (uintptr_t)ret_var.inner;
8748         if (ret_var.is_owned) {
8749                 ret_ref |= 1;
8750         }
8751         return ret_ref;
8752 }
8753
8754 static jclass LDKGraphSyncError_DecodeError_class = NULL;
8755 static jmethodID LDKGraphSyncError_DecodeError_meth = NULL;
8756 static jclass LDKGraphSyncError_LightningError_class = NULL;
8757 static jmethodID LDKGraphSyncError_LightningError_meth = NULL;
8758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGraphSyncError_init (JNIEnv *env, jclass clz) {
8759         LDKGraphSyncError_DecodeError_class =
8760                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$DecodeError"));
8761         CHECK(LDKGraphSyncError_DecodeError_class != NULL);
8762         LDKGraphSyncError_DecodeError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_DecodeError_class, "<init>", "(J)V");
8763         CHECK(LDKGraphSyncError_DecodeError_meth != NULL);
8764         LDKGraphSyncError_LightningError_class =
8765                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$LightningError"));
8766         CHECK(LDKGraphSyncError_LightningError_class != NULL);
8767         LDKGraphSyncError_LightningError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_LightningError_class, "<init>", "(J)V");
8768         CHECK(LDKGraphSyncError_LightningError_meth != NULL);
8769 }
8770 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGraphSyncError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8771         LDKGraphSyncError *obj = (LDKGraphSyncError*)(ptr & ~1);
8772         switch(obj->tag) {
8773                 case LDKGraphSyncError_DecodeError: {
8774                         LDKDecodeError decode_error_var = obj->decode_error;
8775                         int64_t decode_error_ref = 0;
8776                         CHECK((((uintptr_t)decode_error_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8777                         CHECK((((uintptr_t)&decode_error_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8778                         CHECK_INNER_FIELD_ACCESS_OR_NULL(decode_error_var);
8779                         decode_error_ref = (uintptr_t)decode_error_var.inner & ~1;
8780                         return (*env)->NewObject(env, LDKGraphSyncError_DecodeError_class, LDKGraphSyncError_DecodeError_meth, decode_error_ref);
8781                 }
8782                 case LDKGraphSyncError_LightningError: {
8783                         LDKLightningError lightning_error_var = obj->lightning_error;
8784                         int64_t lightning_error_ref = 0;
8785                         CHECK((((uintptr_t)lightning_error_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8786                         CHECK((((uintptr_t)&lightning_error_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8787                         CHECK_INNER_FIELD_ACCESS_OR_NULL(lightning_error_var);
8788                         lightning_error_ref = (uintptr_t)lightning_error_var.inner & ~1;
8789                         return (*env)->NewObject(env, LDKGraphSyncError_LightningError_class, LDKGraphSyncError_LightningError_meth, lightning_error_ref);
8790                 }
8791                 default: abort();
8792         }
8793 }
8794 static inline uint32_t CResult_u32GraphSyncErrorZ_get_ok(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
8795 CHECK(owner->result_ok);
8796         return *owner->contents.result;
8797 }
8798 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8799         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)(owner & ~1);
8800         int32_t ret_conv = CResult_u32GraphSyncErrorZ_get_ok(owner_conv);
8801         return ret_conv;
8802 }
8803
8804 static inline struct LDKGraphSyncError CResult_u32GraphSyncErrorZ_get_err(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
8805 CHECK(!owner->result_ok);
8806         return GraphSyncError_clone(&*owner->contents.err);
8807 }
8808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8809         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)(owner & ~1);
8810         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
8811         *ret_copy = CResult_u32GraphSyncErrorZ_get_err(owner_conv);
8812         int64_t ret_ref = (uintptr_t)ret_copy;
8813         return ret_ref;
8814 }
8815
8816 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8817 CHECK(owner->result_ok);
8818         return NetAddress_clone(&*owner->contents.result);
8819 }
8820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8821         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8822         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
8823         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
8824         int64_t ret_ref = (uintptr_t)ret_copy;
8825         return ret_ref;
8826 }
8827
8828 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8829 CHECK(!owner->result_ok);
8830         return DecodeError_clone(&*owner->contents.err);
8831 }
8832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8833         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8834         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
8835         int64_t ret_ref = 0;
8836         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8837         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8839         ret_ref = (uintptr_t)ret_var.inner;
8840         if (ret_var.is_owned) {
8841                 ret_ref |= 1;
8842         }
8843         return ret_ref;
8844 }
8845
8846 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
8847         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
8848         for (size_t i = 0; i < ret.datalen; i++) {
8849                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
8850         }
8851         return ret;
8852 }
8853 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
8854         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
8855         for (size_t i = 0; i < ret.datalen; i++) {
8856                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
8857         }
8858         return ret;
8859 }
8860 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
8861         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
8862         for (size_t i = 0; i < ret.datalen; i++) {
8863                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
8864         }
8865         return ret;
8866 }
8867 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
8868         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
8869         for (size_t i = 0; i < ret.datalen; i++) {
8870                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
8871         }
8872         return ret;
8873 }
8874 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8875 CHECK(owner->result_ok);
8876         return AcceptChannel_clone(&*owner->contents.result);
8877 }
8878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8879         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8880         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
8881         int64_t ret_ref = 0;
8882         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8883         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8885         ret_ref = (uintptr_t)ret_var.inner;
8886         if (ret_var.is_owned) {
8887                 ret_ref |= 1;
8888         }
8889         return ret_ref;
8890 }
8891
8892 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8893 CHECK(!owner->result_ok);
8894         return DecodeError_clone(&*owner->contents.err);
8895 }
8896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8897         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8898         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
8899         int64_t ret_ref = 0;
8900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8903         ret_ref = (uintptr_t)ret_var.inner;
8904         if (ret_var.is_owned) {
8905                 ret_ref |= 1;
8906         }
8907         return ret_ref;
8908 }
8909
8910 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8911 CHECK(owner->result_ok);
8912         return AnnouncementSignatures_clone(&*owner->contents.result);
8913 }
8914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8915         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8916         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
8917         int64_t ret_ref = 0;
8918         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8919         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8921         ret_ref = (uintptr_t)ret_var.inner;
8922         if (ret_var.is_owned) {
8923                 ret_ref |= 1;
8924         }
8925         return ret_ref;
8926 }
8927
8928 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8929 CHECK(!owner->result_ok);
8930         return DecodeError_clone(&*owner->contents.err);
8931 }
8932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8933         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8934         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
8935         int64_t ret_ref = 0;
8936         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8937         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8939         ret_ref = (uintptr_t)ret_var.inner;
8940         if (ret_var.is_owned) {
8941                 ret_ref |= 1;
8942         }
8943         return ret_ref;
8944 }
8945
8946 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8947 CHECK(owner->result_ok);
8948         return ChannelReestablish_clone(&*owner->contents.result);
8949 }
8950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8951         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8952         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
8953         int64_t ret_ref = 0;
8954         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8955         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8957         ret_ref = (uintptr_t)ret_var.inner;
8958         if (ret_var.is_owned) {
8959                 ret_ref |= 1;
8960         }
8961         return ret_ref;
8962 }
8963
8964 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8965 CHECK(!owner->result_ok);
8966         return DecodeError_clone(&*owner->contents.err);
8967 }
8968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8969         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8970         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
8971         int64_t ret_ref = 0;
8972         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8973         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8975         ret_ref = (uintptr_t)ret_var.inner;
8976         if (ret_var.is_owned) {
8977                 ret_ref |= 1;
8978         }
8979         return ret_ref;
8980 }
8981
8982 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8983 CHECK(owner->result_ok);
8984         return ClosingSigned_clone(&*owner->contents.result);
8985 }
8986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8987         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8988         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
8989         int64_t ret_ref = 0;
8990         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8991         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8993         ret_ref = (uintptr_t)ret_var.inner;
8994         if (ret_var.is_owned) {
8995                 ret_ref |= 1;
8996         }
8997         return ret_ref;
8998 }
8999
9000 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
9001 CHECK(!owner->result_ok);
9002         return DecodeError_clone(&*owner->contents.err);
9003 }
9004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9005         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
9006         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
9007         int64_t ret_ref = 0;
9008         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9009         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9011         ret_ref = (uintptr_t)ret_var.inner;
9012         if (ret_var.is_owned) {
9013                 ret_ref |= 1;
9014         }
9015         return ret_ref;
9016 }
9017
9018 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
9019 CHECK(owner->result_ok);
9020         return ClosingSignedFeeRange_clone(&*owner->contents.result);
9021 }
9022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9023         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
9024         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
9025         int64_t ret_ref = 0;
9026         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9027         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9029         ret_ref = (uintptr_t)ret_var.inner;
9030         if (ret_var.is_owned) {
9031                 ret_ref |= 1;
9032         }
9033         return ret_ref;
9034 }
9035
9036 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
9037 CHECK(!owner->result_ok);
9038         return DecodeError_clone(&*owner->contents.err);
9039 }
9040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9041         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
9042         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
9043         int64_t ret_ref = 0;
9044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9047         ret_ref = (uintptr_t)ret_var.inner;
9048         if (ret_var.is_owned) {
9049                 ret_ref |= 1;
9050         }
9051         return ret_ref;
9052 }
9053
9054 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
9055 CHECK(owner->result_ok);
9056         return CommitmentSigned_clone(&*owner->contents.result);
9057 }
9058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9059         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
9060         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
9061         int64_t ret_ref = 0;
9062         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9063         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9065         ret_ref = (uintptr_t)ret_var.inner;
9066         if (ret_var.is_owned) {
9067                 ret_ref |= 1;
9068         }
9069         return ret_ref;
9070 }
9071
9072 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
9073 CHECK(!owner->result_ok);
9074         return DecodeError_clone(&*owner->contents.err);
9075 }
9076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9077         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
9078         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
9079         int64_t ret_ref = 0;
9080         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9081         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9083         ret_ref = (uintptr_t)ret_var.inner;
9084         if (ret_var.is_owned) {
9085                 ret_ref |= 1;
9086         }
9087         return ret_ref;
9088 }
9089
9090 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
9091 CHECK(owner->result_ok);
9092         return FundingCreated_clone(&*owner->contents.result);
9093 }
9094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9095         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
9096         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
9097         int64_t ret_ref = 0;
9098         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9099         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9101         ret_ref = (uintptr_t)ret_var.inner;
9102         if (ret_var.is_owned) {
9103                 ret_ref |= 1;
9104         }
9105         return ret_ref;
9106 }
9107
9108 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
9109 CHECK(!owner->result_ok);
9110         return DecodeError_clone(&*owner->contents.err);
9111 }
9112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9113         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
9114         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
9115         int64_t ret_ref = 0;
9116         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9117         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9119         ret_ref = (uintptr_t)ret_var.inner;
9120         if (ret_var.is_owned) {
9121                 ret_ref |= 1;
9122         }
9123         return ret_ref;
9124 }
9125
9126 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
9127 CHECK(owner->result_ok);
9128         return FundingSigned_clone(&*owner->contents.result);
9129 }
9130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9131         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
9132         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
9133         int64_t ret_ref = 0;
9134         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9135         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9137         ret_ref = (uintptr_t)ret_var.inner;
9138         if (ret_var.is_owned) {
9139                 ret_ref |= 1;
9140         }
9141         return ret_ref;
9142 }
9143
9144 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
9145 CHECK(!owner->result_ok);
9146         return DecodeError_clone(&*owner->contents.err);
9147 }
9148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9149         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
9150         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
9151         int64_t ret_ref = 0;
9152         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9153         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9155         ret_ref = (uintptr_t)ret_var.inner;
9156         if (ret_var.is_owned) {
9157                 ret_ref |= 1;
9158         }
9159         return ret_ref;
9160 }
9161
9162 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
9163 CHECK(owner->result_ok);
9164         return ChannelReady_clone(&*owner->contents.result);
9165 }
9166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9167         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
9168         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
9169         int64_t ret_ref = 0;
9170         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9171         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9173         ret_ref = (uintptr_t)ret_var.inner;
9174         if (ret_var.is_owned) {
9175                 ret_ref |= 1;
9176         }
9177         return ret_ref;
9178 }
9179
9180 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
9181 CHECK(!owner->result_ok);
9182         return DecodeError_clone(&*owner->contents.err);
9183 }
9184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9185         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
9186         LDKDecodeError ret_var = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
9187         int64_t ret_ref = 0;
9188         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9189         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9191         ret_ref = (uintptr_t)ret_var.inner;
9192         if (ret_var.is_owned) {
9193                 ret_ref |= 1;
9194         }
9195         return ret_ref;
9196 }
9197
9198 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9199 CHECK(owner->result_ok);
9200         return Init_clone(&*owner->contents.result);
9201 }
9202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9203         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
9204         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
9205         int64_t ret_ref = 0;
9206         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9207         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9209         ret_ref = (uintptr_t)ret_var.inner;
9210         if (ret_var.is_owned) {
9211                 ret_ref |= 1;
9212         }
9213         return ret_ref;
9214 }
9215
9216 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9217 CHECK(!owner->result_ok);
9218         return DecodeError_clone(&*owner->contents.err);
9219 }
9220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9221         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
9222         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
9223         int64_t ret_ref = 0;
9224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9227         ret_ref = (uintptr_t)ret_var.inner;
9228         if (ret_var.is_owned) {
9229                 ret_ref |= 1;
9230         }
9231         return ret_ref;
9232 }
9233
9234 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9235 CHECK(owner->result_ok);
9236         return OpenChannel_clone(&*owner->contents.result);
9237 }
9238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9239         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
9240         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
9241         int64_t ret_ref = 0;
9242         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9243         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9245         ret_ref = (uintptr_t)ret_var.inner;
9246         if (ret_var.is_owned) {
9247                 ret_ref |= 1;
9248         }
9249         return ret_ref;
9250 }
9251
9252 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9253 CHECK(!owner->result_ok);
9254         return DecodeError_clone(&*owner->contents.err);
9255 }
9256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9257         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
9258         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
9259         int64_t ret_ref = 0;
9260         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9261         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9263         ret_ref = (uintptr_t)ret_var.inner;
9264         if (ret_var.is_owned) {
9265                 ret_ref |= 1;
9266         }
9267         return ret_ref;
9268 }
9269
9270 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9271 CHECK(owner->result_ok);
9272         return RevokeAndACK_clone(&*owner->contents.result);
9273 }
9274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9275         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
9276         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
9277         int64_t ret_ref = 0;
9278         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9279         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9281         ret_ref = (uintptr_t)ret_var.inner;
9282         if (ret_var.is_owned) {
9283                 ret_ref |= 1;
9284         }
9285         return ret_ref;
9286 }
9287
9288 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9289 CHECK(!owner->result_ok);
9290         return DecodeError_clone(&*owner->contents.err);
9291 }
9292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9293         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
9294         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
9295         int64_t ret_ref = 0;
9296         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9297         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9299         ret_ref = (uintptr_t)ret_var.inner;
9300         if (ret_var.is_owned) {
9301                 ret_ref |= 1;
9302         }
9303         return ret_ref;
9304 }
9305
9306 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9307 CHECK(owner->result_ok);
9308         return Shutdown_clone(&*owner->contents.result);
9309 }
9310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9311         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
9312         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
9313         int64_t ret_ref = 0;
9314         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9315         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9317         ret_ref = (uintptr_t)ret_var.inner;
9318         if (ret_var.is_owned) {
9319                 ret_ref |= 1;
9320         }
9321         return ret_ref;
9322 }
9323
9324 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9325 CHECK(!owner->result_ok);
9326         return DecodeError_clone(&*owner->contents.err);
9327 }
9328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9329         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
9330         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
9331         int64_t ret_ref = 0;
9332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9335         ret_ref = (uintptr_t)ret_var.inner;
9336         if (ret_var.is_owned) {
9337                 ret_ref |= 1;
9338         }
9339         return ret_ref;
9340 }
9341
9342 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9343 CHECK(owner->result_ok);
9344         return UpdateFailHTLC_clone(&*owner->contents.result);
9345 }
9346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9347         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
9348         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
9349         int64_t ret_ref = 0;
9350         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9351         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9353         ret_ref = (uintptr_t)ret_var.inner;
9354         if (ret_var.is_owned) {
9355                 ret_ref |= 1;
9356         }
9357         return ret_ref;
9358 }
9359
9360 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9361 CHECK(!owner->result_ok);
9362         return DecodeError_clone(&*owner->contents.err);
9363 }
9364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9365         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
9366         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
9367         int64_t ret_ref = 0;
9368         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9369         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9371         ret_ref = (uintptr_t)ret_var.inner;
9372         if (ret_var.is_owned) {
9373                 ret_ref |= 1;
9374         }
9375         return ret_ref;
9376 }
9377
9378 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9379 CHECK(owner->result_ok);
9380         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
9381 }
9382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9383         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
9384         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
9385         int64_t ret_ref = 0;
9386         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9387         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9389         ret_ref = (uintptr_t)ret_var.inner;
9390         if (ret_var.is_owned) {
9391                 ret_ref |= 1;
9392         }
9393         return ret_ref;
9394 }
9395
9396 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9397 CHECK(!owner->result_ok);
9398         return DecodeError_clone(&*owner->contents.err);
9399 }
9400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9401         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
9402         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
9403         int64_t ret_ref = 0;
9404         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9405         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9407         ret_ref = (uintptr_t)ret_var.inner;
9408         if (ret_var.is_owned) {
9409                 ret_ref |= 1;
9410         }
9411         return ret_ref;
9412 }
9413
9414 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9415 CHECK(owner->result_ok);
9416         return UpdateFee_clone(&*owner->contents.result);
9417 }
9418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9419         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
9420         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
9421         int64_t ret_ref = 0;
9422         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9423         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9425         ret_ref = (uintptr_t)ret_var.inner;
9426         if (ret_var.is_owned) {
9427                 ret_ref |= 1;
9428         }
9429         return ret_ref;
9430 }
9431
9432 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9433 CHECK(!owner->result_ok);
9434         return DecodeError_clone(&*owner->contents.err);
9435 }
9436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9437         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
9438         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
9439         int64_t ret_ref = 0;
9440         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9441         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9443         ret_ref = (uintptr_t)ret_var.inner;
9444         if (ret_var.is_owned) {
9445                 ret_ref |= 1;
9446         }
9447         return ret_ref;
9448 }
9449
9450 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9451 CHECK(owner->result_ok);
9452         return UpdateFulfillHTLC_clone(&*owner->contents.result);
9453 }
9454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9455         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9456         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
9457         int64_t ret_ref = 0;
9458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9461         ret_ref = (uintptr_t)ret_var.inner;
9462         if (ret_var.is_owned) {
9463                 ret_ref |= 1;
9464         }
9465         return ret_ref;
9466 }
9467
9468 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9469 CHECK(!owner->result_ok);
9470         return DecodeError_clone(&*owner->contents.err);
9471 }
9472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9473         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9474         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
9475         int64_t ret_ref = 0;
9476         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9477         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9479         ret_ref = (uintptr_t)ret_var.inner;
9480         if (ret_var.is_owned) {
9481                 ret_ref |= 1;
9482         }
9483         return ret_ref;
9484 }
9485
9486 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9487 CHECK(owner->result_ok);
9488         return UpdateAddHTLC_clone(&*owner->contents.result);
9489 }
9490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9491         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9492         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
9493         int64_t ret_ref = 0;
9494         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9495         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9497         ret_ref = (uintptr_t)ret_var.inner;
9498         if (ret_var.is_owned) {
9499                 ret_ref |= 1;
9500         }
9501         return ret_ref;
9502 }
9503
9504 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9505 CHECK(!owner->result_ok);
9506         return DecodeError_clone(&*owner->contents.err);
9507 }
9508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9509         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9510         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
9511         int64_t ret_ref = 0;
9512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9515         ret_ref = (uintptr_t)ret_var.inner;
9516         if (ret_var.is_owned) {
9517                 ret_ref |= 1;
9518         }
9519         return ret_ref;
9520 }
9521
9522 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9523 CHECK(owner->result_ok);
9524         return Ping_clone(&*owner->contents.result);
9525 }
9526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9527         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9528         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
9529         int64_t ret_ref = 0;
9530         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9531         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9533         ret_ref = (uintptr_t)ret_var.inner;
9534         if (ret_var.is_owned) {
9535                 ret_ref |= 1;
9536         }
9537         return ret_ref;
9538 }
9539
9540 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9541 CHECK(!owner->result_ok);
9542         return DecodeError_clone(&*owner->contents.err);
9543 }
9544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9545         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9546         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
9547         int64_t ret_ref = 0;
9548         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9549         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9551         ret_ref = (uintptr_t)ret_var.inner;
9552         if (ret_var.is_owned) {
9553                 ret_ref |= 1;
9554         }
9555         return ret_ref;
9556 }
9557
9558 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9559 CHECK(owner->result_ok);
9560         return Pong_clone(&*owner->contents.result);
9561 }
9562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9563         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9564         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
9565         int64_t ret_ref = 0;
9566         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9567         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9569         ret_ref = (uintptr_t)ret_var.inner;
9570         if (ret_var.is_owned) {
9571                 ret_ref |= 1;
9572         }
9573         return ret_ref;
9574 }
9575
9576 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9577 CHECK(!owner->result_ok);
9578         return DecodeError_clone(&*owner->contents.err);
9579 }
9580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9581         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9582         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
9583         int64_t ret_ref = 0;
9584         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9585         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9587         ret_ref = (uintptr_t)ret_var.inner;
9588         if (ret_var.is_owned) {
9589                 ret_ref |= 1;
9590         }
9591         return ret_ref;
9592 }
9593
9594 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9595 CHECK(owner->result_ok);
9596         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
9597 }
9598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9599         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9600         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9601         int64_t ret_ref = 0;
9602         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9603         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9605         ret_ref = (uintptr_t)ret_var.inner;
9606         if (ret_var.is_owned) {
9607                 ret_ref |= 1;
9608         }
9609         return ret_ref;
9610 }
9611
9612 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9613 CHECK(!owner->result_ok);
9614         return DecodeError_clone(&*owner->contents.err);
9615 }
9616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9617         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9618         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9619         int64_t ret_ref = 0;
9620         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9621         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9623         ret_ref = (uintptr_t)ret_var.inner;
9624         if (ret_var.is_owned) {
9625                 ret_ref |= 1;
9626         }
9627         return ret_ref;
9628 }
9629
9630 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9631 CHECK(owner->result_ok);
9632         return ChannelAnnouncement_clone(&*owner->contents.result);
9633 }
9634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9635         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9636         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9637         int64_t ret_ref = 0;
9638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9641         ret_ref = (uintptr_t)ret_var.inner;
9642         if (ret_var.is_owned) {
9643                 ret_ref |= 1;
9644         }
9645         return ret_ref;
9646 }
9647
9648 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9649 CHECK(!owner->result_ok);
9650         return DecodeError_clone(&*owner->contents.err);
9651 }
9652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9653         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9654         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9655         int64_t ret_ref = 0;
9656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9659         ret_ref = (uintptr_t)ret_var.inner;
9660         if (ret_var.is_owned) {
9661                 ret_ref |= 1;
9662         }
9663         return ret_ref;
9664 }
9665
9666 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9667 CHECK(owner->result_ok);
9668         return UnsignedChannelUpdate_clone(&*owner->contents.result);
9669 }
9670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9671         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9672         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9673         int64_t ret_ref = 0;
9674         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9675         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9677         ret_ref = (uintptr_t)ret_var.inner;
9678         if (ret_var.is_owned) {
9679                 ret_ref |= 1;
9680         }
9681         return ret_ref;
9682 }
9683
9684 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9685 CHECK(!owner->result_ok);
9686         return DecodeError_clone(&*owner->contents.err);
9687 }
9688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9689         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9690         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
9691         int64_t ret_ref = 0;
9692         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9693         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9695         ret_ref = (uintptr_t)ret_var.inner;
9696         if (ret_var.is_owned) {
9697                 ret_ref |= 1;
9698         }
9699         return ret_ref;
9700 }
9701
9702 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9703 CHECK(owner->result_ok);
9704         return ChannelUpdate_clone(&*owner->contents.result);
9705 }
9706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9707         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9708         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9709         int64_t ret_ref = 0;
9710         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9711         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9713         ret_ref = (uintptr_t)ret_var.inner;
9714         if (ret_var.is_owned) {
9715                 ret_ref |= 1;
9716         }
9717         return ret_ref;
9718 }
9719
9720 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9721 CHECK(!owner->result_ok);
9722         return DecodeError_clone(&*owner->contents.err);
9723 }
9724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9725         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9726         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
9727         int64_t ret_ref = 0;
9728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9731         ret_ref = (uintptr_t)ret_var.inner;
9732         if (ret_var.is_owned) {
9733                 ret_ref |= 1;
9734         }
9735         return ret_ref;
9736 }
9737
9738 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9739 CHECK(owner->result_ok);
9740         return ErrorMessage_clone(&*owner->contents.result);
9741 }
9742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9743         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9744         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
9745         int64_t ret_ref = 0;
9746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9749         ret_ref = (uintptr_t)ret_var.inner;
9750         if (ret_var.is_owned) {
9751                 ret_ref |= 1;
9752         }
9753         return ret_ref;
9754 }
9755
9756 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9757 CHECK(!owner->result_ok);
9758         return DecodeError_clone(&*owner->contents.err);
9759 }
9760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9761         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9762         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
9763         int64_t ret_ref = 0;
9764         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9765         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9767         ret_ref = (uintptr_t)ret_var.inner;
9768         if (ret_var.is_owned) {
9769                 ret_ref |= 1;
9770         }
9771         return ret_ref;
9772 }
9773
9774 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9775 CHECK(owner->result_ok);
9776         return WarningMessage_clone(&*owner->contents.result);
9777 }
9778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9779         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9780         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
9781         int64_t ret_ref = 0;
9782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9785         ret_ref = (uintptr_t)ret_var.inner;
9786         if (ret_var.is_owned) {
9787                 ret_ref |= 1;
9788         }
9789         return ret_ref;
9790 }
9791
9792 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9793 CHECK(!owner->result_ok);
9794         return DecodeError_clone(&*owner->contents.err);
9795 }
9796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9797         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9798         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
9799         int64_t ret_ref = 0;
9800         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9801         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9803         ret_ref = (uintptr_t)ret_var.inner;
9804         if (ret_var.is_owned) {
9805                 ret_ref |= 1;
9806         }
9807         return ret_ref;
9808 }
9809
9810 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9811 CHECK(owner->result_ok);
9812         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
9813 }
9814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9815         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9816         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9817         int64_t ret_ref = 0;
9818         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9819         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9821         ret_ref = (uintptr_t)ret_var.inner;
9822         if (ret_var.is_owned) {
9823                 ret_ref |= 1;
9824         }
9825         return ret_ref;
9826 }
9827
9828 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9829 CHECK(!owner->result_ok);
9830         return DecodeError_clone(&*owner->contents.err);
9831 }
9832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9833         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9834         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9835         int64_t ret_ref = 0;
9836         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9837         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9839         ret_ref = (uintptr_t)ret_var.inner;
9840         if (ret_var.is_owned) {
9841                 ret_ref |= 1;
9842         }
9843         return ret_ref;
9844 }
9845
9846 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9847 CHECK(owner->result_ok);
9848         return NodeAnnouncement_clone(&*owner->contents.result);
9849 }
9850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9851         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9852         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9853         int64_t ret_ref = 0;
9854         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9855         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9857         ret_ref = (uintptr_t)ret_var.inner;
9858         if (ret_var.is_owned) {
9859                 ret_ref |= 1;
9860         }
9861         return ret_ref;
9862 }
9863
9864 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9865 CHECK(!owner->result_ok);
9866         return DecodeError_clone(&*owner->contents.err);
9867 }
9868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9869         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9870         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9871         int64_t ret_ref = 0;
9872         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9873         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9875         ret_ref = (uintptr_t)ret_var.inner;
9876         if (ret_var.is_owned) {
9877                 ret_ref |= 1;
9878         }
9879         return ret_ref;
9880 }
9881
9882 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9883 CHECK(owner->result_ok);
9884         return QueryShortChannelIds_clone(&*owner->contents.result);
9885 }
9886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9887         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9888         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
9889         int64_t ret_ref = 0;
9890         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9891         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9893         ret_ref = (uintptr_t)ret_var.inner;
9894         if (ret_var.is_owned) {
9895                 ret_ref |= 1;
9896         }
9897         return ret_ref;
9898 }
9899
9900 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9901 CHECK(!owner->result_ok);
9902         return DecodeError_clone(&*owner->contents.err);
9903 }
9904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9905         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9906         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
9907         int64_t ret_ref = 0;
9908         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9909         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9911         ret_ref = (uintptr_t)ret_var.inner;
9912         if (ret_var.is_owned) {
9913                 ret_ref |= 1;
9914         }
9915         return ret_ref;
9916 }
9917
9918 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9919 CHECK(owner->result_ok);
9920         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
9921 }
9922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9923         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9924         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
9925         int64_t ret_ref = 0;
9926         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9927         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9929         ret_ref = (uintptr_t)ret_var.inner;
9930         if (ret_var.is_owned) {
9931                 ret_ref |= 1;
9932         }
9933         return ret_ref;
9934 }
9935
9936 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9937 CHECK(!owner->result_ok);
9938         return DecodeError_clone(&*owner->contents.err);
9939 }
9940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9941         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9942         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
9943         int64_t ret_ref = 0;
9944         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9945         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9947         ret_ref = (uintptr_t)ret_var.inner;
9948         if (ret_var.is_owned) {
9949                 ret_ref |= 1;
9950         }
9951         return ret_ref;
9952 }
9953
9954 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9955 CHECK(owner->result_ok);
9956         return QueryChannelRange_clone(&*owner->contents.result);
9957 }
9958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9959         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9960         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
9961         int64_t ret_ref = 0;
9962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9965         ret_ref = (uintptr_t)ret_var.inner;
9966         if (ret_var.is_owned) {
9967                 ret_ref |= 1;
9968         }
9969         return ret_ref;
9970 }
9971
9972 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9973 CHECK(!owner->result_ok);
9974         return DecodeError_clone(&*owner->contents.err);
9975 }
9976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9977         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9978         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
9979         int64_t ret_ref = 0;
9980         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9981         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9983         ret_ref = (uintptr_t)ret_var.inner;
9984         if (ret_var.is_owned) {
9985                 ret_ref |= 1;
9986         }
9987         return ret_ref;
9988 }
9989
9990 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9991 CHECK(owner->result_ok);
9992         return ReplyChannelRange_clone(&*owner->contents.result);
9993 }
9994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9995         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9996         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
9997         int64_t ret_ref = 0;
9998         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9999         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10001         ret_ref = (uintptr_t)ret_var.inner;
10002         if (ret_var.is_owned) {
10003                 ret_ref |= 1;
10004         }
10005         return ret_ref;
10006 }
10007
10008 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10009 CHECK(!owner->result_ok);
10010         return DecodeError_clone(&*owner->contents.err);
10011 }
10012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10013         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
10014         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
10015         int64_t ret_ref = 0;
10016         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10017         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10019         ret_ref = (uintptr_t)ret_var.inner;
10020         if (ret_var.is_owned) {
10021                 ret_ref |= 1;
10022         }
10023         return ret_ref;
10024 }
10025
10026 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
10027 CHECK(owner->result_ok);
10028         return GossipTimestampFilter_clone(&*owner->contents.result);
10029 }
10030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10031         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
10032         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
10033         int64_t ret_ref = 0;
10034         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10035         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10037         ret_ref = (uintptr_t)ret_var.inner;
10038         if (ret_var.is_owned) {
10039                 ret_ref |= 1;
10040         }
10041         return ret_ref;
10042 }
10043
10044 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
10045 CHECK(!owner->result_ok);
10046         return DecodeError_clone(&*owner->contents.err);
10047 }
10048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10049         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
10050         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
10051         int64_t ret_ref = 0;
10052         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10053         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10055         ret_ref = (uintptr_t)ret_var.inner;
10056         if (ret_var.is_owned) {
10057                 ret_ref |= 1;
10058         }
10059         return ret_ref;
10060 }
10061
10062 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
10063         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
10064         for (size_t i = 0; i < ret.datalen; i++) {
10065                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
10066         }
10067         return ret;
10068 }
10069 static jclass LDKSignOrCreationError_SignError_class = NULL;
10070 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
10071 static jclass LDKSignOrCreationError_CreationError_class = NULL;
10072 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
10073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
10074         LDKSignOrCreationError_SignError_class =
10075                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
10076         CHECK(LDKSignOrCreationError_SignError_class != NULL);
10077         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
10078         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
10079         LDKSignOrCreationError_CreationError_class =
10080                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
10081         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
10082         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
10083         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
10084 }
10085 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10086         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
10087         switch(obj->tag) {
10088                 case LDKSignOrCreationError_SignError: {
10089                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
10090                 }
10091                 case LDKSignOrCreationError_CreationError: {
10092                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
10093                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
10094                 }
10095                 default: abort();
10096         }
10097 }
10098 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
10099 CHECK(owner->result_ok);
10100         return Invoice_clone(&*owner->contents.result);
10101 }
10102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10103         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
10104         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
10105         int64_t ret_ref = 0;
10106         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10107         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10109         ret_ref = (uintptr_t)ret_var.inner;
10110         if (ret_var.is_owned) {
10111                 ret_ref |= 1;
10112         }
10113         return ret_ref;
10114 }
10115
10116 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
10117 CHECK(!owner->result_ok);
10118         return SignOrCreationError_clone(&*owner->contents.err);
10119 }
10120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10121         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
10122         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
10123         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
10124         int64_t ret_ref = (uintptr_t)ret_copy;
10125         return ret_ref;
10126 }
10127
10128 typedef struct LDKFilter_JCalls {
10129         atomic_size_t refcnt;
10130         JavaVM *vm;
10131         jweak o;
10132         jmethodID register_tx_meth;
10133         jmethodID register_output_meth;
10134 } LDKFilter_JCalls;
10135 static void LDKFilter_JCalls_free(void* this_arg) {
10136         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10137         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10138                 JNIEnv *env;
10139                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10140                 if (get_jenv_res == JNI_EDETACHED) {
10141                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10142                 } else {
10143                         DO_ASSERT(get_jenv_res == JNI_OK);
10144                 }
10145                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10146                 if (get_jenv_res == JNI_EDETACHED) {
10147                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10148                 }
10149                 FREE(j_calls);
10150         }
10151 }
10152 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
10153         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10154         JNIEnv *env;
10155         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10156         if (get_jenv_res == JNI_EDETACHED) {
10157                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10158         } else {
10159                 DO_ASSERT(get_jenv_res == JNI_OK);
10160         }
10161         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
10162         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
10163         LDKu8slice script_pubkey_var = script_pubkey;
10164         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
10165         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
10166         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10167         CHECK(obj != NULL);
10168         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
10169         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10170                 (*env)->ExceptionDescribe(env);
10171                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
10172         }
10173         if (get_jenv_res == JNI_EDETACHED) {
10174                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10175         }
10176 }
10177 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
10178         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10179         JNIEnv *env;
10180         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10181         if (get_jenv_res == JNI_EDETACHED) {
10182                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10183         } else {
10184                 DO_ASSERT(get_jenv_res == JNI_OK);
10185         }
10186         LDKWatchedOutput output_var = output;
10187         int64_t output_ref = 0;
10188         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10189         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10190         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
10191         output_ref = (uintptr_t)output_var.inner;
10192         if (output_var.is_owned) {
10193                 output_ref |= 1;
10194         }
10195         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10196         CHECK(obj != NULL);
10197         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
10198         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10199                 (*env)->ExceptionDescribe(env);
10200                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
10201         }
10202         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10203         CHECK_ACCESS(ret_ptr);
10204         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
10205         FREE((void*)ret);
10206         if (get_jenv_res == JNI_EDETACHED) {
10207                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10208         }
10209         return ret_conv;
10210 }
10211 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
10212         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
10213         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10214 }
10215 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
10216         jclass c = (*env)->GetObjectClass(env, o);
10217         CHECK(c != NULL);
10218         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
10219         atomic_init(&calls->refcnt, 1);
10220         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10221         calls->o = (*env)->NewWeakGlobalRef(env, o);
10222         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
10223         CHECK(calls->register_tx_meth != NULL);
10224         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
10225         CHECK(calls->register_output_meth != NULL);
10226
10227         LDKFilter ret = {
10228                 .this_arg = (void*) calls,
10229                 .register_tx = register_tx_LDKFilter_jcall,
10230                 .register_output = register_output_LDKFilter_jcall,
10231                 .free = LDKFilter_JCalls_free,
10232         };
10233         return ret;
10234 }
10235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
10236         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
10237         *res_ptr = LDKFilter_init(env, clz, o);
10238         return (uint64_t)res_ptr;
10239 }
10240 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) {
10241         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10242         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10243         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10244         unsigned char txid_arr[32];
10245         CHECK((*env)->GetArrayLength(env, txid) == 32);
10246         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
10247         unsigned char (*txid_ref)[32] = &txid_arr;
10248         LDKu8slice script_pubkey_ref;
10249         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
10250         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
10251         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
10252         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
10253 }
10254
10255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
10256         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10257         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10258         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10259         LDKWatchedOutput output_conv;
10260         output_conv.inner = (void*)(output & (~1));
10261         output_conv.is_owned = (output & 1) || (output == 0);
10262         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
10263         output_conv = WatchedOutput_clone(&output_conv);
10264         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
10265         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
10266         int64_t ret_ref = (uintptr_t)ret_copy;
10267         return ret_ref;
10268 }
10269
10270 static jclass LDKCOption_FilterZ_Some_class = NULL;
10271 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
10272 static jclass LDKCOption_FilterZ_None_class = NULL;
10273 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
10274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
10275         LDKCOption_FilterZ_Some_class =
10276                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
10277         CHECK(LDKCOption_FilterZ_Some_class != NULL);
10278         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
10279         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
10280         LDKCOption_FilterZ_None_class =
10281                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
10282         CHECK(LDKCOption_FilterZ_None_class != NULL);
10283         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
10284         CHECK(LDKCOption_FilterZ_None_meth != NULL);
10285 }
10286 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10287         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
10288         switch(obj->tag) {
10289                 case LDKCOption_FilterZ_Some: {
10290                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
10291                         *some_ret = obj->some;
10292                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
10293                         if ((*some_ret).free == LDKFilter_JCalls_free) {
10294                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10295                                 LDKFilter_JCalls_cloned(&(*some_ret));
10296                         }
10297                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (int64_t)some_ret);
10298                 }
10299                 case LDKCOption_FilterZ_None: {
10300                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
10301                 }
10302                 default: abort();
10303         }
10304 }
10305 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10306 CHECK(owner->result_ok);
10307         return &*owner->contents.result;
10308 }
10309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10310         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
10311         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
10312         int64_t ret_ref = 0;
10313         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10314         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10316         ret_ref = (uintptr_t)ret_var.inner & ~1;
10317         return ret_ref;
10318 }
10319
10320 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10321 CHECK(!owner->result_ok);
10322         return *owner->contents.err;
10323 }
10324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10325         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
10326         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
10327 }
10328
10329 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
10330         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
10331         for (size_t i = 0; i < ret.datalen; i++) {
10332                 ret.data[i] = OutPoint_clone(&orig->data[i]);
10333         }
10334         return ret;
10335 }
10336 typedef struct LDKMessageSendEventsProvider_JCalls {
10337         atomic_size_t refcnt;
10338         JavaVM *vm;
10339         jweak o;
10340         jmethodID get_and_clear_pending_msg_events_meth;
10341 } LDKMessageSendEventsProvider_JCalls;
10342 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
10343         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10344         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10345                 JNIEnv *env;
10346                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10347                 if (get_jenv_res == JNI_EDETACHED) {
10348                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10349                 } else {
10350                         DO_ASSERT(get_jenv_res == JNI_OK);
10351                 }
10352                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10353                 if (get_jenv_res == JNI_EDETACHED) {
10354                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10355                 }
10356                 FREE(j_calls);
10357         }
10358 }
10359 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
10360         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10361         JNIEnv *env;
10362         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10363         if (get_jenv_res == JNI_EDETACHED) {
10364                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10365         } else {
10366                 DO_ASSERT(get_jenv_res == JNI_OK);
10367         }
10368         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10369         CHECK(obj != NULL);
10370         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
10371         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10372                 (*env)->ExceptionDescribe(env);
10373                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
10374         }
10375         LDKCVec_MessageSendEventZ ret_constr;
10376         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10377         if (ret_constr.datalen > 0)
10378                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
10379         else
10380                 ret_constr.data = NULL;
10381         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
10382         for (size_t s = 0; s < ret_constr.datalen; s++) {
10383                 int64_t ret_conv_18 = ret_vals[s];
10384                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
10385                 CHECK_ACCESS(ret_conv_18_ptr);
10386                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
10387                 FREE((void*)ret_conv_18);
10388                 ret_constr.data[s] = ret_conv_18_conv;
10389         }
10390         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
10391         if (get_jenv_res == JNI_EDETACHED) {
10392                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10393         }
10394         return ret_constr;
10395 }
10396 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
10397         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
10398         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10399 }
10400 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10401         jclass c = (*env)->GetObjectClass(env, o);
10402         CHECK(c != NULL);
10403         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
10404         atomic_init(&calls->refcnt, 1);
10405         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10406         calls->o = (*env)->NewWeakGlobalRef(env, o);
10407         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
10408         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
10409
10410         LDKMessageSendEventsProvider ret = {
10411                 .this_arg = (void*) calls,
10412                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
10413                 .free = LDKMessageSendEventsProvider_JCalls_free,
10414         };
10415         return ret;
10416 }
10417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10418         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
10419         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
10420         return (uint64_t)res_ptr;
10421 }
10422 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10423         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10424         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10425         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
10426         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
10427         int64_tArray ret_arr = NULL;
10428         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10429         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10430         for (size_t s = 0; s < ret_var.datalen; s++) {
10431                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10432                 *ret_conv_18_copy = ret_var.data[s];
10433                 int64_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
10434                 ret_arr_ptr[s] = ret_conv_18_ref;
10435         }
10436         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10437         FREE(ret_var.data);
10438         return ret_arr;
10439 }
10440
10441 typedef struct LDKEventHandler_JCalls {
10442         atomic_size_t refcnt;
10443         JavaVM *vm;
10444         jweak o;
10445         jmethodID handle_event_meth;
10446 } LDKEventHandler_JCalls;
10447 static void LDKEventHandler_JCalls_free(void* this_arg) {
10448         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10449         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10450                 JNIEnv *env;
10451                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10452                 if (get_jenv_res == JNI_EDETACHED) {
10453                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10454                 } else {
10455                         DO_ASSERT(get_jenv_res == JNI_OK);
10456                 }
10457                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10458                 if (get_jenv_res == JNI_EDETACHED) {
10459                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10460                 }
10461                 FREE(j_calls);
10462         }
10463 }
10464 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
10465         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10466         JNIEnv *env;
10467         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10468         if (get_jenv_res == JNI_EDETACHED) {
10469                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10470         } else {
10471                 DO_ASSERT(get_jenv_res == JNI_OK);
10472         }
10473         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
10474         *ret_event = Event_clone(event);
10475         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10476         CHECK(obj != NULL);
10477         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (int64_t)ret_event);
10478         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10479                 (*env)->ExceptionDescribe(env);
10480                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
10481         }
10482         if (get_jenv_res == JNI_EDETACHED) {
10483                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10484         }
10485 }
10486 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
10487         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
10488         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10489 }
10490 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
10491         jclass c = (*env)->GetObjectClass(env, o);
10492         CHECK(c != NULL);
10493         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
10494         atomic_init(&calls->refcnt, 1);
10495         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10496         calls->o = (*env)->NewWeakGlobalRef(env, o);
10497         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
10498         CHECK(calls->handle_event_meth != NULL);
10499
10500         LDKEventHandler ret = {
10501                 .this_arg = (void*) calls,
10502                 .handle_event = handle_event_LDKEventHandler_jcall,
10503                 .free = LDKEventHandler_JCalls_free,
10504         };
10505         return ret;
10506 }
10507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
10508         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10509         *res_ptr = LDKEventHandler_init(env, clz, o);
10510         return (uint64_t)res_ptr;
10511 }
10512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
10513         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10514         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10515         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
10516         LDKEvent* event_conv = (LDKEvent*)event;
10517         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
10518 }
10519
10520 typedef struct LDKEventsProvider_JCalls {
10521         atomic_size_t refcnt;
10522         JavaVM *vm;
10523         jweak o;
10524         jmethodID process_pending_events_meth;
10525 } LDKEventsProvider_JCalls;
10526 static void LDKEventsProvider_JCalls_free(void* this_arg) {
10527         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10528         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10529                 JNIEnv *env;
10530                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10531                 if (get_jenv_res == JNI_EDETACHED) {
10532                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10533                 } else {
10534                         DO_ASSERT(get_jenv_res == JNI_OK);
10535                 }
10536                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10537                 if (get_jenv_res == JNI_EDETACHED) {
10538                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10539                 }
10540                 FREE(j_calls);
10541         }
10542 }
10543 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
10544         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10545         JNIEnv *env;
10546         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10547         if (get_jenv_res == JNI_EDETACHED) {
10548                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10549         } else {
10550                 DO_ASSERT(get_jenv_res == JNI_OK);
10551         }
10552         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10553         *handler_ret = handler;
10554         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10555         CHECK(obj != NULL);
10556         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (int64_t)handler_ret);
10557         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10558                 (*env)->ExceptionDescribe(env);
10559                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
10560         }
10561         if (get_jenv_res == JNI_EDETACHED) {
10562                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10563         }
10564 }
10565 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
10566         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
10567         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10568 }
10569 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10570         jclass c = (*env)->GetObjectClass(env, o);
10571         CHECK(c != NULL);
10572         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
10573         atomic_init(&calls->refcnt, 1);
10574         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10575         calls->o = (*env)->NewWeakGlobalRef(env, o);
10576         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
10577         CHECK(calls->process_pending_events_meth != NULL);
10578
10579         LDKEventsProvider ret = {
10580                 .this_arg = (void*) calls,
10581                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
10582                 .free = LDKEventsProvider_JCalls_free,
10583         };
10584         return ret;
10585 }
10586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10587         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
10588         *res_ptr = LDKEventsProvider_init(env, clz, o);
10589         return (uint64_t)res_ptr;
10590 }
10591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
10592         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10593         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10594         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
10595         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
10596         CHECK_ACCESS(handler_ptr);
10597         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
10598         if (handler_conv.free == LDKEventHandler_JCalls_free) {
10599                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10600                 LDKEventHandler_JCalls_cloned(&handler_conv);
10601         }
10602         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
10603 }
10604
10605 typedef struct LDKScore_JCalls {
10606         atomic_size_t refcnt;
10607         JavaVM *vm;
10608         jweak o;
10609         jmethodID channel_penalty_msat_meth;
10610         jmethodID payment_path_failed_meth;
10611         jmethodID payment_path_successful_meth;
10612         jmethodID probe_failed_meth;
10613         jmethodID probe_successful_meth;
10614         jmethodID write_meth;
10615 } LDKScore_JCalls;
10616 static void LDKScore_JCalls_free(void* this_arg) {
10617         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10618         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10619                 JNIEnv *env;
10620                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10621                 if (get_jenv_res == JNI_EDETACHED) {
10622                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10623                 } else {
10624                         DO_ASSERT(get_jenv_res == JNI_OK);
10625                 }
10626                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10627                 if (get_jenv_res == JNI_EDETACHED) {
10628                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10629                 }
10630                 FREE(j_calls);
10631         }
10632 }
10633 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
10634         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10635         JNIEnv *env;
10636         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10637         if (get_jenv_res == JNI_EDETACHED) {
10638                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10639         } else {
10640                 DO_ASSERT(get_jenv_res == JNI_OK);
10641         }
10642         int64_t short_channel_id_conv = short_channel_id;
10643         LDKNodeId source_var = *source;
10644         int64_t source_ref = 0;
10645         source_var = NodeId_clone(&source_var);
10646         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10647         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10648         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
10649         source_ref = (uintptr_t)source_var.inner;
10650         if (source_var.is_owned) {
10651                 source_ref |= 1;
10652         }
10653         LDKNodeId target_var = *target;
10654         int64_t target_ref = 0;
10655         target_var = NodeId_clone(&target_var);
10656         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10657         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10658         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
10659         target_ref = (uintptr_t)target_var.inner;
10660         if (target_var.is_owned) {
10661                 target_ref |= 1;
10662         }
10663         LDKChannelUsage usage_var = usage;
10664         int64_t usage_ref = 0;
10665         CHECK((((uintptr_t)usage_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10666         CHECK((((uintptr_t)&usage_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10667         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
10668         usage_ref = (uintptr_t)usage_var.inner;
10669         if (usage_var.is_owned) {
10670                 usage_ref |= 1;
10671         }
10672         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10673         CHECK(obj != NULL);
10674         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id_conv, source_ref, target_ref, usage_ref);
10675         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10676                 (*env)->ExceptionDescribe(env);
10677                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
10678         }
10679         if (get_jenv_res == JNI_EDETACHED) {
10680                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10681         }
10682         return ret;
10683 }
10684 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
10685         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10686         JNIEnv *env;
10687         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10688         if (get_jenv_res == JNI_EDETACHED) {
10689                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10690         } else {
10691                 DO_ASSERT(get_jenv_res == JNI_OK);
10692         }
10693         LDKCVec_RouteHopZ path_var = path;
10694         int64_tArray path_arr = NULL;
10695         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10696         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10697         for (size_t k = 0; k < path_var.datalen; k++) {
10698                 LDKRouteHop path_conv_10_var = path_var.data[k];
10699                 int64_t path_conv_10_ref = 0;
10700                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10701                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10702                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10703                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10704                 if (path_conv_10_var.is_owned) {
10705                         path_conv_10_ref |= 1;
10706                 }
10707                 path_arr_ptr[k] = path_conv_10_ref;
10708         }
10709         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10710         FREE(path_var.data);
10711         int64_t short_channel_id_conv = short_channel_id;
10712         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10713         CHECK(obj != NULL);
10714         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id_conv);
10715         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10716                 (*env)->ExceptionDescribe(env);
10717                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
10718         }
10719         if (get_jenv_res == JNI_EDETACHED) {
10720                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10721         }
10722 }
10723 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
10724         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10725         JNIEnv *env;
10726         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10727         if (get_jenv_res == JNI_EDETACHED) {
10728                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10729         } else {
10730                 DO_ASSERT(get_jenv_res == JNI_OK);
10731         }
10732         LDKCVec_RouteHopZ path_var = path;
10733         int64_tArray path_arr = NULL;
10734         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10735         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10736         for (size_t k = 0; k < path_var.datalen; k++) {
10737                 LDKRouteHop path_conv_10_var = path_var.data[k];
10738                 int64_t path_conv_10_ref = 0;
10739                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10740                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10741                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10742                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10743                 if (path_conv_10_var.is_owned) {
10744                         path_conv_10_ref |= 1;
10745                 }
10746                 path_arr_ptr[k] = path_conv_10_ref;
10747         }
10748         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10749         FREE(path_var.data);
10750         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10751         CHECK(obj != NULL);
10752         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
10753         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10754                 (*env)->ExceptionDescribe(env);
10755                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
10756         }
10757         if (get_jenv_res == JNI_EDETACHED) {
10758                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10759         }
10760 }
10761 void probe_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
10762         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10763         JNIEnv *env;
10764         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10765         if (get_jenv_res == JNI_EDETACHED) {
10766                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10767         } else {
10768                 DO_ASSERT(get_jenv_res == JNI_OK);
10769         }
10770         LDKCVec_RouteHopZ path_var = path;
10771         int64_tArray path_arr = NULL;
10772         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10773         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10774         for (size_t k = 0; k < path_var.datalen; k++) {
10775                 LDKRouteHop path_conv_10_var = path_var.data[k];
10776                 int64_t path_conv_10_ref = 0;
10777                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10778                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10779                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10780                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10781                 if (path_conv_10_var.is_owned) {
10782                         path_conv_10_ref |= 1;
10783                 }
10784                 path_arr_ptr[k] = path_conv_10_ref;
10785         }
10786         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10787         FREE(path_var.data);
10788         int64_t short_channel_id_conv = short_channel_id;
10789         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10790         CHECK(obj != NULL);
10791         (*env)->CallVoidMethod(env, obj, j_calls->probe_failed_meth, path_arr, short_channel_id_conv);
10792         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10793                 (*env)->ExceptionDescribe(env);
10794                 (*env)->FatalError(env, "A call to probe_failed in LDKScore from rust threw an exception.");
10795         }
10796         if (get_jenv_res == JNI_EDETACHED) {
10797                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10798         }
10799 }
10800 void probe_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
10801         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10802         JNIEnv *env;
10803         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10804         if (get_jenv_res == JNI_EDETACHED) {
10805                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10806         } else {
10807                 DO_ASSERT(get_jenv_res == JNI_OK);
10808         }
10809         LDKCVec_RouteHopZ path_var = path;
10810         int64_tArray path_arr = NULL;
10811         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10812         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10813         for (size_t k = 0; k < path_var.datalen; k++) {
10814                 LDKRouteHop path_conv_10_var = path_var.data[k];
10815                 int64_t path_conv_10_ref = 0;
10816                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10817                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10818                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10819                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10820                 if (path_conv_10_var.is_owned) {
10821                         path_conv_10_ref |= 1;
10822                 }
10823                 path_arr_ptr[k] = path_conv_10_ref;
10824         }
10825         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10826         FREE(path_var.data);
10827         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10828         CHECK(obj != NULL);
10829         (*env)->CallVoidMethod(env, obj, j_calls->probe_successful_meth, path_arr);
10830         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10831                 (*env)->ExceptionDescribe(env);
10832                 (*env)->FatalError(env, "A call to probe_successful in LDKScore from rust threw an exception.");
10833         }
10834         if (get_jenv_res == JNI_EDETACHED) {
10835                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10836         }
10837 }
10838 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
10839         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10840         JNIEnv *env;
10841         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10842         if (get_jenv_res == JNI_EDETACHED) {
10843                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10844         } else {
10845                 DO_ASSERT(get_jenv_res == JNI_OK);
10846         }
10847         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10848         CHECK(obj != NULL);
10849         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
10850         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10851                 (*env)->ExceptionDescribe(env);
10852                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
10853         }
10854         LDKCVec_u8Z ret_ref;
10855         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
10856         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
10857         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
10858         if (get_jenv_res == JNI_EDETACHED) {
10859                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10860         }
10861         return ret_ref;
10862 }
10863 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
10864         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
10865         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10866 }
10867 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
10868         jclass c = (*env)->GetObjectClass(env, o);
10869         CHECK(c != NULL);
10870         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
10871         atomic_init(&calls->refcnt, 1);
10872         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10873         calls->o = (*env)->NewWeakGlobalRef(env, o);
10874         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJ)J");
10875         CHECK(calls->channel_penalty_msat_meth != NULL);
10876         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
10877         CHECK(calls->payment_path_failed_meth != NULL);
10878         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
10879         CHECK(calls->payment_path_successful_meth != NULL);
10880         calls->probe_failed_meth = (*env)->GetMethodID(env, c, "probe_failed", "([JJ)V");
10881         CHECK(calls->probe_failed_meth != NULL);
10882         calls->probe_successful_meth = (*env)->GetMethodID(env, c, "probe_successful", "([J)V");
10883         CHECK(calls->probe_successful_meth != NULL);
10884         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
10885         CHECK(calls->write_meth != NULL);
10886
10887         LDKScore ret = {
10888                 .this_arg = (void*) calls,
10889                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
10890                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
10891                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
10892                 .probe_failed = probe_failed_LDKScore_jcall,
10893                 .probe_successful = probe_successful_LDKScore_jcall,
10894                 .write = write_LDKScore_jcall,
10895                 .free = LDKScore_JCalls_free,
10896         };
10897         return ret;
10898 }
10899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
10900         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
10901         *res_ptr = LDKScore_init(env, clz, o);
10902         return (uint64_t)res_ptr;
10903 }
10904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t source, int64_t target, int64_t usage) {
10905         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10906         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10907         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10908         LDKNodeId source_conv;
10909         source_conv.inner = (void*)(source & (~1));
10910         source_conv.is_owned = false;
10911         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
10912         LDKNodeId target_conv;
10913         target_conv.inner = (void*)(target & (~1));
10914         target_conv.is_owned = false;
10915         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
10916         LDKChannelUsage usage_conv;
10917         usage_conv.inner = (void*)(usage & (~1));
10918         usage_conv.is_owned = (usage & 1) || (usage == 0);
10919         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
10920         usage_conv = ChannelUsage_clone(&usage_conv);
10921         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
10922         return ret_conv;
10923 }
10924
10925 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) {
10926         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10927         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10928         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10929         LDKCVec_RouteHopZ path_constr;
10930         path_constr.datalen = (*env)->GetArrayLength(env, path);
10931         if (path_constr.datalen > 0)
10932                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10933         else
10934                 path_constr.data = NULL;
10935         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10936         for (size_t k = 0; k < path_constr.datalen; k++) {
10937                 int64_t path_conv_10 = path_vals[k];
10938                 LDKRouteHop path_conv_10_conv;
10939                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10940                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10941                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10942                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10943                 path_constr.data[k] = path_conv_10_conv;
10944         }
10945         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10946         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10947 }
10948
10949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
10950         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10951         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10952         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10953         LDKCVec_RouteHopZ path_constr;
10954         path_constr.datalen = (*env)->GetArrayLength(env, path);
10955         if (path_constr.datalen > 0)
10956                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10957         else
10958                 path_constr.data = NULL;
10959         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10960         for (size_t k = 0; k < path_constr.datalen; k++) {
10961                 int64_t path_conv_10 = path_vals[k];
10962                 LDKRouteHop path_conv_10_conv;
10963                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10964                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10965                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10966                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10967                 path_constr.data[k] = path_conv_10_conv;
10968         }
10969         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10970         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
10971 }
10972
10973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
10974         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10975         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10976         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10977         LDKCVec_RouteHopZ path_constr;
10978         path_constr.datalen = (*env)->GetArrayLength(env, path);
10979         if (path_constr.datalen > 0)
10980                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10981         else
10982                 path_constr.data = NULL;
10983         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10984         for (size_t k = 0; k < path_constr.datalen; k++) {
10985                 int64_t path_conv_10 = path_vals[k];
10986                 LDKRouteHop path_conv_10_conv;
10987                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10988                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10989                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10990                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10991                 path_constr.data[k] = path_conv_10_conv;
10992         }
10993         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10994         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10995 }
10996
10997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
10998         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10999         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11000         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
11001         LDKCVec_RouteHopZ path_constr;
11002         path_constr.datalen = (*env)->GetArrayLength(env, path);
11003         if (path_constr.datalen > 0)
11004                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11005         else
11006                 path_constr.data = NULL;
11007         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
11008         for (size_t k = 0; k < path_constr.datalen; k++) {
11009                 int64_t path_conv_10 = path_vals[k];
11010                 LDKRouteHop path_conv_10_conv;
11011                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
11012                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
11013                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
11014                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
11015                 path_constr.data[k] = path_conv_10_conv;
11016         }
11017         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
11018         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, path_constr);
11019 }
11020
11021 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
11022         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11023         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11024         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
11025         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
11026         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
11027         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
11028         CVec_u8Z_free(ret_var);
11029         return ret_arr;
11030 }
11031
11032 typedef struct LDKPersister_JCalls {
11033         atomic_size_t refcnt;
11034         JavaVM *vm;
11035         jweak o;
11036         jmethodID persist_manager_meth;
11037         jmethodID persist_graph_meth;
11038         jmethodID persist_scorer_meth;
11039 } LDKPersister_JCalls;
11040 static void LDKPersister_JCalls_free(void* this_arg) {
11041         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11042         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
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                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11051                 if (get_jenv_res == JNI_EDETACHED) {
11052                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11053                 }
11054                 FREE(j_calls);
11055         }
11056 }
11057 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
11058         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11059         JNIEnv *env;
11060         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11061         if (get_jenv_res == JNI_EDETACHED) {
11062                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11063         } else {
11064                 DO_ASSERT(get_jenv_res == JNI_OK);
11065         }
11066         LDKChannelManager channel_manager_var = *channel_manager;
11067         int64_t channel_manager_ref = 0;
11068         // WARNING: we may need a move here but no clone is available for LDKChannelManager
11069         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11070         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11071         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
11072         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
11073         if (channel_manager_var.is_owned) {
11074                 channel_manager_ref |= 1;
11075         }
11076         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11077         CHECK(obj != NULL);
11078         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
11079         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11080                 (*env)->ExceptionDescribe(env);
11081                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
11082         }
11083         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11084         CHECK_ACCESS(ret_ptr);
11085         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11086         FREE((void*)ret);
11087         if (get_jenv_res == JNI_EDETACHED) {
11088                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11089         }
11090         return ret_conv;
11091 }
11092 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
11093         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11094         JNIEnv *env;
11095         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11096         if (get_jenv_res == JNI_EDETACHED) {
11097                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11098         } else {
11099                 DO_ASSERT(get_jenv_res == JNI_OK);
11100         }
11101         LDKNetworkGraph network_graph_var = *network_graph;
11102         int64_t network_graph_ref = 0;
11103         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
11104         CHECK((((uintptr_t)network_graph_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11105         CHECK((((uintptr_t)&network_graph_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11106         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
11107         network_graph_ref = (uintptr_t)network_graph_var.inner;
11108         if (network_graph_var.is_owned) {
11109                 network_graph_ref |= 1;
11110         }
11111         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11112         CHECK(obj != NULL);
11113         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
11114         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11115                 (*env)->ExceptionDescribe(env);
11116                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
11117         }
11118         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11119         CHECK_ACCESS(ret_ptr);
11120         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11121         FREE((void*)ret);
11122         if (get_jenv_res == JNI_EDETACHED) {
11123                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11124         }
11125         return ret_conv;
11126 }
11127 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKMultiThreadedLockableScore * scorer) {
11128         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11129         JNIEnv *env;
11130         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11131         if (get_jenv_res == JNI_EDETACHED) {
11132                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11133         } else {
11134                 DO_ASSERT(get_jenv_res == JNI_OK);
11135         }
11136         LDKMultiThreadedLockableScore scorer_var = *scorer;
11137         int64_t scorer_ref = 0;
11138         // WARNING: we may need a move here but no clone is available for LDKMultiThreadedLockableScore
11139         CHECK((((uintptr_t)scorer_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11140         CHECK((((uintptr_t)&scorer_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11141         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_var);
11142         scorer_ref = (uintptr_t)scorer_var.inner;
11143         if (scorer_var.is_owned) {
11144                 scorer_ref |= 1;
11145         }
11146         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11147         CHECK(obj != NULL);
11148         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_scorer_meth, scorer_ref);
11149         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11150                 (*env)->ExceptionDescribe(env);
11151                 (*env)->FatalError(env, "A call to persist_scorer in LDKPersister from rust threw an exception.");
11152         }
11153         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11154         CHECK_ACCESS(ret_ptr);
11155         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11156         FREE((void*)ret);
11157         if (get_jenv_res == JNI_EDETACHED) {
11158                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11159         }
11160         return ret_conv;
11161 }
11162 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
11163         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
11164         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11165 }
11166 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
11167         jclass c = (*env)->GetObjectClass(env, o);
11168         CHECK(c != NULL);
11169         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
11170         atomic_init(&calls->refcnt, 1);
11171         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11172         calls->o = (*env)->NewWeakGlobalRef(env, o);
11173         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
11174         CHECK(calls->persist_manager_meth != NULL);
11175         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
11176         CHECK(calls->persist_graph_meth != NULL);
11177         calls->persist_scorer_meth = (*env)->GetMethodID(env, c, "persist_scorer", "(J)J");
11178         CHECK(calls->persist_scorer_meth != NULL);
11179
11180         LDKPersister ret = {
11181                 .this_arg = (void*) calls,
11182                 .persist_manager = persist_manager_LDKPersister_jcall,
11183                 .persist_graph = persist_graph_LDKPersister_jcall,
11184                 .persist_scorer = persist_scorer_LDKPersister_jcall,
11185                 .free = LDKPersister_JCalls_free,
11186         };
11187         return ret;
11188 }
11189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
11190         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
11191         *res_ptr = LDKPersister_init(env, clz, o);
11192         return (uint64_t)res_ptr;
11193 }
11194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
11195         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11196         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11197         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11198         LDKChannelManager channel_manager_conv;
11199         channel_manager_conv.inner = (void*)(channel_manager & (~1));
11200         channel_manager_conv.is_owned = false;
11201         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
11202         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11203         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
11204         return (int64_t)ret_conv;
11205 }
11206
11207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
11208         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11209         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11210         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11211         LDKNetworkGraph network_graph_conv;
11212         network_graph_conv.inner = (void*)(network_graph & (~1));
11213         network_graph_conv.is_owned = false;
11214         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
11215         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11216         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
11217         return (int64_t)ret_conv;
11218 }
11219
11220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1scorer(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scorer) {
11221         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11222         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11223         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11224         LDKMultiThreadedLockableScore scorer_conv;
11225         scorer_conv.inner = (void*)(scorer & (~1));
11226         scorer_conv.is_owned = false;
11227         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
11228         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11229         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, &scorer_conv);
11230         return (int64_t)ret_conv;
11231 }
11232
11233 typedef struct LDKListen_JCalls {
11234         atomic_size_t refcnt;
11235         JavaVM *vm;
11236         jweak o;
11237         jmethodID filtered_block_connected_meth;
11238         jmethodID block_connected_meth;
11239         jmethodID block_disconnected_meth;
11240 } LDKListen_JCalls;
11241 static void LDKListen_JCalls_free(void* this_arg) {
11242         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11243         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11244                 JNIEnv *env;
11245                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11246                 if (get_jenv_res == JNI_EDETACHED) {
11247                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11248                 } else {
11249                         DO_ASSERT(get_jenv_res == JNI_OK);
11250                 }
11251                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11252                 if (get_jenv_res == JNI_EDETACHED) {
11253                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11254                 }
11255                 FREE(j_calls);
11256         }
11257 }
11258 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11259         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11260         JNIEnv *env;
11261         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11262         if (get_jenv_res == JNI_EDETACHED) {
11263                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11264         } else {
11265                 DO_ASSERT(get_jenv_res == JNI_OK);
11266         }
11267         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11268         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11269         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11270         int64_tArray txdata_arr = NULL;
11271         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11272         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11273         for (size_t c = 0; c < txdata_var.datalen; c++) {
11274                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11275                 *txdata_conv_28_conv = txdata_var.data[c];
11276                 txdata_arr_ptr[c] = ((int64_t)txdata_conv_28_conv);
11277         }
11278         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11279         FREE(txdata_var.data);
11280         int32_t height_conv = height;
11281         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11282         CHECK(obj != NULL);
11283         (*env)->CallVoidMethod(env, obj, j_calls->filtered_block_connected_meth, header_arr, txdata_arr, height_conv);
11284         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11285                 (*env)->ExceptionDescribe(env);
11286                 (*env)->FatalError(env, "A call to filtered_block_connected in LDKListen from rust threw an exception.");
11287         }
11288         if (get_jenv_res == JNI_EDETACHED) {
11289                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11290         }
11291 }
11292 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
11293         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11294         JNIEnv *env;
11295         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11296         if (get_jenv_res == JNI_EDETACHED) {
11297                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11298         } else {
11299                 DO_ASSERT(get_jenv_res == JNI_OK);
11300         }
11301         LDKu8slice block_var = block;
11302         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
11303         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
11304         int32_t height_conv = height;
11305         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11306         CHECK(obj != NULL);
11307         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height_conv);
11308         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11309                 (*env)->ExceptionDescribe(env);
11310                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
11311         }
11312         if (get_jenv_res == JNI_EDETACHED) {
11313                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11314         }
11315 }
11316 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11317         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11318         JNIEnv *env;
11319         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11320         if (get_jenv_res == JNI_EDETACHED) {
11321                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11322         } else {
11323                 DO_ASSERT(get_jenv_res == JNI_OK);
11324         }
11325         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11326         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11327         int32_t height_conv = height;
11328         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11329         CHECK(obj != NULL);
11330         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height_conv);
11331         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11332                 (*env)->ExceptionDescribe(env);
11333                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
11334         }
11335         if (get_jenv_res == JNI_EDETACHED) {
11336                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11337         }
11338 }
11339 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
11340         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
11341         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11342 }
11343 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
11344         jclass c = (*env)->GetObjectClass(env, o);
11345         CHECK(c != NULL);
11346         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
11347         atomic_init(&calls->refcnt, 1);
11348         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11349         calls->o = (*env)->NewWeakGlobalRef(env, o);
11350         calls->filtered_block_connected_meth = (*env)->GetMethodID(env, c, "filtered_block_connected", "([B[JI)V");
11351         CHECK(calls->filtered_block_connected_meth != NULL);
11352         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
11353         CHECK(calls->block_connected_meth != NULL);
11354         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
11355         CHECK(calls->block_disconnected_meth != NULL);
11356
11357         LDKListen ret = {
11358                 .this_arg = (void*) calls,
11359                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
11360                 .block_connected = block_connected_LDKListen_jcall,
11361                 .block_disconnected = block_disconnected_LDKListen_jcall,
11362                 .free = LDKListen_JCalls_free,
11363         };
11364         return ret;
11365 }
11366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
11367         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
11368         *res_ptr = LDKListen_init(env, clz, o);
11369         return (uint64_t)res_ptr;
11370 }
11371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1filtered_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
11372         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11373         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11374         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11375         unsigned char header_arr[80];
11376         CHECK((*env)->GetArrayLength(env, header) == 80);
11377         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11378         unsigned char (*header_ref)[80] = &header_arr;
11379         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11380         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11381         if (txdata_constr.datalen > 0)
11382                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11383         else
11384                 txdata_constr.data = NULL;
11385         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11386         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11387                 int64_t txdata_conv_28 = txdata_vals[c];
11388                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
11389                 CHECK_ACCESS(txdata_conv_28_ptr);
11390                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11391                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
11392                 txdata_constr.data[c] = txdata_conv_28_conv;
11393         }
11394         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11395         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11396 }
11397
11398 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) {
11399         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11400         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11401         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11402         LDKu8slice block_ref;
11403         block_ref.datalen = (*env)->GetArrayLength(env, block);
11404         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
11405         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
11406         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
11407 }
11408
11409 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) {
11410         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11411         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11412         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11413         unsigned char header_arr[80];
11414         CHECK((*env)->GetArrayLength(env, header) == 80);
11415         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11416         unsigned char (*header_ref)[80] = &header_arr;
11417         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
11418 }
11419
11420 typedef struct LDKConfirm_JCalls {
11421         atomic_size_t refcnt;
11422         JavaVM *vm;
11423         jweak o;
11424         jmethodID transactions_confirmed_meth;
11425         jmethodID transaction_unconfirmed_meth;
11426         jmethodID best_block_updated_meth;
11427         jmethodID get_relevant_txids_meth;
11428 } LDKConfirm_JCalls;
11429 static void LDKConfirm_JCalls_free(void* this_arg) {
11430         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11431         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11432                 JNIEnv *env;
11433                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11434                 if (get_jenv_res == JNI_EDETACHED) {
11435                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11436                 } else {
11437                         DO_ASSERT(get_jenv_res == JNI_OK);
11438                 }
11439                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11440                 if (get_jenv_res == JNI_EDETACHED) {
11441                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11442                 }
11443                 FREE(j_calls);
11444         }
11445 }
11446 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11447         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11448         JNIEnv *env;
11449         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11450         if (get_jenv_res == JNI_EDETACHED) {
11451                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11452         } else {
11453                 DO_ASSERT(get_jenv_res == JNI_OK);
11454         }
11455         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11456         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11457         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11458         int64_tArray txdata_arr = NULL;
11459         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11460         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11461         for (size_t c = 0; c < txdata_var.datalen; c++) {
11462                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11463                 *txdata_conv_28_conv = txdata_var.data[c];
11464                 txdata_arr_ptr[c] = ((int64_t)txdata_conv_28_conv);
11465         }
11466         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11467         FREE(txdata_var.data);
11468         int32_t height_conv = height;
11469         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11470         CHECK(obj != NULL);
11471         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height_conv);
11472         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11473                 (*env)->ExceptionDescribe(env);
11474                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
11475         }
11476         if (get_jenv_res == JNI_EDETACHED) {
11477                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11478         }
11479 }
11480 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
11481         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11482         JNIEnv *env;
11483         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11484         if (get_jenv_res == JNI_EDETACHED) {
11485                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11486         } else {
11487                 DO_ASSERT(get_jenv_res == JNI_OK);
11488         }
11489         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
11490         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
11491         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11492         CHECK(obj != NULL);
11493         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
11494         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11495                 (*env)->ExceptionDescribe(env);
11496                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
11497         }
11498         if (get_jenv_res == JNI_EDETACHED) {
11499                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11500         }
11501 }
11502 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11503         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11504         JNIEnv *env;
11505         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11506         if (get_jenv_res == JNI_EDETACHED) {
11507                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11508         } else {
11509                 DO_ASSERT(get_jenv_res == JNI_OK);
11510         }
11511         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11512         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11513         int32_t height_conv = height;
11514         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11515         CHECK(obj != NULL);
11516         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height_conv);
11517         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11518                 (*env)->ExceptionDescribe(env);
11519                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
11520         }
11521         if (get_jenv_res == JNI_EDETACHED) {
11522                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11523         }
11524 }
11525 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
11526         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11527         JNIEnv *env;
11528         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11529         if (get_jenv_res == JNI_EDETACHED) {
11530                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11531         } else {
11532                 DO_ASSERT(get_jenv_res == JNI_OK);
11533         }
11534         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11535         CHECK(obj != NULL);
11536         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
11537         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11538                 (*env)->ExceptionDescribe(env);
11539                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
11540         }
11541         LDKCVec_TxidZ ret_constr;
11542         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11543         if (ret_constr.datalen > 0)
11544                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
11545         else
11546                 ret_constr.data = NULL;
11547         for (size_t i = 0; i < ret_constr.datalen; i++) {
11548                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
11549                 LDKThirtyTwoBytes ret_conv_8_ref;
11550                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
11551                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
11552                 ret_constr.data[i] = ret_conv_8_ref;
11553         }
11554         if (get_jenv_res == JNI_EDETACHED) {
11555                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11556         }
11557         return ret_constr;
11558 }
11559 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
11560         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
11561         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11562 }
11563 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
11564         jclass c = (*env)->GetObjectClass(env, o);
11565         CHECK(c != NULL);
11566         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
11567         atomic_init(&calls->refcnt, 1);
11568         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11569         calls->o = (*env)->NewWeakGlobalRef(env, o);
11570         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
11571         CHECK(calls->transactions_confirmed_meth != NULL);
11572         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
11573         CHECK(calls->transaction_unconfirmed_meth != NULL);
11574         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
11575         CHECK(calls->best_block_updated_meth != NULL);
11576         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
11577         CHECK(calls->get_relevant_txids_meth != NULL);
11578
11579         LDKConfirm ret = {
11580                 .this_arg = (void*) calls,
11581                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
11582                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
11583                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
11584                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
11585                 .free = LDKConfirm_JCalls_free,
11586         };
11587         return ret;
11588 }
11589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
11590         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
11591         *res_ptr = LDKConfirm_init(env, clz, o);
11592         return (uint64_t)res_ptr;
11593 }
11594 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) {
11595         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11596         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11597         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11598         unsigned char header_arr[80];
11599         CHECK((*env)->GetArrayLength(env, header) == 80);
11600         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11601         unsigned char (*header_ref)[80] = &header_arr;
11602         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11603         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11604         if (txdata_constr.datalen > 0)
11605                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11606         else
11607                 txdata_constr.data = NULL;
11608         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11609         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11610                 int64_t txdata_conv_28 = txdata_vals[c];
11611                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
11612                 CHECK_ACCESS(txdata_conv_28_ptr);
11613                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11614                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
11615                 txdata_constr.data[c] = txdata_conv_28_conv;
11616         }
11617         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11618         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11619 }
11620
11621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
11622         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11623         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11624         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11625         unsigned char txid_arr[32];
11626         CHECK((*env)->GetArrayLength(env, txid) == 32);
11627         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11628         unsigned char (*txid_ref)[32] = &txid_arr;
11629         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
11630 }
11631
11632 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) {
11633         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11634         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11635         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11636         unsigned char header_arr[80];
11637         CHECK((*env)->GetArrayLength(env, header) == 80);
11638         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11639         unsigned char (*header_ref)[80] = &header_arr;
11640         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
11641 }
11642
11643 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
11644         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11645         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11646         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11647         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
11648         jobjectArray ret_arr = NULL;
11649         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
11650         ;
11651         for (size_t i = 0; i < ret_var.datalen; i++) {
11652                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
11653                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
11654                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
11655         }
11656         
11657         FREE(ret_var.data);
11658         return ret_arr;
11659 }
11660
11661 typedef struct LDKPersist_JCalls {
11662         atomic_size_t refcnt;
11663         JavaVM *vm;
11664         jweak o;
11665         jmethodID persist_new_channel_meth;
11666         jmethodID update_persisted_channel_meth;
11667 } LDKPersist_JCalls;
11668 static void LDKPersist_JCalls_free(void* this_arg) {
11669         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11670         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11671                 JNIEnv *env;
11672                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11673                 if (get_jenv_res == JNI_EDETACHED) {
11674                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11675                 } else {
11676                         DO_ASSERT(get_jenv_res == JNI_OK);
11677                 }
11678                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11679                 if (get_jenv_res == JNI_EDETACHED) {
11680                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11681                 }
11682                 FREE(j_calls);
11683         }
11684 }
11685 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11686         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11687         JNIEnv *env;
11688         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11689         if (get_jenv_res == JNI_EDETACHED) {
11690                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11691         } else {
11692                 DO_ASSERT(get_jenv_res == JNI_OK);
11693         }
11694         LDKOutPoint channel_id_var = channel_id;
11695         int64_t channel_id_ref = 0;
11696         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11697         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11698         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11699         channel_id_ref = (uintptr_t)channel_id_var.inner;
11700         if (channel_id_var.is_owned) {
11701                 channel_id_ref |= 1;
11702         }
11703         LDKChannelMonitor data_var = *data;
11704         int64_t data_ref = 0;
11705         data_var = ChannelMonitor_clone(&data_var);
11706         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11707         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11708         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11709         data_ref = (uintptr_t)data_var.inner;
11710         if (data_var.is_owned) {
11711                 data_ref |= 1;
11712         }
11713         LDKMonitorUpdateId update_id_var = update_id;
11714         int64_t update_id_ref = 0;
11715         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11716         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11717         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11718         update_id_ref = (uintptr_t)update_id_var.inner;
11719         if (update_id_var.is_owned) {
11720                 update_id_ref |= 1;
11721         }
11722         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11723         CHECK(obj != NULL);
11724         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
11725         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11726                 (*env)->ExceptionDescribe(env);
11727                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
11728         }
11729         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11730         CHECK_ACCESS(ret_ptr);
11731         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
11732         FREE((void*)ret);
11733         if (get_jenv_res == JNI_EDETACHED) {
11734                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11735         }
11736         return ret_conv;
11737 }
11738 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11739         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11740         JNIEnv *env;
11741         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11742         if (get_jenv_res == JNI_EDETACHED) {
11743                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11744         } else {
11745                 DO_ASSERT(get_jenv_res == JNI_OK);
11746         }
11747         LDKOutPoint channel_id_var = channel_id;
11748         int64_t channel_id_ref = 0;
11749         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11750         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11751         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11752         channel_id_ref = (uintptr_t)channel_id_var.inner;
11753         if (channel_id_var.is_owned) {
11754                 channel_id_ref |= 1;
11755         }
11756         LDKChannelMonitorUpdate update_var = *update;
11757         int64_t update_ref = 0;
11758         if ((uintptr_t)update_var.inner > 4096) {
11759                 update_var = ChannelMonitorUpdate_clone(&update_var);
11760                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11761                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11762         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
11763                 update_ref = (uintptr_t)update_var.inner;
11764                 if (update_var.is_owned) {
11765                         update_ref |= 1;
11766                 }
11767         }
11768         LDKChannelMonitor data_var = *data;
11769         int64_t data_ref = 0;
11770         data_var = ChannelMonitor_clone(&data_var);
11771         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11772         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11773         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11774         data_ref = (uintptr_t)data_var.inner;
11775         if (data_var.is_owned) {
11776                 data_ref |= 1;
11777         }
11778         LDKMonitorUpdateId update_id_var = update_id;
11779         int64_t update_id_ref = 0;
11780         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11781         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11782         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11783         update_id_ref = (uintptr_t)update_id_var.inner;
11784         if (update_id_var.is_owned) {
11785                 update_id_ref |= 1;
11786         }
11787         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11788         CHECK(obj != NULL);
11789         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
11790         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11791                 (*env)->ExceptionDescribe(env);
11792                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
11793         }
11794         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11795         CHECK_ACCESS(ret_ptr);
11796         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
11797         FREE((void*)ret);
11798         if (get_jenv_res == JNI_EDETACHED) {
11799                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11800         }
11801         return ret_conv;
11802 }
11803 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
11804         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
11805         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11806 }
11807 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
11808         jclass c = (*env)->GetObjectClass(env, o);
11809         CHECK(c != NULL);
11810         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
11811         atomic_init(&calls->refcnt, 1);
11812         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11813         calls->o = (*env)->NewWeakGlobalRef(env, o);
11814         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
11815         CHECK(calls->persist_new_channel_meth != NULL);
11816         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
11817         CHECK(calls->update_persisted_channel_meth != NULL);
11818
11819         LDKPersist ret = {
11820                 .this_arg = (void*) calls,
11821                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
11822                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
11823                 .free = LDKPersist_JCalls_free,
11824         };
11825         return ret;
11826 }
11827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
11828         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
11829         *res_ptr = LDKPersist_init(env, clz, o);
11830         return (uint64_t)res_ptr;
11831 }
11832 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) {
11833         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11834         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11835         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11836         LDKOutPoint channel_id_conv;
11837         channel_id_conv.inner = (void*)(channel_id & (~1));
11838         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
11839         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11840         channel_id_conv = OutPoint_clone(&channel_id_conv);
11841         LDKChannelMonitor data_conv;
11842         data_conv.inner = (void*)(data & (~1));
11843         data_conv.is_owned = false;
11844         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11845         LDKMonitorUpdateId update_id_conv;
11846         update_id_conv.inner = (void*)(update_id & (~1));
11847         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
11848         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11849         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11850         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11851         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
11852         return (int64_t)ret_conv;
11853 }
11854
11855 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) {
11856         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11857         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11858         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11859         LDKOutPoint channel_id_conv;
11860         channel_id_conv.inner = (void*)(channel_id & (~1));
11861         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
11862         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11863         channel_id_conv = OutPoint_clone(&channel_id_conv);
11864         LDKChannelMonitorUpdate update_conv;
11865         update_conv.inner = (void*)(update & (~1));
11866         update_conv.is_owned = false;
11867         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
11868         LDKChannelMonitor data_conv;
11869         data_conv.inner = (void*)(data & (~1));
11870         data_conv.is_owned = false;
11871         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11872         LDKMonitorUpdateId update_id_conv;
11873         update_id_conv.inner = (void*)(update_id & (~1));
11874         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
11875         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11876         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11877         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11878         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
11879         return (int64_t)ret_conv;
11880 }
11881
11882 typedef struct LDKChannelMessageHandler_JCalls {
11883         atomic_size_t refcnt;
11884         JavaVM *vm;
11885         jweak o;
11886         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
11887         jmethodID handle_open_channel_meth;
11888         jmethodID handle_accept_channel_meth;
11889         jmethodID handle_funding_created_meth;
11890         jmethodID handle_funding_signed_meth;
11891         jmethodID handle_channel_ready_meth;
11892         jmethodID handle_shutdown_meth;
11893         jmethodID handle_closing_signed_meth;
11894         jmethodID handle_update_add_htlc_meth;
11895         jmethodID handle_update_fulfill_htlc_meth;
11896         jmethodID handle_update_fail_htlc_meth;
11897         jmethodID handle_update_fail_malformed_htlc_meth;
11898         jmethodID handle_commitment_signed_meth;
11899         jmethodID handle_revoke_and_ack_meth;
11900         jmethodID handle_update_fee_meth;
11901         jmethodID handle_announcement_signatures_meth;
11902         jmethodID peer_disconnected_meth;
11903         jmethodID peer_connected_meth;
11904         jmethodID handle_channel_reestablish_meth;
11905         jmethodID handle_channel_update_meth;
11906         jmethodID handle_error_meth;
11907 } LDKChannelMessageHandler_JCalls;
11908 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
11909         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11910         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11911                 JNIEnv *env;
11912                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11913                 if (get_jenv_res == JNI_EDETACHED) {
11914                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11915                 } else {
11916                         DO_ASSERT(get_jenv_res == JNI_OK);
11917                 }
11918                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11919                 if (get_jenv_res == JNI_EDETACHED) {
11920                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11921                 }
11922                 FREE(j_calls);
11923         }
11924 }
11925 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
11926         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11927         JNIEnv *env;
11928         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11929         if (get_jenv_res == JNI_EDETACHED) {
11930                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11931         } else {
11932                 DO_ASSERT(get_jenv_res == JNI_OK);
11933         }
11934         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11935         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11936         LDKInitFeatures their_features_var = their_features;
11937         int64_t their_features_ref = 0;
11938         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11939         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11940         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11941         their_features_ref = (uintptr_t)their_features_var.inner;
11942         if (their_features_var.is_owned) {
11943                 their_features_ref |= 1;
11944         }
11945         LDKOpenChannel msg_var = *msg;
11946         int64_t msg_ref = 0;
11947         msg_var = OpenChannel_clone(&msg_var);
11948         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11949         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11950         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11951         msg_ref = (uintptr_t)msg_var.inner;
11952         if (msg_var.is_owned) {
11953                 msg_ref |= 1;
11954         }
11955         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11956         CHECK(obj != NULL);
11957         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11958         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11959                 (*env)->ExceptionDescribe(env);
11960                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
11961         }
11962         if (get_jenv_res == JNI_EDETACHED) {
11963                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11964         }
11965 }
11966 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
11967         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11968         JNIEnv *env;
11969         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11970         if (get_jenv_res == JNI_EDETACHED) {
11971                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11972         } else {
11973                 DO_ASSERT(get_jenv_res == JNI_OK);
11974         }
11975         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11976         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11977         LDKInitFeatures their_features_var = their_features;
11978         int64_t their_features_ref = 0;
11979         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11980         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11981         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11982         their_features_ref = (uintptr_t)their_features_var.inner;
11983         if (their_features_var.is_owned) {
11984                 their_features_ref |= 1;
11985         }
11986         LDKAcceptChannel msg_var = *msg;
11987         int64_t msg_ref = 0;
11988         msg_var = AcceptChannel_clone(&msg_var);
11989         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11990         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11991         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11992         msg_ref = (uintptr_t)msg_var.inner;
11993         if (msg_var.is_owned) {
11994                 msg_ref |= 1;
11995         }
11996         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11997         CHECK(obj != NULL);
11998         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11999         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12000                 (*env)->ExceptionDescribe(env);
12001                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
12002         }
12003         if (get_jenv_res == JNI_EDETACHED) {
12004                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12005         }
12006 }
12007 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
12008         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12009         JNIEnv *env;
12010         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12011         if (get_jenv_res == JNI_EDETACHED) {
12012                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12013         } else {
12014                 DO_ASSERT(get_jenv_res == JNI_OK);
12015         }
12016         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12017         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12018         LDKFundingCreated msg_var = *msg;
12019         int64_t msg_ref = 0;
12020         msg_var = FundingCreated_clone(&msg_var);
12021         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12022         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12023         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12024         msg_ref = (uintptr_t)msg_var.inner;
12025         if (msg_var.is_owned) {
12026                 msg_ref |= 1;
12027         }
12028         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12029         CHECK(obj != NULL);
12030         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
12031         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12032                 (*env)->ExceptionDescribe(env);
12033                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
12034         }
12035         if (get_jenv_res == JNI_EDETACHED) {
12036                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12037         }
12038 }
12039 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
12040         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12041         JNIEnv *env;
12042         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12043         if (get_jenv_res == JNI_EDETACHED) {
12044                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12045         } else {
12046                 DO_ASSERT(get_jenv_res == JNI_OK);
12047         }
12048         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12049         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12050         LDKFundingSigned msg_var = *msg;
12051         int64_t msg_ref = 0;
12052         msg_var = FundingSigned_clone(&msg_var);
12053         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12054         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12055         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12056         msg_ref = (uintptr_t)msg_var.inner;
12057         if (msg_var.is_owned) {
12058                 msg_ref |= 1;
12059         }
12060         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12061         CHECK(obj != NULL);
12062         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
12063         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12064                 (*env)->ExceptionDescribe(env);
12065                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
12066         }
12067         if (get_jenv_res == JNI_EDETACHED) {
12068                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12069         }
12070 }
12071 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
12072         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12073         JNIEnv *env;
12074         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12075         if (get_jenv_res == JNI_EDETACHED) {
12076                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12077         } else {
12078                 DO_ASSERT(get_jenv_res == JNI_OK);
12079         }
12080         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12081         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12082         LDKChannelReady msg_var = *msg;
12083         int64_t msg_ref = 0;
12084         msg_var = ChannelReady_clone(&msg_var);
12085         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12086         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12087         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12088         msg_ref = (uintptr_t)msg_var.inner;
12089         if (msg_var.is_owned) {
12090                 msg_ref |= 1;
12091         }
12092         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12093         CHECK(obj != NULL);
12094         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_ready_meth, their_node_id_arr, msg_ref);
12095         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12096                 (*env)->ExceptionDescribe(env);
12097                 (*env)->FatalError(env, "A call to handle_channel_ready in LDKChannelMessageHandler from rust threw an exception.");
12098         }
12099         if (get_jenv_res == JNI_EDETACHED) {
12100                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12101         }
12102 }
12103 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
12104         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12105         JNIEnv *env;
12106         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12107         if (get_jenv_res == JNI_EDETACHED) {
12108                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12109         } else {
12110                 DO_ASSERT(get_jenv_res == JNI_OK);
12111         }
12112         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12113         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12114         LDKInitFeatures their_features_var = *their_features;
12115         int64_t their_features_ref = 0;
12116         their_features_var = InitFeatures_clone(&their_features_var);
12117         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12118         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12119         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
12120         their_features_ref = (uintptr_t)their_features_var.inner;
12121         if (their_features_var.is_owned) {
12122                 their_features_ref |= 1;
12123         }
12124         LDKShutdown msg_var = *msg;
12125         int64_t msg_ref = 0;
12126         msg_var = Shutdown_clone(&msg_var);
12127         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12128         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12129         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12130         msg_ref = (uintptr_t)msg_var.inner;
12131         if (msg_var.is_owned) {
12132                 msg_ref |= 1;
12133         }
12134         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12135         CHECK(obj != NULL);
12136         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
12137         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12138                 (*env)->ExceptionDescribe(env);
12139                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
12140         }
12141         if (get_jenv_res == JNI_EDETACHED) {
12142                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12143         }
12144 }
12145 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
12146         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12147         JNIEnv *env;
12148         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12149         if (get_jenv_res == JNI_EDETACHED) {
12150                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12151         } else {
12152                 DO_ASSERT(get_jenv_res == JNI_OK);
12153         }
12154         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12155         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12156         LDKClosingSigned msg_var = *msg;
12157         int64_t msg_ref = 0;
12158         msg_var = ClosingSigned_clone(&msg_var);
12159         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12160         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12161         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12162         msg_ref = (uintptr_t)msg_var.inner;
12163         if (msg_var.is_owned) {
12164                 msg_ref |= 1;
12165         }
12166         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12167         CHECK(obj != NULL);
12168         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
12169         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12170                 (*env)->ExceptionDescribe(env);
12171                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
12172         }
12173         if (get_jenv_res == JNI_EDETACHED) {
12174                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12175         }
12176 }
12177 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
12178         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12179         JNIEnv *env;
12180         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12181         if (get_jenv_res == JNI_EDETACHED) {
12182                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12183         } else {
12184                 DO_ASSERT(get_jenv_res == JNI_OK);
12185         }
12186         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12187         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12188         LDKUpdateAddHTLC msg_var = *msg;
12189         int64_t msg_ref = 0;
12190         msg_var = UpdateAddHTLC_clone(&msg_var);
12191         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12192         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12193         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12194         msg_ref = (uintptr_t)msg_var.inner;
12195         if (msg_var.is_owned) {
12196                 msg_ref |= 1;
12197         }
12198         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12199         CHECK(obj != NULL);
12200         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
12201         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12202                 (*env)->ExceptionDescribe(env);
12203                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
12204         }
12205         if (get_jenv_res == JNI_EDETACHED) {
12206                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12207         }
12208 }
12209 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
12210         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12211         JNIEnv *env;
12212         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12213         if (get_jenv_res == JNI_EDETACHED) {
12214                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12215         } else {
12216                 DO_ASSERT(get_jenv_res == JNI_OK);
12217         }
12218         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12219         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12220         LDKUpdateFulfillHTLC msg_var = *msg;
12221         int64_t msg_ref = 0;
12222         msg_var = UpdateFulfillHTLC_clone(&msg_var);
12223         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12224         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12225         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12226         msg_ref = (uintptr_t)msg_var.inner;
12227         if (msg_var.is_owned) {
12228                 msg_ref |= 1;
12229         }
12230         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12231         CHECK(obj != NULL);
12232         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
12233         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12234                 (*env)->ExceptionDescribe(env);
12235                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
12236         }
12237         if (get_jenv_res == JNI_EDETACHED) {
12238                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12239         }
12240 }
12241 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
12242         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12243         JNIEnv *env;
12244         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12245         if (get_jenv_res == JNI_EDETACHED) {
12246                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12247         } else {
12248                 DO_ASSERT(get_jenv_res == JNI_OK);
12249         }
12250         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12251         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12252         LDKUpdateFailHTLC msg_var = *msg;
12253         int64_t msg_ref = 0;
12254         msg_var = UpdateFailHTLC_clone(&msg_var);
12255         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12256         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12257         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12258         msg_ref = (uintptr_t)msg_var.inner;
12259         if (msg_var.is_owned) {
12260                 msg_ref |= 1;
12261         }
12262         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12263         CHECK(obj != NULL);
12264         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
12265         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12266                 (*env)->ExceptionDescribe(env);
12267                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
12268         }
12269         if (get_jenv_res == JNI_EDETACHED) {
12270                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12271         }
12272 }
12273 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
12274         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12275         JNIEnv *env;
12276         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12277         if (get_jenv_res == JNI_EDETACHED) {
12278                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12279         } else {
12280                 DO_ASSERT(get_jenv_res == JNI_OK);
12281         }
12282         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12283         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12284         LDKUpdateFailMalformedHTLC msg_var = *msg;
12285         int64_t msg_ref = 0;
12286         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
12287         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12288         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12289         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12290         msg_ref = (uintptr_t)msg_var.inner;
12291         if (msg_var.is_owned) {
12292                 msg_ref |= 1;
12293         }
12294         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12295         CHECK(obj != NULL);
12296         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
12297         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12298                 (*env)->ExceptionDescribe(env);
12299                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
12300         }
12301         if (get_jenv_res == JNI_EDETACHED) {
12302                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12303         }
12304 }
12305 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
12306         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12307         JNIEnv *env;
12308         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12309         if (get_jenv_res == JNI_EDETACHED) {
12310                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12311         } else {
12312                 DO_ASSERT(get_jenv_res == JNI_OK);
12313         }
12314         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12315         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12316         LDKCommitmentSigned msg_var = *msg;
12317         int64_t msg_ref = 0;
12318         msg_var = CommitmentSigned_clone(&msg_var);
12319         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12320         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12321         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12322         msg_ref = (uintptr_t)msg_var.inner;
12323         if (msg_var.is_owned) {
12324                 msg_ref |= 1;
12325         }
12326         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12327         CHECK(obj != NULL);
12328         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
12329         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12330                 (*env)->ExceptionDescribe(env);
12331                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
12332         }
12333         if (get_jenv_res == JNI_EDETACHED) {
12334                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12335         }
12336 }
12337 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
12338         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12339         JNIEnv *env;
12340         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12341         if (get_jenv_res == JNI_EDETACHED) {
12342                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12343         } else {
12344                 DO_ASSERT(get_jenv_res == JNI_OK);
12345         }
12346         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12347         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12348         LDKRevokeAndACK msg_var = *msg;
12349         int64_t msg_ref = 0;
12350         msg_var = RevokeAndACK_clone(&msg_var);
12351         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12352         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12353         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12354         msg_ref = (uintptr_t)msg_var.inner;
12355         if (msg_var.is_owned) {
12356                 msg_ref |= 1;
12357         }
12358         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12359         CHECK(obj != NULL);
12360         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
12361         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12362                 (*env)->ExceptionDescribe(env);
12363                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
12364         }
12365         if (get_jenv_res == JNI_EDETACHED) {
12366                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12367         }
12368 }
12369 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
12370         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12371         JNIEnv *env;
12372         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12373         if (get_jenv_res == JNI_EDETACHED) {
12374                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12375         } else {
12376                 DO_ASSERT(get_jenv_res == JNI_OK);
12377         }
12378         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12379         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12380         LDKUpdateFee msg_var = *msg;
12381         int64_t msg_ref = 0;
12382         msg_var = UpdateFee_clone(&msg_var);
12383         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12384         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12385         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12386         msg_ref = (uintptr_t)msg_var.inner;
12387         if (msg_var.is_owned) {
12388                 msg_ref |= 1;
12389         }
12390         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12391         CHECK(obj != NULL);
12392         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
12393         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12394                 (*env)->ExceptionDescribe(env);
12395                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
12396         }
12397         if (get_jenv_res == JNI_EDETACHED) {
12398                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12399         }
12400 }
12401 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
12402         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12403         JNIEnv *env;
12404         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12405         if (get_jenv_res == JNI_EDETACHED) {
12406                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12407         } else {
12408                 DO_ASSERT(get_jenv_res == JNI_OK);
12409         }
12410         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12411         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12412         LDKAnnouncementSignatures msg_var = *msg;
12413         int64_t msg_ref = 0;
12414         msg_var = AnnouncementSignatures_clone(&msg_var);
12415         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12416         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12417         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12418         msg_ref = (uintptr_t)msg_var.inner;
12419         if (msg_var.is_owned) {
12420                 msg_ref |= 1;
12421         }
12422         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12423         CHECK(obj != NULL);
12424         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
12425         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12426                 (*env)->ExceptionDescribe(env);
12427                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
12428         }
12429         if (get_jenv_res == JNI_EDETACHED) {
12430                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12431         }
12432 }
12433 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
12434         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12435         JNIEnv *env;
12436         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12437         if (get_jenv_res == JNI_EDETACHED) {
12438                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12439         } else {
12440                 DO_ASSERT(get_jenv_res == JNI_OK);
12441         }
12442         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12443         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12444         jboolean no_connection_possible_conv = no_connection_possible;
12445         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12446         CHECK(obj != NULL);
12447         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
12448         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12449                 (*env)->ExceptionDescribe(env);
12450                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
12451         }
12452         if (get_jenv_res == JNI_EDETACHED) {
12453                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12454         }
12455 }
12456 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
12457         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12458         JNIEnv *env;
12459         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12460         if (get_jenv_res == JNI_EDETACHED) {
12461                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12462         } else {
12463                 DO_ASSERT(get_jenv_res == JNI_OK);
12464         }
12465         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12466         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12467         LDKInit msg_var = *msg;
12468         int64_t msg_ref = 0;
12469         msg_var = Init_clone(&msg_var);
12470         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12471         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12472         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12473         msg_ref = (uintptr_t)msg_var.inner;
12474         if (msg_var.is_owned) {
12475                 msg_ref |= 1;
12476         }
12477         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12478         CHECK(obj != NULL);
12479         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
12480         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12481                 (*env)->ExceptionDescribe(env);
12482                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
12483         }
12484         if (get_jenv_res == JNI_EDETACHED) {
12485                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12486         }
12487 }
12488 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
12489         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12490         JNIEnv *env;
12491         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12492         if (get_jenv_res == JNI_EDETACHED) {
12493                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12494         } else {
12495                 DO_ASSERT(get_jenv_res == JNI_OK);
12496         }
12497         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12498         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12499         LDKChannelReestablish msg_var = *msg;
12500         int64_t msg_ref = 0;
12501         msg_var = ChannelReestablish_clone(&msg_var);
12502         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12503         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12504         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12505         msg_ref = (uintptr_t)msg_var.inner;
12506         if (msg_var.is_owned) {
12507                 msg_ref |= 1;
12508         }
12509         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12510         CHECK(obj != NULL);
12511         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
12512         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12513                 (*env)->ExceptionDescribe(env);
12514                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
12515         }
12516         if (get_jenv_res == JNI_EDETACHED) {
12517                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12518         }
12519 }
12520 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
12521         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12522         JNIEnv *env;
12523         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12524         if (get_jenv_res == JNI_EDETACHED) {
12525                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12526         } else {
12527                 DO_ASSERT(get_jenv_res == JNI_OK);
12528         }
12529         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12530         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12531         LDKChannelUpdate msg_var = *msg;
12532         int64_t msg_ref = 0;
12533         msg_var = ChannelUpdate_clone(&msg_var);
12534         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12535         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12536         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12537         msg_ref = (uintptr_t)msg_var.inner;
12538         if (msg_var.is_owned) {
12539                 msg_ref |= 1;
12540         }
12541         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12542         CHECK(obj != NULL);
12543         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
12544         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12545                 (*env)->ExceptionDescribe(env);
12546                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
12547         }
12548         if (get_jenv_res == JNI_EDETACHED) {
12549                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12550         }
12551 }
12552 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
12553         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12554         JNIEnv *env;
12555         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12556         if (get_jenv_res == JNI_EDETACHED) {
12557                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12558         } else {
12559                 DO_ASSERT(get_jenv_res == JNI_OK);
12560         }
12561         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12562         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12563         LDKErrorMessage msg_var = *msg;
12564         int64_t msg_ref = 0;
12565         msg_var = ErrorMessage_clone(&msg_var);
12566         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12567         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12568         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12569         msg_ref = (uintptr_t)msg_var.inner;
12570         if (msg_var.is_owned) {
12571                 msg_ref |= 1;
12572         }
12573         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12574         CHECK(obj != NULL);
12575         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
12576         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12577                 (*env)->ExceptionDescribe(env);
12578                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
12579         }
12580         if (get_jenv_res == JNI_EDETACHED) {
12581                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12582         }
12583 }
12584 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
12585         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
12586         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12587         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
12588 }
12589 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12590         jclass c = (*env)->GetObjectClass(env, o);
12591         CHECK(c != NULL);
12592         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
12593         atomic_init(&calls->refcnt, 1);
12594         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12595         calls->o = (*env)->NewWeakGlobalRef(env, o);
12596         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
12597         CHECK(calls->handle_open_channel_meth != NULL);
12598         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
12599         CHECK(calls->handle_accept_channel_meth != NULL);
12600         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
12601         CHECK(calls->handle_funding_created_meth != NULL);
12602         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
12603         CHECK(calls->handle_funding_signed_meth != NULL);
12604         calls->handle_channel_ready_meth = (*env)->GetMethodID(env, c, "handle_channel_ready", "([BJ)V");
12605         CHECK(calls->handle_channel_ready_meth != NULL);
12606         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
12607         CHECK(calls->handle_shutdown_meth != NULL);
12608         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
12609         CHECK(calls->handle_closing_signed_meth != NULL);
12610         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
12611         CHECK(calls->handle_update_add_htlc_meth != NULL);
12612         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
12613         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
12614         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
12615         CHECK(calls->handle_update_fail_htlc_meth != NULL);
12616         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
12617         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
12618         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
12619         CHECK(calls->handle_commitment_signed_meth != NULL);
12620         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
12621         CHECK(calls->handle_revoke_and_ack_meth != NULL);
12622         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
12623         CHECK(calls->handle_update_fee_meth != NULL);
12624         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
12625         CHECK(calls->handle_announcement_signatures_meth != NULL);
12626         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
12627         CHECK(calls->peer_disconnected_meth != NULL);
12628         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
12629         CHECK(calls->peer_connected_meth != NULL);
12630         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
12631         CHECK(calls->handle_channel_reestablish_meth != NULL);
12632         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
12633         CHECK(calls->handle_channel_update_meth != NULL);
12634         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
12635         CHECK(calls->handle_error_meth != NULL);
12636
12637         LDKChannelMessageHandler ret = {
12638                 .this_arg = (void*) calls,
12639                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
12640                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
12641                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
12642                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
12643                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
12644                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
12645                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
12646                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
12647                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
12648                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
12649                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
12650                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
12651                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
12652                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
12653                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
12654                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
12655                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
12656                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
12657                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
12658                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
12659                 .free = LDKChannelMessageHandler_JCalls_free,
12660                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
12661         };
12662         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
12663         return ret;
12664 }
12665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12666         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
12667         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
12668         return (uint64_t)res_ptr;
12669 }
12670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
12671         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
12672         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
12673         DO_ASSERT((res_ptr & 1) == 0);
12674         return (int64_t)(res_ptr | 1);
12675 }
12676 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) {
12677         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12678         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12679         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12680         LDKPublicKey their_node_id_ref;
12681         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12682         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12683         LDKInitFeatures their_features_conv;
12684         their_features_conv.inner = (void*)(their_features & (~1));
12685         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
12686         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12687         their_features_conv = InitFeatures_clone(&their_features_conv);
12688         LDKOpenChannel msg_conv;
12689         msg_conv.inner = (void*)(msg & (~1));
12690         msg_conv.is_owned = false;
12691         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12692         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12693 }
12694
12695 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) {
12696         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12697         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12698         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12699         LDKPublicKey their_node_id_ref;
12700         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12701         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12702         LDKInitFeatures their_features_conv;
12703         their_features_conv.inner = (void*)(their_features & (~1));
12704         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
12705         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12706         their_features_conv = InitFeatures_clone(&their_features_conv);
12707         LDKAcceptChannel msg_conv;
12708         msg_conv.inner = (void*)(msg & (~1));
12709         msg_conv.is_owned = false;
12710         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12711         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12712 }
12713
12714 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) {
12715         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12716         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12717         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12718         LDKPublicKey their_node_id_ref;
12719         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12720         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12721         LDKFundingCreated msg_conv;
12722         msg_conv.inner = (void*)(msg & (~1));
12723         msg_conv.is_owned = false;
12724         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12725         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12726 }
12727
12728 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) {
12729         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12730         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12731         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12732         LDKPublicKey their_node_id_ref;
12733         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12734         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12735         LDKFundingSigned msg_conv;
12736         msg_conv.inner = (void*)(msg & (~1));
12737         msg_conv.is_owned = false;
12738         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12739         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12740 }
12741
12742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12743         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12744         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12745         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12746         LDKPublicKey their_node_id_ref;
12747         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12748         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12749         LDKChannelReady msg_conv;
12750         msg_conv.inner = (void*)(msg & (~1));
12751         msg_conv.is_owned = false;
12752         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12753         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12754 }
12755
12756 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) {
12757         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12758         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12759         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12760         LDKPublicKey their_node_id_ref;
12761         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12762         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12763         LDKInitFeatures their_features_conv;
12764         their_features_conv.inner = (void*)(their_features & (~1));
12765         their_features_conv.is_owned = false;
12766         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12767         LDKShutdown msg_conv;
12768         msg_conv.inner = (void*)(msg & (~1));
12769         msg_conv.is_owned = false;
12770         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12771         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
12772 }
12773
12774 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) {
12775         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12776         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12777         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12778         LDKPublicKey their_node_id_ref;
12779         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12780         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12781         LDKClosingSigned msg_conv;
12782         msg_conv.inner = (void*)(msg & (~1));
12783         msg_conv.is_owned = false;
12784         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12785         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12786 }
12787
12788 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) {
12789         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12790         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12791         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12792         LDKPublicKey their_node_id_ref;
12793         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12794         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12795         LDKUpdateAddHTLC msg_conv;
12796         msg_conv.inner = (void*)(msg & (~1));
12797         msg_conv.is_owned = false;
12798         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12799         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12800 }
12801
12802 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) {
12803         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12804         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12805         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12806         LDKPublicKey their_node_id_ref;
12807         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12808         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12809         LDKUpdateFulfillHTLC msg_conv;
12810         msg_conv.inner = (void*)(msg & (~1));
12811         msg_conv.is_owned = false;
12812         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12813         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12814 }
12815
12816 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) {
12817         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12818         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12819         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12820         LDKPublicKey their_node_id_ref;
12821         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12822         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12823         LDKUpdateFailHTLC msg_conv;
12824         msg_conv.inner = (void*)(msg & (~1));
12825         msg_conv.is_owned = false;
12826         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12827         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12828 }
12829
12830 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) {
12831         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12832         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12833         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12834         LDKPublicKey their_node_id_ref;
12835         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12836         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12837         LDKUpdateFailMalformedHTLC msg_conv;
12838         msg_conv.inner = (void*)(msg & (~1));
12839         msg_conv.is_owned = false;
12840         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12841         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12842 }
12843
12844 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) {
12845         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12846         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12847         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12848         LDKPublicKey their_node_id_ref;
12849         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12850         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12851         LDKCommitmentSigned msg_conv;
12852         msg_conv.inner = (void*)(msg & (~1));
12853         msg_conv.is_owned = false;
12854         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12855         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12856 }
12857
12858 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) {
12859         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12860         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12861         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12862         LDKPublicKey their_node_id_ref;
12863         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12864         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12865         LDKRevokeAndACK msg_conv;
12866         msg_conv.inner = (void*)(msg & (~1));
12867         msg_conv.is_owned = false;
12868         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12869         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12870 }
12871
12872 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) {
12873         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12874         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12875         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12876         LDKPublicKey their_node_id_ref;
12877         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12878         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12879         LDKUpdateFee msg_conv;
12880         msg_conv.inner = (void*)(msg & (~1));
12881         msg_conv.is_owned = false;
12882         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12883         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12884 }
12885
12886 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) {
12887         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12888         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12889         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12890         LDKPublicKey their_node_id_ref;
12891         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12892         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12893         LDKAnnouncementSignatures msg_conv;
12894         msg_conv.inner = (void*)(msg & (~1));
12895         msg_conv.is_owned = false;
12896         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12897         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12898 }
12899
12900 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) {
12901         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12902         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12903         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12904         LDKPublicKey their_node_id_ref;
12905         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12906         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12907         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
12908 }
12909
12910 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) {
12911         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12912         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12913         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12914         LDKPublicKey their_node_id_ref;
12915         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12916         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12917         LDKInit msg_conv;
12918         msg_conv.inner = (void*)(msg & (~1));
12919         msg_conv.is_owned = false;
12920         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12921         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12922 }
12923
12924 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) {
12925         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12926         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12927         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12928         LDKPublicKey their_node_id_ref;
12929         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12930         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12931         LDKChannelReestablish msg_conv;
12932         msg_conv.inner = (void*)(msg & (~1));
12933         msg_conv.is_owned = false;
12934         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12935         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12936 }
12937
12938 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) {
12939         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12940         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12941         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12942         LDKPublicKey their_node_id_ref;
12943         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12944         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12945         LDKChannelUpdate msg_conv;
12946         msg_conv.inner = (void*)(msg & (~1));
12947         msg_conv.is_owned = false;
12948         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12949         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12950 }
12951
12952 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) {
12953         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12954         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12955         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12956         LDKPublicKey their_node_id_ref;
12957         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12958         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12959         LDKErrorMessage msg_conv;
12960         msg_conv.inner = (void*)(msg & (~1));
12961         msg_conv.is_owned = false;
12962         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12963         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12964 }
12965
12966 typedef struct LDKRoutingMessageHandler_JCalls {
12967         atomic_size_t refcnt;
12968         JavaVM *vm;
12969         jweak o;
12970         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
12971         jmethodID handle_node_announcement_meth;
12972         jmethodID handle_channel_announcement_meth;
12973         jmethodID handle_channel_update_meth;
12974         jmethodID get_next_channel_announcements_meth;
12975         jmethodID get_next_node_announcements_meth;
12976         jmethodID peer_connected_meth;
12977         jmethodID handle_reply_channel_range_meth;
12978         jmethodID handle_reply_short_channel_ids_end_meth;
12979         jmethodID handle_query_channel_range_meth;
12980         jmethodID handle_query_short_channel_ids_meth;
12981 } LDKRoutingMessageHandler_JCalls;
12982 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
12983         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12984         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12985                 JNIEnv *env;
12986                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12987                 if (get_jenv_res == JNI_EDETACHED) {
12988                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12989                 } else {
12990                         DO_ASSERT(get_jenv_res == JNI_OK);
12991                 }
12992                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12993                 if (get_jenv_res == JNI_EDETACHED) {
12994                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12995                 }
12996                 FREE(j_calls);
12997         }
12998 }
12999 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
13000         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13001         JNIEnv *env;
13002         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13003         if (get_jenv_res == JNI_EDETACHED) {
13004                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13005         } else {
13006                 DO_ASSERT(get_jenv_res == JNI_OK);
13007         }
13008         LDKNodeAnnouncement msg_var = *msg;
13009         int64_t msg_ref = 0;
13010         msg_var = NodeAnnouncement_clone(&msg_var);
13011         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13012         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13013         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13014         msg_ref = (uintptr_t)msg_var.inner;
13015         if (msg_var.is_owned) {
13016                 msg_ref |= 1;
13017         }
13018         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13019         CHECK(obj != NULL);
13020         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
13021         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13022                 (*env)->ExceptionDescribe(env);
13023                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13024         }
13025         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13026         CHECK_ACCESS(ret_ptr);
13027         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13028         FREE((void*)ret);
13029         if (get_jenv_res == JNI_EDETACHED) {
13030                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13031         }
13032         return ret_conv;
13033 }
13034 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
13035         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13036         JNIEnv *env;
13037         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13038         if (get_jenv_res == JNI_EDETACHED) {
13039                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13040         } else {
13041                 DO_ASSERT(get_jenv_res == JNI_OK);
13042         }
13043         LDKChannelAnnouncement msg_var = *msg;
13044         int64_t msg_ref = 0;
13045         msg_var = ChannelAnnouncement_clone(&msg_var);
13046         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13047         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13048         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13049         msg_ref = (uintptr_t)msg_var.inner;
13050         if (msg_var.is_owned) {
13051                 msg_ref |= 1;
13052         }
13053         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13054         CHECK(obj != NULL);
13055         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
13056         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13057                 (*env)->ExceptionDescribe(env);
13058                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13059         }
13060         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13061         CHECK_ACCESS(ret_ptr);
13062         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13063         FREE((void*)ret);
13064         if (get_jenv_res == JNI_EDETACHED) {
13065                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13066         }
13067         return ret_conv;
13068 }
13069 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
13070         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13071         JNIEnv *env;
13072         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13073         if (get_jenv_res == JNI_EDETACHED) {
13074                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13075         } else {
13076                 DO_ASSERT(get_jenv_res == JNI_OK);
13077         }
13078         LDKChannelUpdate msg_var = *msg;
13079         int64_t msg_ref = 0;
13080         msg_var = ChannelUpdate_clone(&msg_var);
13081         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13082         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13083         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13084         msg_ref = (uintptr_t)msg_var.inner;
13085         if (msg_var.is_owned) {
13086                 msg_ref |= 1;
13087         }
13088         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13089         CHECK(obj != NULL);
13090         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
13091         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13092                 (*env)->ExceptionDescribe(env);
13093                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
13094         }
13095         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13096         CHECK_ACCESS(ret_ptr);
13097         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13098         FREE((void*)ret);
13099         if (get_jenv_res == JNI_EDETACHED) {
13100                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13101         }
13102         return ret_conv;
13103 }
13104 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
13105         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13106         JNIEnv *env;
13107         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13108         if (get_jenv_res == JNI_EDETACHED) {
13109                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13110         } else {
13111                 DO_ASSERT(get_jenv_res == JNI_OK);
13112         }
13113         int64_t starting_point_conv = starting_point;
13114         int8_t batch_amount_conv = batch_amount;
13115         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13116         CHECK(obj != NULL);
13117         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point_conv, batch_amount_conv);
13118         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13119                 (*env)->ExceptionDescribe(env);
13120                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
13121         }
13122         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
13123         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13124         if (ret_constr.datalen > 0)
13125                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
13126         else
13127                 ret_constr.data = NULL;
13128         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13129         for (size_t h = 0; h < ret_constr.datalen; h++) {
13130                 int64_t ret_conv_59 = ret_vals[h];
13131                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
13132                 CHECK_ACCESS(ret_conv_59_ptr);
13133                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
13134                 FREE((void*)ret_conv_59);
13135                 ret_constr.data[h] = ret_conv_59_conv;
13136         }
13137         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13138         if (get_jenv_res == JNI_EDETACHED) {
13139                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13140         }
13141         return ret_constr;
13142 }
13143 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
13144         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13145         JNIEnv *env;
13146         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13147         if (get_jenv_res == JNI_EDETACHED) {
13148                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13149         } else {
13150                 DO_ASSERT(get_jenv_res == JNI_OK);
13151         }
13152         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
13153         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
13154         int8_t batch_amount_conv = batch_amount;
13155         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13156         CHECK(obj != NULL);
13157         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount_conv);
13158         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13159                 (*env)->ExceptionDescribe(env);
13160                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
13161         }
13162         LDKCVec_NodeAnnouncementZ ret_constr;
13163         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13164         if (ret_constr.datalen > 0)
13165                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
13166         else
13167                 ret_constr.data = NULL;
13168         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13169         for (size_t s = 0; s < ret_constr.datalen; s++) {
13170                 int64_t ret_conv_18 = ret_vals[s];
13171                 LDKNodeAnnouncement ret_conv_18_conv;
13172                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
13173                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
13174                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
13175                 ret_constr.data[s] = ret_conv_18_conv;
13176         }
13177         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13178         if (get_jenv_res == JNI_EDETACHED) {
13179                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13180         }
13181         return ret_constr;
13182 }
13183 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
13184         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13185         JNIEnv *env;
13186         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13187         if (get_jenv_res == JNI_EDETACHED) {
13188                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13189         } else {
13190                 DO_ASSERT(get_jenv_res == JNI_OK);
13191         }
13192         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13193         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13194         LDKInit init_var = *init;
13195         int64_t init_ref = 0;
13196         init_var = Init_clone(&init_var);
13197         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13198         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13199         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
13200         init_ref = (uintptr_t)init_var.inner;
13201         if (init_var.is_owned) {
13202                 init_ref |= 1;
13203         }
13204         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13205         CHECK(obj != NULL);
13206         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
13207         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13208                 (*env)->ExceptionDescribe(env);
13209                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler from rust threw an exception.");
13210         }
13211         if (get_jenv_res == JNI_EDETACHED) {
13212                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13213         }
13214 }
13215 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
13216         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13217         JNIEnv *env;
13218         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13219         if (get_jenv_res == JNI_EDETACHED) {
13220                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13221         } else {
13222                 DO_ASSERT(get_jenv_res == JNI_OK);
13223         }
13224         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13225         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13226         LDKReplyChannelRange msg_var = msg;
13227         int64_t msg_ref = 0;
13228         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13229         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13230         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13231         msg_ref = (uintptr_t)msg_var.inner;
13232         if (msg_var.is_owned) {
13233                 msg_ref |= 1;
13234         }
13235         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13236         CHECK(obj != NULL);
13237         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
13238         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13239                 (*env)->ExceptionDescribe(env);
13240                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
13241         }
13242         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13243         CHECK_ACCESS(ret_ptr);
13244         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13245         FREE((void*)ret);
13246         if (get_jenv_res == JNI_EDETACHED) {
13247                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13248         }
13249         return ret_conv;
13250 }
13251 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
13252         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13253         JNIEnv *env;
13254         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13255         if (get_jenv_res == JNI_EDETACHED) {
13256                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13257         } else {
13258                 DO_ASSERT(get_jenv_res == JNI_OK);
13259         }
13260         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13261         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13262         LDKReplyShortChannelIdsEnd msg_var = msg;
13263         int64_t msg_ref = 0;
13264         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13265         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13266         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13267         msg_ref = (uintptr_t)msg_var.inner;
13268         if (msg_var.is_owned) {
13269                 msg_ref |= 1;
13270         }
13271         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13272         CHECK(obj != NULL);
13273         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
13274         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13275                 (*env)->ExceptionDescribe(env);
13276                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
13277         }
13278         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13279         CHECK_ACCESS(ret_ptr);
13280         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13281         FREE((void*)ret);
13282         if (get_jenv_res == JNI_EDETACHED) {
13283                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13284         }
13285         return ret_conv;
13286 }
13287 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
13288         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13289         JNIEnv *env;
13290         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13291         if (get_jenv_res == JNI_EDETACHED) {
13292                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13293         } else {
13294                 DO_ASSERT(get_jenv_res == JNI_OK);
13295         }
13296         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13297         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13298         LDKQueryChannelRange msg_var = msg;
13299         int64_t msg_ref = 0;
13300         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13301         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13302         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13303         msg_ref = (uintptr_t)msg_var.inner;
13304         if (msg_var.is_owned) {
13305                 msg_ref |= 1;
13306         }
13307         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13308         CHECK(obj != NULL);
13309         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
13310         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13311                 (*env)->ExceptionDescribe(env);
13312                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
13313         }
13314         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13315         CHECK_ACCESS(ret_ptr);
13316         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13317         FREE((void*)ret);
13318         if (get_jenv_res == JNI_EDETACHED) {
13319                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13320         }
13321         return ret_conv;
13322 }
13323 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
13324         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13325         JNIEnv *env;
13326         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13327         if (get_jenv_res == JNI_EDETACHED) {
13328                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13329         } else {
13330                 DO_ASSERT(get_jenv_res == JNI_OK);
13331         }
13332         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13333         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13334         LDKQueryShortChannelIds msg_var = msg;
13335         int64_t msg_ref = 0;
13336         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13337         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13338         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13339         msg_ref = (uintptr_t)msg_var.inner;
13340         if (msg_var.is_owned) {
13341                 msg_ref |= 1;
13342         }
13343         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13344         CHECK(obj != NULL);
13345         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
13346         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13347                 (*env)->ExceptionDescribe(env);
13348                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
13349         }
13350         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13351         CHECK_ACCESS(ret_ptr);
13352         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13353         FREE((void*)ret);
13354         if (get_jenv_res == JNI_EDETACHED) {
13355                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13356         }
13357         return ret_conv;
13358 }
13359 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
13360         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
13361         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13362         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
13363 }
13364 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13365         jclass c = (*env)->GetObjectClass(env, o);
13366         CHECK(c != NULL);
13367         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
13368         atomic_init(&calls->refcnt, 1);
13369         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13370         calls->o = (*env)->NewWeakGlobalRef(env, o);
13371         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
13372         CHECK(calls->handle_node_announcement_meth != NULL);
13373         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
13374         CHECK(calls->handle_channel_announcement_meth != NULL);
13375         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
13376         CHECK(calls->handle_channel_update_meth != NULL);
13377         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
13378         CHECK(calls->get_next_channel_announcements_meth != NULL);
13379         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
13380         CHECK(calls->get_next_node_announcements_meth != NULL);
13381         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
13382         CHECK(calls->peer_connected_meth != NULL);
13383         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
13384         CHECK(calls->handle_reply_channel_range_meth != NULL);
13385         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
13386         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
13387         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
13388         CHECK(calls->handle_query_channel_range_meth != NULL);
13389         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
13390         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
13391
13392         LDKRoutingMessageHandler ret = {
13393                 .this_arg = (void*) calls,
13394                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
13395                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
13396                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
13397                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
13398                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
13399                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
13400                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
13401                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
13402                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
13403                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
13404                 .free = LDKRoutingMessageHandler_JCalls_free,
13405                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
13406         };
13407         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
13408         return ret;
13409 }
13410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13411         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
13412         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
13413         return (uint64_t)res_ptr;
13414 }
13415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
13416         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
13417         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
13418         DO_ASSERT((res_ptr & 1) == 0);
13419         return (int64_t)(res_ptr | 1);
13420 }
13421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13422         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13423         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13424         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13425         LDKNodeAnnouncement msg_conv;
13426         msg_conv.inner = (void*)(msg & (~1));
13427         msg_conv.is_owned = false;
13428         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13429         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13430         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
13431         return (int64_t)ret_conv;
13432 }
13433
13434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13435         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13436         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13437         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13438         LDKChannelAnnouncement msg_conv;
13439         msg_conv.inner = (void*)(msg & (~1));
13440         msg_conv.is_owned = false;
13441         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13442         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13443         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
13444         return (int64_t)ret_conv;
13445 }
13446
13447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13448         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13449         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13450         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13451         LDKChannelUpdate msg_conv;
13452         msg_conv.inner = (void*)(msg & (~1));
13453         msg_conv.is_owned = false;
13454         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13455         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13456         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
13457         return (int64_t)ret_conv;
13458 }
13459
13460 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) {
13461         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13462         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13463         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13464         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
13465         int64_tArray ret_arr = NULL;
13466         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13467         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13468         for (size_t h = 0; h < ret_var.datalen; h++) {
13469                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13470                 *ret_conv_59_conv = ret_var.data[h];
13471                 ret_arr_ptr[h] = ((int64_t)ret_conv_59_conv);
13472         }
13473         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13474         FREE(ret_var.data);
13475         return ret_arr;
13476 }
13477
13478 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) {
13479         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13480         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13481         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13482         LDKPublicKey starting_point_ref;
13483         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
13484         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
13485         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
13486         int64_tArray ret_arr = NULL;
13487         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13488         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13489         for (size_t s = 0; s < ret_var.datalen; s++) {
13490                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
13491                 int64_t ret_conv_18_ref = 0;
13492                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13493                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13494                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
13495                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
13496                 if (ret_conv_18_var.is_owned) {
13497                         ret_conv_18_ref |= 1;
13498                 }
13499                 ret_arr_ptr[s] = ret_conv_18_ref;
13500         }
13501         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13502         FREE(ret_var.data);
13503         return ret_arr;
13504 }
13505
13506 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) {
13507         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13508         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13509         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13510         LDKPublicKey their_node_id_ref;
13511         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13512         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13513         LDKInit init_conv;
13514         init_conv.inner = (void*)(init & (~1));
13515         init_conv.is_owned = false;
13516         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
13517         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
13518 }
13519
13520 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) {
13521         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13522         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13523         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13524         LDKPublicKey their_node_id_ref;
13525         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13526         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13527         LDKReplyChannelRange msg_conv;
13528         msg_conv.inner = (void*)(msg & (~1));
13529         msg_conv.is_owned = (msg & 1) || (msg == 0);
13530         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13531         msg_conv = ReplyChannelRange_clone(&msg_conv);
13532         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13533         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13534         return (int64_t)ret_conv;
13535 }
13536
13537 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) {
13538         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13539         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13540         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13541         LDKPublicKey their_node_id_ref;
13542         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13543         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13544         LDKReplyShortChannelIdsEnd msg_conv;
13545         msg_conv.inner = (void*)(msg & (~1));
13546         msg_conv.is_owned = (msg & 1) || (msg == 0);
13547         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13548         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
13549         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13550         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13551         return (int64_t)ret_conv;
13552 }
13553
13554 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) {
13555         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13556         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13557         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13558         LDKPublicKey their_node_id_ref;
13559         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13560         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13561         LDKQueryChannelRange msg_conv;
13562         msg_conv.inner = (void*)(msg & (~1));
13563         msg_conv.is_owned = (msg & 1) || (msg == 0);
13564         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13565         msg_conv = QueryChannelRange_clone(&msg_conv);
13566         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13567         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13568         return (int64_t)ret_conv;
13569 }
13570
13571 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) {
13572         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13573         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13574         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13575         LDKPublicKey their_node_id_ref;
13576         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13577         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13578         LDKQueryShortChannelIds msg_conv;
13579         msg_conv.inner = (void*)(msg & (~1));
13580         msg_conv.is_owned = (msg & 1) || (msg == 0);
13581         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13582         msg_conv = QueryShortChannelIds_clone(&msg_conv);
13583         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13584         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13585         return (int64_t)ret_conv;
13586 }
13587
13588 typedef struct LDKCustomMessageReader_JCalls {
13589         atomic_size_t refcnt;
13590         JavaVM *vm;
13591         jweak o;
13592         jmethodID read_meth;
13593 } LDKCustomMessageReader_JCalls;
13594 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
13595         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13596         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13597                 JNIEnv *env;
13598                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13599                 if (get_jenv_res == JNI_EDETACHED) {
13600                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13601                 } else {
13602                         DO_ASSERT(get_jenv_res == JNI_OK);
13603                 }
13604                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13605                 if (get_jenv_res == JNI_EDETACHED) {
13606                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13607                 }
13608                 FREE(j_calls);
13609         }
13610 }
13611 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
13612         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13613         JNIEnv *env;
13614         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13615         if (get_jenv_res == JNI_EDETACHED) {
13616                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13617         } else {
13618                 DO_ASSERT(get_jenv_res == JNI_OK);
13619         }
13620         int16_t message_type_conv = message_type;
13621         LDKu8slice buffer_var = buffer;
13622         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
13623         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
13624         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13625         CHECK(obj != NULL);
13626         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type_conv, buffer_arr);
13627         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13628                 (*env)->ExceptionDescribe(env);
13629                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
13630         }
13631         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13632         CHECK_ACCESS(ret_ptr);
13633         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
13634         FREE((void*)ret);
13635         if (get_jenv_res == JNI_EDETACHED) {
13636                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13637         }
13638         return ret_conv;
13639 }
13640 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
13641         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
13642         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13643 }
13644 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
13645         jclass c = (*env)->GetObjectClass(env, o);
13646         CHECK(c != NULL);
13647         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
13648         atomic_init(&calls->refcnt, 1);
13649         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13650         calls->o = (*env)->NewWeakGlobalRef(env, o);
13651         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
13652         CHECK(calls->read_meth != NULL);
13653
13654         LDKCustomMessageReader ret = {
13655                 .this_arg = (void*) calls,
13656                 .read = read_LDKCustomMessageReader_jcall,
13657                 .free = LDKCustomMessageReader_JCalls_free,
13658         };
13659         return ret;
13660 }
13661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
13662         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
13663         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
13664         return (uint64_t)res_ptr;
13665 }
13666 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) {
13667         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13668         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13669         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
13670         LDKu8slice buffer_ref;
13671         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
13672         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
13673         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
13674         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
13675         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
13676         return (int64_t)ret_conv;
13677 }
13678
13679 typedef struct LDKCustomMessageHandler_JCalls {
13680         atomic_size_t refcnt;
13681         JavaVM *vm;
13682         jweak o;
13683         LDKCustomMessageReader_JCalls* CustomMessageReader;
13684         jmethodID handle_custom_message_meth;
13685         jmethodID get_and_clear_pending_msg_meth;
13686 } LDKCustomMessageHandler_JCalls;
13687 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
13688         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13689         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13690                 JNIEnv *env;
13691                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13692                 if (get_jenv_res == JNI_EDETACHED) {
13693                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13694                 } else {
13695                         DO_ASSERT(get_jenv_res == JNI_OK);
13696                 }
13697                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13698                 if (get_jenv_res == JNI_EDETACHED) {
13699                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13700                 }
13701                 FREE(j_calls);
13702         }
13703 }
13704 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
13705         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13706         JNIEnv *env;
13707         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13708         if (get_jenv_res == JNI_EDETACHED) {
13709                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13710         } else {
13711                 DO_ASSERT(get_jenv_res == JNI_OK);
13712         }
13713         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
13714         *msg_ret = msg;
13715         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
13716         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
13717         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13718         CHECK(obj != NULL);
13719         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (int64_t)msg_ret, sender_node_id_arr);
13720         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13721                 (*env)->ExceptionDescribe(env);
13722                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
13723         }
13724         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13725         CHECK_ACCESS(ret_ptr);
13726         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13727         FREE((void*)ret);
13728         if (get_jenv_res == JNI_EDETACHED) {
13729                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13730         }
13731         return ret_conv;
13732 }
13733 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
13734         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13735         JNIEnv *env;
13736         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13737         if (get_jenv_res == JNI_EDETACHED) {
13738                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13739         } else {
13740                 DO_ASSERT(get_jenv_res == JNI_OK);
13741         }
13742         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13743         CHECK(obj != NULL);
13744         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
13745         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13746                 (*env)->ExceptionDescribe(env);
13747                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
13748         }
13749         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
13750         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13751         if (ret_constr.datalen > 0)
13752                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
13753         else
13754                 ret_constr.data = NULL;
13755         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13756         for (size_t z = 0; z < ret_constr.datalen; z++) {
13757                 int64_t ret_conv_25 = ret_vals[z];
13758                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
13759                 CHECK_ACCESS(ret_conv_25_ptr);
13760                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
13761                 FREE((void*)ret_conv_25);
13762                 ret_constr.data[z] = ret_conv_25_conv;
13763         }
13764         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13765         if (get_jenv_res == JNI_EDETACHED) {
13766                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13767         }
13768         return ret_constr;
13769 }
13770 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
13771         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
13772         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13773         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
13774 }
13775 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
13776         jclass c = (*env)->GetObjectClass(env, o);
13777         CHECK(c != NULL);
13778         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
13779         atomic_init(&calls->refcnt, 1);
13780         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13781         calls->o = (*env)->NewWeakGlobalRef(env, o);
13782         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
13783         CHECK(calls->handle_custom_message_meth != NULL);
13784         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
13785         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
13786
13787         LDKCustomMessageHandler ret = {
13788                 .this_arg = (void*) calls,
13789                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
13790                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
13791                 .free = LDKCustomMessageHandler_JCalls_free,
13792                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
13793         };
13794         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
13795         return ret;
13796 }
13797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
13798         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
13799         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
13800         return (uint64_t)res_ptr;
13801 }
13802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
13803         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
13804         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
13805         DO_ASSERT((res_ptr & 1) == 0);
13806         return (int64_t)(res_ptr | 1);
13807 }
13808 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) {
13809         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13810         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13811         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
13812         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
13813         CHECK_ACCESS(msg_ptr);
13814         LDKType msg_conv = *(LDKType*)(msg_ptr);
13815         if (msg_conv.free == LDKType_JCalls_free) {
13816                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13817                 LDKType_JCalls_cloned(&msg_conv);
13818         }
13819         LDKPublicKey sender_node_id_ref;
13820         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
13821         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
13822         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13823         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
13824         return (int64_t)ret_conv;
13825 }
13826
13827 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
13828         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13829         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13830         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
13831         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
13832         int64_tArray ret_arr = NULL;
13833         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13834         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13835         for (size_t z = 0; z < ret_var.datalen; z++) {
13836                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13837                 *ret_conv_25_conv = ret_var.data[z];
13838                 ret_arr_ptr[z] = ((int64_t)ret_conv_25_conv);
13839         }
13840         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13841         FREE(ret_var.data);
13842         return ret_arr;
13843 }
13844
13845 typedef struct LDKSocketDescriptor_JCalls {
13846         atomic_size_t refcnt;
13847         JavaVM *vm;
13848         jweak o;
13849         jmethodID send_data_meth;
13850         jmethodID disconnect_socket_meth;
13851         jmethodID eq_meth;
13852         jmethodID hash_meth;
13853 } LDKSocketDescriptor_JCalls;
13854 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
13855         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13856         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13857                 JNIEnv *env;
13858                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13859                 if (get_jenv_res == JNI_EDETACHED) {
13860                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13861                 } else {
13862                         DO_ASSERT(get_jenv_res == JNI_OK);
13863                 }
13864                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13865                 if (get_jenv_res == JNI_EDETACHED) {
13866                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13867                 }
13868                 FREE(j_calls);
13869         }
13870 }
13871 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
13872         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13873         JNIEnv *env;
13874         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13875         if (get_jenv_res == JNI_EDETACHED) {
13876                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13877         } else {
13878                 DO_ASSERT(get_jenv_res == JNI_OK);
13879         }
13880         LDKu8slice data_var = data;
13881         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
13882         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
13883         jboolean resume_read_conv = resume_read;
13884         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13885         CHECK(obj != NULL);
13886         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read_conv);
13887         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13888                 (*env)->ExceptionDescribe(env);
13889                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
13890         }
13891         if (get_jenv_res == JNI_EDETACHED) {
13892                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13893         }
13894         return ret;
13895 }
13896 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
13897         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13898         JNIEnv *env;
13899         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13900         if (get_jenv_res == JNI_EDETACHED) {
13901                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13902         } else {
13903                 DO_ASSERT(get_jenv_res == JNI_OK);
13904         }
13905         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13906         CHECK(obj != NULL);
13907         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
13908         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13909                 (*env)->ExceptionDescribe(env);
13910                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
13911         }
13912         if (get_jenv_res == JNI_EDETACHED) {
13913                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13914         }
13915 }
13916 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
13917         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13918         JNIEnv *env;
13919         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13920         if (get_jenv_res == JNI_EDETACHED) {
13921                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13922         } else {
13923                 DO_ASSERT(get_jenv_res == JNI_OK);
13924         }
13925         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
13926         *other_arg_clone = SocketDescriptor_clone(other_arg);
13927         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13928         CHECK(obj != NULL);
13929         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (int64_t)other_arg_clone);
13930         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13931                 (*env)->ExceptionDescribe(env);
13932                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
13933         }
13934         if (get_jenv_res == JNI_EDETACHED) {
13935                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13936         }
13937         return ret;
13938 }
13939 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
13940         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13941         JNIEnv *env;
13942         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13943         if (get_jenv_res == JNI_EDETACHED) {
13944                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13945         } else {
13946                 DO_ASSERT(get_jenv_res == JNI_OK);
13947         }
13948         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13949         CHECK(obj != NULL);
13950         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
13951         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13952                 (*env)->ExceptionDescribe(env);
13953                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
13954         }
13955         if (get_jenv_res == JNI_EDETACHED) {
13956                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13957         }
13958         return ret;
13959 }
13960 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
13961         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
13962         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13963 }
13964 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
13965         jclass c = (*env)->GetObjectClass(env, o);
13966         CHECK(c != NULL);
13967         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
13968         atomic_init(&calls->refcnt, 1);
13969         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13970         calls->o = (*env)->NewWeakGlobalRef(env, o);
13971         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
13972         CHECK(calls->send_data_meth != NULL);
13973         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
13974         CHECK(calls->disconnect_socket_meth != NULL);
13975         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
13976         CHECK(calls->eq_meth != NULL);
13977         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
13978         CHECK(calls->hash_meth != NULL);
13979
13980         LDKSocketDescriptor ret = {
13981                 .this_arg = (void*) calls,
13982                 .send_data = send_data_LDKSocketDescriptor_jcall,
13983                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
13984                 .eq = eq_LDKSocketDescriptor_jcall,
13985                 .hash = hash_LDKSocketDescriptor_jcall,
13986                 .cloned = LDKSocketDescriptor_JCalls_cloned,
13987                 .free = LDKSocketDescriptor_JCalls_free,
13988         };
13989         return ret;
13990 }
13991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
13992         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
13993         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
13994         return (uint64_t)res_ptr;
13995 }
13996 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) {
13997         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13998         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13999         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14000         LDKu8slice data_ref;
14001         data_ref.datalen = (*env)->GetArrayLength(env, data);
14002         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
14003         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
14004         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
14005         return ret_conv;
14006 }
14007
14008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
14009         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14010         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14011         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14012         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
14013 }
14014
14015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
14016         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14017         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14018         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14019         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
14020         return ret_conv;
14021 }
14022
14023 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
14024 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
14025 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
14026 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
14027 static jclass LDKEffectiveCapacity_Total_class = NULL;
14028 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
14029 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
14030 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
14031 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
14032 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
14033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
14034         LDKEffectiveCapacity_ExactLiquidity_class =
14035                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
14036         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
14037         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
14038         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
14039         LDKEffectiveCapacity_MaximumHTLC_class =
14040                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
14041         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
14042         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
14043         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
14044         LDKEffectiveCapacity_Total_class =
14045                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
14046         CHECK(LDKEffectiveCapacity_Total_class != NULL);
14047         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(JJ)V");
14048         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
14049         LDKEffectiveCapacity_Infinite_class =
14050                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
14051         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
14052         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
14053         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
14054         LDKEffectiveCapacity_Unknown_class =
14055                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
14056         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
14057         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
14058         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
14059 }
14060 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14061         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
14062         switch(obj->tag) {
14063                 case LDKEffectiveCapacity_ExactLiquidity: {
14064                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
14065                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, liquidity_msat_conv);
14066                 }
14067                 case LDKEffectiveCapacity_MaximumHTLC: {
14068                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
14069                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, amount_msat_conv);
14070                 }
14071                 case LDKEffectiveCapacity_Total: {
14072                         int64_t capacity_msat_conv = obj->total.capacity_msat;
14073                         int64_t htlc_maximum_msat_ref = ((uintptr_t)&obj->total.htlc_maximum_msat) | 1;
14074                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, capacity_msat_conv, htlc_maximum_msat_ref);
14075                 }
14076                 case LDKEffectiveCapacity_Infinite: {
14077                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
14078                 }
14079                 case LDKEffectiveCapacity_Unknown: {
14080                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
14081                 }
14082                 default: abort();
14083         }
14084 }
14085 typedef struct LDKLockableScore_JCalls {
14086         atomic_size_t refcnt;
14087         JavaVM *vm;
14088         jweak o;
14089         jmethodID lock_meth;
14090 } LDKLockableScore_JCalls;
14091 static void LDKLockableScore_JCalls_free(void* this_arg) {
14092         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
14093         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14094                 JNIEnv *env;
14095                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14096                 if (get_jenv_res == JNI_EDETACHED) {
14097                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14098                 } else {
14099                         DO_ASSERT(get_jenv_res == JNI_OK);
14100                 }
14101                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14102                 if (get_jenv_res == JNI_EDETACHED) {
14103                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14104                 }
14105                 FREE(j_calls);
14106         }
14107 }
14108 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
14109         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
14110         JNIEnv *env;
14111         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14112         if (get_jenv_res == JNI_EDETACHED) {
14113                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14114         } else {
14115                 DO_ASSERT(get_jenv_res == JNI_OK);
14116         }
14117         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14118         CHECK(obj != NULL);
14119         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
14120         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14121                 (*env)->ExceptionDescribe(env);
14122                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
14123         }
14124         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14125         CHECK_ACCESS(ret_ptr);
14126         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
14127         if (ret_conv.free == LDKScore_JCalls_free) {
14128                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14129                 LDKScore_JCalls_cloned(&ret_conv);
14130         }// WARNING: we may need a move here but no clone is available for LDKScore
14131         
14132         if (get_jenv_res == JNI_EDETACHED) {
14133                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14134         }
14135         return ret_conv;
14136 }
14137 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
14138         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
14139         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14140 }
14141 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
14142         jclass c = (*env)->GetObjectClass(env, o);
14143         CHECK(c != NULL);
14144         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
14145         atomic_init(&calls->refcnt, 1);
14146         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14147         calls->o = (*env)->NewWeakGlobalRef(env, o);
14148         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
14149         CHECK(calls->lock_meth != NULL);
14150
14151         LDKLockableScore ret = {
14152                 .this_arg = (void*) calls,
14153                 .lock = lock_LDKLockableScore_jcall,
14154                 .free = LDKLockableScore_JCalls_free,
14155         };
14156         return ret;
14157 }
14158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
14159         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
14160         *res_ptr = LDKLockableScore_init(env, clz, o);
14161         return (uint64_t)res_ptr;
14162 }
14163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
14164         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14165         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14166         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
14167         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
14168         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
14169         return (int64_t)ret_ret;
14170 }
14171
14172 static jclass LDKGossipSync_P2P_class = NULL;
14173 static jmethodID LDKGossipSync_P2P_meth = NULL;
14174 static jclass LDKGossipSync_Rapid_class = NULL;
14175 static jmethodID LDKGossipSync_Rapid_meth = NULL;
14176 static jclass LDKGossipSync_None_class = NULL;
14177 static jmethodID LDKGossipSync_None_meth = NULL;
14178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGossipSync_init (JNIEnv *env, jclass clz) {
14179         LDKGossipSync_P2P_class =
14180                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$P2P"));
14181         CHECK(LDKGossipSync_P2P_class != NULL);
14182         LDKGossipSync_P2P_meth = (*env)->GetMethodID(env, LDKGossipSync_P2P_class, "<init>", "(J)V");
14183         CHECK(LDKGossipSync_P2P_meth != NULL);
14184         LDKGossipSync_Rapid_class =
14185                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$Rapid"));
14186         CHECK(LDKGossipSync_Rapid_class != NULL);
14187         LDKGossipSync_Rapid_meth = (*env)->GetMethodID(env, LDKGossipSync_Rapid_class, "<init>", "(J)V");
14188         CHECK(LDKGossipSync_Rapid_meth != NULL);
14189         LDKGossipSync_None_class =
14190                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$None"));
14191         CHECK(LDKGossipSync_None_class != NULL);
14192         LDKGossipSync_None_meth = (*env)->GetMethodID(env, LDKGossipSync_None_class, "<init>", "()V");
14193         CHECK(LDKGossipSync_None_meth != NULL);
14194 }
14195 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGossipSync_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14196         LDKGossipSync *obj = (LDKGossipSync*)(ptr & ~1);
14197         switch(obj->tag) {
14198                 case LDKGossipSync_P2P: {
14199                         LDKP2PGossipSync p2p_var = obj->p2p;
14200                         int64_t p2p_ref = 0;
14201                         CHECK((((uintptr_t)p2p_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14202                         CHECK((((uintptr_t)&p2p_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14203                         CHECK_INNER_FIELD_ACCESS_OR_NULL(p2p_var);
14204                         p2p_ref = (uintptr_t)p2p_var.inner & ~1;
14205                         return (*env)->NewObject(env, LDKGossipSync_P2P_class, LDKGossipSync_P2P_meth, p2p_ref);
14206                 }
14207                 case LDKGossipSync_Rapid: {
14208                         LDKRapidGossipSync rapid_var = obj->rapid;
14209                         int64_t rapid_ref = 0;
14210                         CHECK((((uintptr_t)rapid_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14211                         CHECK((((uintptr_t)&rapid_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14212                         CHECK_INNER_FIELD_ACCESS_OR_NULL(rapid_var);
14213                         rapid_ref = (uintptr_t)rapid_var.inner & ~1;
14214                         return (*env)->NewObject(env, LDKGossipSync_Rapid_class, LDKGossipSync_Rapid_meth, rapid_ref);
14215                 }
14216                 case LDKGossipSync_None: {
14217                         return (*env)->NewObject(env, LDKGossipSync_None_class, LDKGossipSync_None_meth);
14218                 }
14219                 default: abort();
14220         }
14221 }
14222 static jclass LDKFallback_SegWitProgram_class = NULL;
14223 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
14224 static jclass LDKFallback_PubKeyHash_class = NULL;
14225 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
14226 static jclass LDKFallback_ScriptHash_class = NULL;
14227 static jmethodID LDKFallback_ScriptHash_meth = NULL;
14228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
14229         LDKFallback_SegWitProgram_class =
14230                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
14231         CHECK(LDKFallback_SegWitProgram_class != NULL);
14232         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
14233         CHECK(LDKFallback_SegWitProgram_meth != NULL);
14234         LDKFallback_PubKeyHash_class =
14235                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
14236         CHECK(LDKFallback_PubKeyHash_class != NULL);
14237         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
14238         CHECK(LDKFallback_PubKeyHash_meth != NULL);
14239         LDKFallback_ScriptHash_class =
14240                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
14241         CHECK(LDKFallback_ScriptHash_class != NULL);
14242         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
14243         CHECK(LDKFallback_ScriptHash_meth != NULL);
14244 }
14245 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14246         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
14247         switch(obj->tag) {
14248                 case LDKFallback_SegWitProgram: {
14249                         uint8_t version_val = obj->seg_wit_program.version._0;
14250                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
14251                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
14252                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
14253                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
14254                 }
14255                 case LDKFallback_PubKeyHash: {
14256                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
14257                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
14258                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
14259                 }
14260                 case LDKFallback_ScriptHash: {
14261                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
14262                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
14263                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
14264                 }
14265                 default: abort();
14266         }
14267 }
14268 typedef struct LDKPayer_JCalls {
14269         atomic_size_t refcnt;
14270         JavaVM *vm;
14271         jweak o;
14272         jmethodID node_id_meth;
14273         jmethodID first_hops_meth;
14274         jmethodID send_payment_meth;
14275         jmethodID send_spontaneous_payment_meth;
14276         jmethodID retry_payment_meth;
14277         jmethodID abandon_payment_meth;
14278 } LDKPayer_JCalls;
14279 static void LDKPayer_JCalls_free(void* this_arg) {
14280         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14281         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14282                 JNIEnv *env;
14283                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14284                 if (get_jenv_res == JNI_EDETACHED) {
14285                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14286                 } else {
14287                         DO_ASSERT(get_jenv_res == JNI_OK);
14288                 }
14289                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14290                 if (get_jenv_res == JNI_EDETACHED) {
14291                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14292                 }
14293                 FREE(j_calls);
14294         }
14295 }
14296 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
14297         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14298         JNIEnv *env;
14299         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14300         if (get_jenv_res == JNI_EDETACHED) {
14301                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14302         } else {
14303                 DO_ASSERT(get_jenv_res == JNI_OK);
14304         }
14305         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14306         CHECK(obj != NULL);
14307         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
14308         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14309                 (*env)->ExceptionDescribe(env);
14310                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
14311         }
14312         LDKPublicKey ret_ref;
14313         CHECK((*env)->GetArrayLength(env, ret) == 33);
14314         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
14315         if (get_jenv_res == JNI_EDETACHED) {
14316                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14317         }
14318         return ret_ref;
14319 }
14320 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
14321         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14322         JNIEnv *env;
14323         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14324         if (get_jenv_res == JNI_EDETACHED) {
14325                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14326         } else {
14327                 DO_ASSERT(get_jenv_res == JNI_OK);
14328         }
14329         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14330         CHECK(obj != NULL);
14331         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
14332         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14333                 (*env)->ExceptionDescribe(env);
14334                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
14335         }
14336         LDKCVec_ChannelDetailsZ ret_constr;
14337         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
14338         if (ret_constr.datalen > 0)
14339                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14340         else
14341                 ret_constr.data = NULL;
14342         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
14343         for (size_t q = 0; q < ret_constr.datalen; q++) {
14344                 int64_t ret_conv_16 = ret_vals[q];
14345                 LDKChannelDetails ret_conv_16_conv;
14346                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
14347                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
14348                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
14349                 ret_constr.data[q] = ret_conv_16_conv;
14350         }
14351         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
14352         if (get_jenv_res == JNI_EDETACHED) {
14353                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14354         }
14355         return ret_constr;
14356 }
14357 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
14358         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14359         JNIEnv *env;
14360         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14361         if (get_jenv_res == JNI_EDETACHED) {
14362                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14363         } else {
14364                 DO_ASSERT(get_jenv_res == JNI_OK);
14365         }
14366         LDKRoute route_var = *route;
14367         int64_t route_ref = 0;
14368         route_var = Route_clone(&route_var);
14369         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14370         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14371         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14372         route_ref = (uintptr_t)route_var.inner;
14373         if (route_var.is_owned) {
14374                 route_ref |= 1;
14375         }
14376         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
14377         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
14378         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
14379         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
14380         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14381         CHECK(obj != NULL);
14382         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
14383         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14384                 (*env)->ExceptionDescribe(env);
14385                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
14386         }
14387         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14388         CHECK_ACCESS(ret_ptr);
14389         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
14390         FREE((void*)ret);
14391         if (get_jenv_res == JNI_EDETACHED) {
14392                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14393         }
14394         return ret_conv;
14395 }
14396 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
14397         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14398         JNIEnv *env;
14399         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14400         if (get_jenv_res == JNI_EDETACHED) {
14401                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14402         } else {
14403                 DO_ASSERT(get_jenv_res == JNI_OK);
14404         }
14405         LDKRoute route_var = *route;
14406         int64_t route_ref = 0;
14407         route_var = Route_clone(&route_var);
14408         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14409         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14410         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14411         route_ref = (uintptr_t)route_var.inner;
14412         if (route_var.is_owned) {
14413                 route_ref |= 1;
14414         }
14415         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
14416         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
14417         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14418         CHECK(obj != NULL);
14419         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
14420         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14421                 (*env)->ExceptionDescribe(env);
14422                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
14423         }
14424         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14425         CHECK_ACCESS(ret_ptr);
14426         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
14427         FREE((void*)ret);
14428         if (get_jenv_res == JNI_EDETACHED) {
14429                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14430         }
14431         return ret_conv;
14432 }
14433 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
14434         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14435         JNIEnv *env;
14436         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14437         if (get_jenv_res == JNI_EDETACHED) {
14438                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14439         } else {
14440                 DO_ASSERT(get_jenv_res == JNI_OK);
14441         }
14442         LDKRoute route_var = *route;
14443         int64_t route_ref = 0;
14444         route_var = Route_clone(&route_var);
14445         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14446         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14447         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14448         route_ref = (uintptr_t)route_var.inner;
14449         if (route_var.is_owned) {
14450                 route_ref |= 1;
14451         }
14452         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14453         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14454         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14455         CHECK(obj != NULL);
14456         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
14457         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14458                 (*env)->ExceptionDescribe(env);
14459                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
14460         }
14461         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14462         CHECK_ACCESS(ret_ptr);
14463         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
14464         FREE((void*)ret);
14465         if (get_jenv_res == JNI_EDETACHED) {
14466                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14467         }
14468         return ret_conv;
14469 }
14470 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
14471         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14472         JNIEnv *env;
14473         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14474         if (get_jenv_res == JNI_EDETACHED) {
14475                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14476         } else {
14477                 DO_ASSERT(get_jenv_res == JNI_OK);
14478         }
14479         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14480         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14481         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14482         CHECK(obj != NULL);
14483         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
14484         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14485                 (*env)->ExceptionDescribe(env);
14486                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
14487         }
14488         if (get_jenv_res == JNI_EDETACHED) {
14489                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14490         }
14491 }
14492 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
14493         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
14494         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14495 }
14496 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
14497         jclass c = (*env)->GetObjectClass(env, o);
14498         CHECK(c != NULL);
14499         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
14500         atomic_init(&calls->refcnt, 1);
14501         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14502         calls->o = (*env)->NewWeakGlobalRef(env, o);
14503         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
14504         CHECK(calls->node_id_meth != NULL);
14505         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
14506         CHECK(calls->first_hops_meth != NULL);
14507         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
14508         CHECK(calls->send_payment_meth != NULL);
14509         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
14510         CHECK(calls->send_spontaneous_payment_meth != NULL);
14511         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
14512         CHECK(calls->retry_payment_meth != NULL);
14513         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
14514         CHECK(calls->abandon_payment_meth != NULL);
14515
14516         LDKPayer ret = {
14517                 .this_arg = (void*) calls,
14518                 .node_id = node_id_LDKPayer_jcall,
14519                 .first_hops = first_hops_LDKPayer_jcall,
14520                 .send_payment = send_payment_LDKPayer_jcall,
14521                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
14522                 .retry_payment = retry_payment_LDKPayer_jcall,
14523                 .abandon_payment = abandon_payment_LDKPayer_jcall,
14524                 .free = LDKPayer_JCalls_free,
14525         };
14526         return ret;
14527 }
14528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
14529         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
14530         *res_ptr = LDKPayer_init(env, clz, o);
14531         return (uint64_t)res_ptr;
14532 }
14533 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14534         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14535         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14536         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14537         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14538         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
14539         return ret_arr;
14540 }
14541
14542 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
14543         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14544         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14545         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14546         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
14547         int64_tArray ret_arr = NULL;
14548         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14549         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14550         for (size_t q = 0; q < ret_var.datalen; q++) {
14551                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
14552                 int64_t ret_conv_16_ref = 0;
14553                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14554                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14555                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
14556                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
14557                 if (ret_conv_16_var.is_owned) {
14558                         ret_conv_16_ref |= 1;
14559                 }
14560                 ret_arr_ptr[q] = ret_conv_16_ref;
14561         }
14562         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14563         FREE(ret_var.data);
14564         return ret_arr;
14565 }
14566
14567 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) {
14568         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14569         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14570         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14571         LDKRoute route_conv;
14572         route_conv.inner = (void*)(route & (~1));
14573         route_conv.is_owned = false;
14574         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14575         LDKThirtyTwoBytes payment_hash_ref;
14576         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14577         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
14578         LDKThirtyTwoBytes payment_secret_ref;
14579         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
14580         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
14581         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14582         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
14583         return (int64_t)ret_conv;
14584 }
14585
14586 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) {
14587         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14588         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14589         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14590         LDKRoute route_conv;
14591         route_conv.inner = (void*)(route & (~1));
14592         route_conv.is_owned = false;
14593         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14594         LDKThirtyTwoBytes payment_preimage_ref;
14595         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
14596         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
14597         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14598         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
14599         return (int64_t)ret_conv;
14600 }
14601
14602 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) {
14603         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14604         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14605         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14606         LDKRoute route_conv;
14607         route_conv.inner = (void*)(route & (~1));
14608         route_conv.is_owned = false;
14609         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14610         LDKThirtyTwoBytes payment_id_ref;
14611         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14612         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14613         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14614         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
14615         return (int64_t)ret_conv;
14616 }
14617
14618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
14619         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14620         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14621         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14622         LDKThirtyTwoBytes payment_id_ref;
14623         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14624         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14625         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
14626 }
14627
14628 typedef struct LDKRouter_JCalls {
14629         atomic_size_t refcnt;
14630         JavaVM *vm;
14631         jweak o;
14632         jmethodID find_route_meth;
14633 } LDKRouter_JCalls;
14634 static void LDKRouter_JCalls_free(void* this_arg) {
14635         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14636         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14637                 JNIEnv *env;
14638                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14639                 if (get_jenv_res == JNI_EDETACHED) {
14640                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14641                 } else {
14642                         DO_ASSERT(get_jenv_res == JNI_OK);
14643                 }
14644                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14645                 if (get_jenv_res == JNI_EDETACHED) {
14646                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14647                 }
14648                 FREE(j_calls);
14649         }
14650 }
14651 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) {
14652         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14653         JNIEnv *env;
14654         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14655         if (get_jenv_res == JNI_EDETACHED) {
14656                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14657         } else {
14658                 DO_ASSERT(get_jenv_res == JNI_OK);
14659         }
14660         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
14661         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
14662         LDKRouteParameters route_params_var = *route_params;
14663         int64_t route_params_ref = 0;
14664         route_params_var = RouteParameters_clone(&route_params_var);
14665         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14666         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14667         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
14668         route_params_ref = (uintptr_t)route_params_var.inner;
14669         if (route_params_var.is_owned) {
14670                 route_params_ref |= 1;
14671         }
14672         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
14673         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, *payment_hash);
14674         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
14675         int64_tArray first_hops_arr = NULL;
14676         if (first_hops != NULL) {
14677                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
14678                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
14679                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
14680                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
14681                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
14682                         int64_t first_hops_conv_16_ref = 0;
14683                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14684                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14685                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
14686                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
14687                         if (first_hops_conv_16_var.is_owned) {
14688                                 first_hops_conv_16_ref |= 1;
14689                         }
14690                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
14691                 }
14692                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
14693         }
14694         // WARNING: This object doesn't live past this scope, needs clone!
14695         int64_t ret_scorer = ((uintptr_t)scorer) | 1;
14696         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14697         CHECK(obj != NULL);
14698         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);
14699         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14700                 (*env)->ExceptionDescribe(env);
14701                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
14702         }
14703         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14704         CHECK_ACCESS(ret_ptr);
14705         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
14706         FREE((void*)ret);
14707         if (get_jenv_res == JNI_EDETACHED) {
14708                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14709         }
14710         return ret_conv;
14711 }
14712 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
14713         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
14714         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14715 }
14716 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
14717         jclass c = (*env)->GetObjectClass(env, o);
14718         CHECK(c != NULL);
14719         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
14720         atomic_init(&calls->refcnt, 1);
14721         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14722         calls->o = (*env)->NewWeakGlobalRef(env, o);
14723         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[B[JJ)J");
14724         CHECK(calls->find_route_meth != NULL);
14725
14726         LDKRouter ret = {
14727                 .this_arg = (void*) calls,
14728                 .find_route = find_route_LDKRouter_jcall,
14729                 .free = LDKRouter_JCalls_free,
14730         };
14731         return ret;
14732 }
14733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
14734         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
14735         *res_ptr = LDKRouter_init(env, clz, o);
14736         return (uint64_t)res_ptr;
14737 }
14738 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) {
14739         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14740         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14741         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
14742         LDKPublicKey payer_ref;
14743         CHECK((*env)->GetArrayLength(env, payer) == 33);
14744         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
14745         LDKRouteParameters route_params_conv;
14746         route_params_conv.inner = (void*)(route_params & (~1));
14747         route_params_conv.is_owned = false;
14748         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
14749         unsigned char payment_hash_arr[32];
14750         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14751         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
14752         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
14753         LDKCVec_ChannelDetailsZ first_hops_constr;
14754         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
14755         if (first_hops != NULL) {
14756                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
14757                 if (first_hops_constr.datalen > 0)
14758                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14759                 else
14760                         first_hops_constr.data = NULL;
14761                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
14762                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
14763                         int64_t first_hops_conv_16 = first_hops_vals[q];
14764                         LDKChannelDetails first_hops_conv_16_conv;
14765                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
14766                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
14767                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
14768                         first_hops_constr.data[q] = first_hops_conv_16_conv;
14769                 }
14770                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
14771                 first_hops_ptr = &first_hops_constr;
14772         }
14773         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
14774         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
14775         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
14776         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14777         *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);
14778         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
14779         return (int64_t)ret_conv;
14780 }
14781
14782 static jclass LDKRetry_Attempts_class = NULL;
14783 static jmethodID LDKRetry_Attempts_meth = NULL;
14784 static jclass LDKRetry_Timeout_class = NULL;
14785 static jmethodID LDKRetry_Timeout_meth = NULL;
14786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRetry_init (JNIEnv *env, jclass clz) {
14787         LDKRetry_Attempts_class =
14788                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Attempts"));
14789         CHECK(LDKRetry_Attempts_class != NULL);
14790         LDKRetry_Attempts_meth = (*env)->GetMethodID(env, LDKRetry_Attempts_class, "<init>", "(J)V");
14791         CHECK(LDKRetry_Attempts_meth != NULL);
14792         LDKRetry_Timeout_class =
14793                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Timeout"));
14794         CHECK(LDKRetry_Timeout_class != NULL);
14795         LDKRetry_Timeout_meth = (*env)->GetMethodID(env, LDKRetry_Timeout_class, "<init>", "(J)V");
14796         CHECK(LDKRetry_Timeout_meth != NULL);
14797 }
14798 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRetry_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14799         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
14800         switch(obj->tag) {
14801                 case LDKRetry_Attempts: {
14802                         int64_t attempts_conv = obj->attempts;
14803                         return (*env)->NewObject(env, LDKRetry_Attempts_class, LDKRetry_Attempts_meth, attempts_conv);
14804                 }
14805                 case LDKRetry_Timeout: {
14806                         int64_t timeout_conv = obj->timeout;
14807                         return (*env)->NewObject(env, LDKRetry_Timeout_class, LDKRetry_Timeout_meth, timeout_conv);
14808                 }
14809                 default: abort();
14810         }
14811 }
14812 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14813         LDKStr ret_str = _ldk_get_compiled_version();
14814         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14815         Str_free(ret_str);
14816         return ret_conv;
14817 }
14818
14819 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14820         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
14821         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14822         Str_free(ret_str);
14823         return ret_conv;
14824 }
14825
14826 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
14827         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14828         *ret_copy = Bech32Error_clone(arg);
14829 int64_t ret_ref = (uintptr_t)ret_copy;
14830         return ret_ref;
14831 }
14832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14833         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
14834         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
14835         return ret_conv;
14836 }
14837
14838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14839         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
14840         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14841         *ret_copy = Bech32Error_clone(orig_conv);
14842         int64_t ret_ref = (uintptr_t)ret_copy;
14843         return ret_ref;
14844 }
14845
14846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
14847         if ((o & 1) != 0) return;
14848         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14849         CHECK_ACCESS(o_ptr);
14850         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
14851         FREE((void*)o);
14852         Bech32Error_free(o_conv);
14853 }
14854
14855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
14856         LDKTransaction _res_ref;
14857         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
14858         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
14859         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
14860         _res_ref.data_is_owned = true;
14861         Transaction_free(_res_ref);
14862 }
14863
14864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
14865         LDKCVec_u8Z script_pubkey_ref;
14866         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
14867         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
14868         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
14869         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14870         *ret_ref = TxOut_new(script_pubkey_ref, value);
14871         return (int64_t)ret_ref;
14872 }
14873
14874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
14875         if ((_res & 1) != 0) return;
14876         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14877         CHECK_ACCESS(_res_ptr);
14878         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
14879         FREE((void*)_res);
14880         TxOut_free(_res_conv);
14881 }
14882
14883 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
14884         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14885         *ret_ref = TxOut_clone(arg);
14886         return (int64_t)ret_ref;
14887 }
14888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14889         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
14890         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
14891         return ret_conv;
14892 }
14893
14894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14895         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
14896         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14897         *ret_ref = TxOut_clone(orig_conv);
14898         return (int64_t)ret_ref;
14899 }
14900
14901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
14902         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
14903         Str_free(dummy);
14904 }
14905
14906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
14907         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14908         *ret_conv = CResult_NoneNoneZ_ok();
14909         return (int64_t)ret_conv;
14910 }
14911
14912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
14913         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14914         *ret_conv = CResult_NoneNoneZ_err();
14915         return (int64_t)ret_conv;
14916 }
14917
14918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14919         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
14920         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
14921         return ret_conv;
14922 }
14923
14924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14925         if ((_res & 1) != 0) return;
14926         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14927         CHECK_ACCESS(_res_ptr);
14928         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
14929         FREE((void*)_res);
14930         CResult_NoneNoneZ_free(_res_conv);
14931 }
14932
14933 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
14934         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14935         *ret_conv = CResult_NoneNoneZ_clone(arg);
14936         return (int64_t)ret_conv;
14937 }
14938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14939         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
14940         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
14941         return ret_conv;
14942 }
14943
14944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14945         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
14946         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14947         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
14948         return (int64_t)ret_conv;
14949 }
14950
14951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14952         LDKCounterpartyCommitmentSecrets o_conv;
14953         o_conv.inner = (void*)(o & (~1));
14954         o_conv.is_owned = (o & 1) || (o == 0);
14955         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14956         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
14957         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14958         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
14959         return (int64_t)ret_conv;
14960 }
14961
14962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14963         LDKDecodeError e_conv;
14964         e_conv.inner = (void*)(e & (~1));
14965         e_conv.is_owned = (e & 1) || (e == 0);
14966         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14967         e_conv = DecodeError_clone(&e_conv);
14968         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14969         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
14970         return (int64_t)ret_conv;
14971 }
14972
14973 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14974         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
14975         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
14976         return ret_conv;
14977 }
14978
14979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14980         if ((_res & 1) != 0) return;
14981         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14982         CHECK_ACCESS(_res_ptr);
14983         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
14984         FREE((void*)_res);
14985         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
14986 }
14987
14988 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
14989         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14990         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
14991         return (int64_t)ret_conv;
14992 }
14993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14994         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
14995         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
14996         return ret_conv;
14997 }
14998
14999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15000         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
15001         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15002         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
15003         return (int64_t)ret_conv;
15004 }
15005
15006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15007         LDKSecretKey o_ref;
15008         CHECK((*env)->GetArrayLength(env, o) == 32);
15009         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
15010         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15011         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
15012         return (int64_t)ret_conv;
15013 }
15014
15015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15016         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15017         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15018         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
15019         return (int64_t)ret_conv;
15020 }
15021
15022 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15023         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
15024         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
15025         return ret_conv;
15026 }
15027
15028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15029         if ((_res & 1) != 0) return;
15030         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15031         CHECK_ACCESS(_res_ptr);
15032         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
15033         FREE((void*)_res);
15034         CResult_SecretKeyErrorZ_free(_res_conv);
15035 }
15036
15037 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
15038         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15039         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
15040         return (int64_t)ret_conv;
15041 }
15042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15043         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
15044         int64_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
15045         return ret_conv;
15046 }
15047
15048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15049         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
15050         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15051         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
15052         return (int64_t)ret_conv;
15053 }
15054
15055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15056         LDKPublicKey o_ref;
15057         CHECK((*env)->GetArrayLength(env, o) == 33);
15058         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
15059         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15060         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
15061         return (int64_t)ret_conv;
15062 }
15063
15064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15065         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15066         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15067         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
15068         return (int64_t)ret_conv;
15069 }
15070
15071 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15072         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
15073         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
15074         return ret_conv;
15075 }
15076
15077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15078         if ((_res & 1) != 0) return;
15079         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15080         CHECK_ACCESS(_res_ptr);
15081         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
15082         FREE((void*)_res);
15083         CResult_PublicKeyErrorZ_free(_res_conv);
15084 }
15085
15086 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
15087         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15088         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
15089         return (int64_t)ret_conv;
15090 }
15091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15092         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
15093         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
15094         return ret_conv;
15095 }
15096
15097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15098         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
15099         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15100         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
15101         return (int64_t)ret_conv;
15102 }
15103
15104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15105         LDKTxCreationKeys o_conv;
15106         o_conv.inner = (void*)(o & (~1));
15107         o_conv.is_owned = (o & 1) || (o == 0);
15108         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15109         o_conv = TxCreationKeys_clone(&o_conv);
15110         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15111         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
15112         return (int64_t)ret_conv;
15113 }
15114
15115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15116         LDKDecodeError e_conv;
15117         e_conv.inner = (void*)(e & (~1));
15118         e_conv.is_owned = (e & 1) || (e == 0);
15119         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15120         e_conv = DecodeError_clone(&e_conv);
15121         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15122         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
15123         return (int64_t)ret_conv;
15124 }
15125
15126 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15127         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
15128         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
15129         return ret_conv;
15130 }
15131
15132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15133         if ((_res & 1) != 0) return;
15134         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15135         CHECK_ACCESS(_res_ptr);
15136         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
15137         FREE((void*)_res);
15138         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
15139 }
15140
15141 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
15142         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15143         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
15144         return (int64_t)ret_conv;
15145 }
15146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15147         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
15148         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
15149         return ret_conv;
15150 }
15151
15152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15153         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
15154         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15155         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
15156         return (int64_t)ret_conv;
15157 }
15158
15159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15160         LDKChannelPublicKeys o_conv;
15161         o_conv.inner = (void*)(o & (~1));
15162         o_conv.is_owned = (o & 1) || (o == 0);
15163         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15164         o_conv = ChannelPublicKeys_clone(&o_conv);
15165         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15166         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
15167         return (int64_t)ret_conv;
15168 }
15169
15170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15171         LDKDecodeError e_conv;
15172         e_conv.inner = (void*)(e & (~1));
15173         e_conv.is_owned = (e & 1) || (e == 0);
15174         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15175         e_conv = DecodeError_clone(&e_conv);
15176         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15177         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
15178         return (int64_t)ret_conv;
15179 }
15180
15181 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15182         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
15183         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
15184         return ret_conv;
15185 }
15186
15187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15188         if ((_res & 1) != 0) return;
15189         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15190         CHECK_ACCESS(_res_ptr);
15191         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
15192         FREE((void*)_res);
15193         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
15194 }
15195
15196 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
15197         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15198         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
15199         return (int64_t)ret_conv;
15200 }
15201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15202         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
15203         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
15204         return ret_conv;
15205 }
15206
15207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15208         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
15209         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15210         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
15211         return (int64_t)ret_conv;
15212 }
15213
15214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15215         LDKTxCreationKeys o_conv;
15216         o_conv.inner = (void*)(o & (~1));
15217         o_conv.is_owned = (o & 1) || (o == 0);
15218         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15219         o_conv = TxCreationKeys_clone(&o_conv);
15220         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15221         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
15222         return (int64_t)ret_conv;
15223 }
15224
15225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15226         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15227         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15228         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
15229         return (int64_t)ret_conv;
15230 }
15231
15232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15233         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
15234         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
15235         return ret_conv;
15236 }
15237
15238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15239         if ((_res & 1) != 0) return;
15240         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15241         CHECK_ACCESS(_res_ptr);
15242         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
15243         FREE((void*)_res);
15244         CResult_TxCreationKeysErrorZ_free(_res_conv);
15245 }
15246
15247 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
15248         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15249         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
15250         return (int64_t)ret_conv;
15251 }
15252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15253         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
15254         int64_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
15255         return ret_conv;
15256 }
15257
15258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15259         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
15260         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15261         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
15262         return (int64_t)ret_conv;
15263 }
15264
15265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
15266         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15267         *ret_copy = COption_u32Z_some(o);
15268         int64_t ret_ref = (uintptr_t)ret_copy;
15269         return ret_ref;
15270 }
15271
15272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
15273         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15274         *ret_copy = COption_u32Z_none();
15275         int64_t ret_ref = (uintptr_t)ret_copy;
15276         return ret_ref;
15277 }
15278
15279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
15280         if ((_res & 1) != 0) return;
15281         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15282         CHECK_ACCESS(_res_ptr);
15283         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
15284         FREE((void*)_res);
15285         COption_u32Z_free(_res_conv);
15286 }
15287
15288 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
15289         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15290         *ret_copy = COption_u32Z_clone(arg);
15291 int64_t ret_ref = (uintptr_t)ret_copy;
15292         return ret_ref;
15293 }
15294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15295         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
15296         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
15297         return ret_conv;
15298 }
15299
15300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15301         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
15302         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15303         *ret_copy = COption_u32Z_clone(orig_conv);
15304         int64_t ret_ref = (uintptr_t)ret_copy;
15305         return ret_ref;
15306 }
15307
15308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15309         LDKHTLCOutputInCommitment o_conv;
15310         o_conv.inner = (void*)(o & (~1));
15311         o_conv.is_owned = (o & 1) || (o == 0);
15312         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15313         o_conv = HTLCOutputInCommitment_clone(&o_conv);
15314         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15315         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
15316         return (int64_t)ret_conv;
15317 }
15318
15319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15320         LDKDecodeError e_conv;
15321         e_conv.inner = (void*)(e & (~1));
15322         e_conv.is_owned = (e & 1) || (e == 0);
15323         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15324         e_conv = DecodeError_clone(&e_conv);
15325         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15326         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
15327         return (int64_t)ret_conv;
15328 }
15329
15330 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15331         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
15332         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
15333         return ret_conv;
15334 }
15335
15336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15337         if ((_res & 1) != 0) return;
15338         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15339         CHECK_ACCESS(_res_ptr);
15340         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
15341         FREE((void*)_res);
15342         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
15343 }
15344
15345 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
15346         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15347         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
15348         return (int64_t)ret_conv;
15349 }
15350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15351         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
15352         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
15353         return ret_conv;
15354 }
15355
15356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15357         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
15358         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15359         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
15360         return (int64_t)ret_conv;
15361 }
15362
15363 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
15364         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
15365         return ret_conv;
15366 }
15367
15368 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
15369         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
15370         return ret_conv;
15371 }
15372
15373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
15374         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
15375         COption_NoneZ_free(_res_conv);
15376 }
15377
15378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15379         LDKCounterpartyChannelTransactionParameters o_conv;
15380         o_conv.inner = (void*)(o & (~1));
15381         o_conv.is_owned = (o & 1) || (o == 0);
15382         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15383         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
15384         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15385         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
15386         return (int64_t)ret_conv;
15387 }
15388
15389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15390         LDKDecodeError e_conv;
15391         e_conv.inner = (void*)(e & (~1));
15392         e_conv.is_owned = (e & 1) || (e == 0);
15393         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15394         e_conv = DecodeError_clone(&e_conv);
15395         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15396         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
15397         return (int64_t)ret_conv;
15398 }
15399
15400 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15401         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
15402         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
15403         return ret_conv;
15404 }
15405
15406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15407         if ((_res & 1) != 0) return;
15408         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15409         CHECK_ACCESS(_res_ptr);
15410         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
15411         FREE((void*)_res);
15412         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
15413 }
15414
15415 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
15416         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15417         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
15418         return (int64_t)ret_conv;
15419 }
15420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15421         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
15422         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
15423         return ret_conv;
15424 }
15425
15426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15427         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
15428         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15429         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
15430         return (int64_t)ret_conv;
15431 }
15432
15433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15434         LDKChannelTransactionParameters o_conv;
15435         o_conv.inner = (void*)(o & (~1));
15436         o_conv.is_owned = (o & 1) || (o == 0);
15437         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15438         o_conv = ChannelTransactionParameters_clone(&o_conv);
15439         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15440         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
15441         return (int64_t)ret_conv;
15442 }
15443
15444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15445         LDKDecodeError e_conv;
15446         e_conv.inner = (void*)(e & (~1));
15447         e_conv.is_owned = (e & 1) || (e == 0);
15448         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15449         e_conv = DecodeError_clone(&e_conv);
15450         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15451         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
15452         return (int64_t)ret_conv;
15453 }
15454
15455 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15456         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
15457         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
15458         return ret_conv;
15459 }
15460
15461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15462         if ((_res & 1) != 0) return;
15463         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15464         CHECK_ACCESS(_res_ptr);
15465         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
15466         FREE((void*)_res);
15467         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
15468 }
15469
15470 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
15471         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15472         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
15473         return (int64_t)ret_conv;
15474 }
15475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15476         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
15477         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
15478         return ret_conv;
15479 }
15480
15481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15482         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
15483         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15484         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
15485         return (int64_t)ret_conv;
15486 }
15487
15488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15489         LDKCVec_SignatureZ _res_constr;
15490         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15491         if (_res_constr.datalen > 0)
15492                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15493         else
15494                 _res_constr.data = NULL;
15495         for (size_t i = 0; i < _res_constr.datalen; i++) {
15496                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15497                 LDKSignature _res_conv_8_ref;
15498                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
15499                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
15500                 _res_constr.data[i] = _res_conv_8_ref;
15501         }
15502         CVec_SignatureZ_free(_res_constr);
15503 }
15504
15505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15506         LDKHolderCommitmentTransaction o_conv;
15507         o_conv.inner = (void*)(o & (~1));
15508         o_conv.is_owned = (o & 1) || (o == 0);
15509         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15510         o_conv = HolderCommitmentTransaction_clone(&o_conv);
15511         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15512         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
15513         return (int64_t)ret_conv;
15514 }
15515
15516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15517         LDKDecodeError e_conv;
15518         e_conv.inner = (void*)(e & (~1));
15519         e_conv.is_owned = (e & 1) || (e == 0);
15520         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15521         e_conv = DecodeError_clone(&e_conv);
15522         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15523         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
15524         return (int64_t)ret_conv;
15525 }
15526
15527 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15528         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
15529         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15530         return ret_conv;
15531 }
15532
15533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15534         if ((_res & 1) != 0) return;
15535         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15536         CHECK_ACCESS(_res_ptr);
15537         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
15538         FREE((void*)_res);
15539         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
15540 }
15541
15542 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15543         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15544         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
15545         return (int64_t)ret_conv;
15546 }
15547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15548         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
15549         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15550         return ret_conv;
15551 }
15552
15553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15554         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
15555         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15556         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
15557         return (int64_t)ret_conv;
15558 }
15559
15560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15561         LDKBuiltCommitmentTransaction o_conv;
15562         o_conv.inner = (void*)(o & (~1));
15563         o_conv.is_owned = (o & 1) || (o == 0);
15564         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15565         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
15566         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15567         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
15568         return (int64_t)ret_conv;
15569 }
15570
15571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15572         LDKDecodeError e_conv;
15573         e_conv.inner = (void*)(e & (~1));
15574         e_conv.is_owned = (e & 1) || (e == 0);
15575         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15576         e_conv = DecodeError_clone(&e_conv);
15577         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15578         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
15579         return (int64_t)ret_conv;
15580 }
15581
15582 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15583         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
15584         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15585         return ret_conv;
15586 }
15587
15588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15589         if ((_res & 1) != 0) return;
15590         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15591         CHECK_ACCESS(_res_ptr);
15592         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
15593         FREE((void*)_res);
15594         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
15595 }
15596
15597 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15598         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15599         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
15600         return (int64_t)ret_conv;
15601 }
15602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15603         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
15604         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15605         return ret_conv;
15606 }
15607
15608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15609         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
15610         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15611         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
15612         return (int64_t)ret_conv;
15613 }
15614
15615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15616         LDKTrustedClosingTransaction o_conv;
15617         o_conv.inner = (void*)(o & (~1));
15618         o_conv.is_owned = (o & 1) || (o == 0);
15619         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15620         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
15621         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
15622         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
15623         return (int64_t)ret_conv;
15624 }
15625
15626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
15627         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
15628         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
15629         return (int64_t)ret_conv;
15630 }
15631
15632 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15633         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
15634         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
15635         return ret_conv;
15636 }
15637
15638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15639         if ((_res & 1) != 0) return;
15640         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15641         CHECK_ACCESS(_res_ptr);
15642         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
15643         FREE((void*)_res);
15644         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
15645 }
15646
15647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15648         LDKCommitmentTransaction o_conv;
15649         o_conv.inner = (void*)(o & (~1));
15650         o_conv.is_owned = (o & 1) || (o == 0);
15651         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15652         o_conv = CommitmentTransaction_clone(&o_conv);
15653         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15654         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
15655         return (int64_t)ret_conv;
15656 }
15657
15658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15659         LDKDecodeError e_conv;
15660         e_conv.inner = (void*)(e & (~1));
15661         e_conv.is_owned = (e & 1) || (e == 0);
15662         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15663         e_conv = DecodeError_clone(&e_conv);
15664         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15665         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
15666         return (int64_t)ret_conv;
15667 }
15668
15669 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15670         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
15671         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15672         return ret_conv;
15673 }
15674
15675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15676         if ((_res & 1) != 0) return;
15677         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15678         CHECK_ACCESS(_res_ptr);
15679         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
15680         FREE((void*)_res);
15681         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
15682 }
15683
15684 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15685         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15686         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
15687         return (int64_t)ret_conv;
15688 }
15689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15690         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
15691         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15692         return ret_conv;
15693 }
15694
15695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15696         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
15697         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15698         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
15699         return (int64_t)ret_conv;
15700 }
15701
15702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15703         LDKTrustedCommitmentTransaction o_conv;
15704         o_conv.inner = (void*)(o & (~1));
15705         o_conv.is_owned = (o & 1) || (o == 0);
15706         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15707         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
15708         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
15709         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
15710         return (int64_t)ret_conv;
15711 }
15712
15713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
15714         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
15715         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
15716         return (int64_t)ret_conv;
15717 }
15718
15719 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15720         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
15721         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
15722         return ret_conv;
15723 }
15724
15725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15726         if ((_res & 1) != 0) return;
15727         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15728         CHECK_ACCESS(_res_ptr);
15729         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
15730         FREE((void*)_res);
15731         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
15732 }
15733
15734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
15735         LDKCVec_SignatureZ o_constr;
15736         o_constr.datalen = (*env)->GetArrayLength(env, o);
15737         if (o_constr.datalen > 0)
15738                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15739         else
15740                 o_constr.data = NULL;
15741         for (size_t i = 0; i < o_constr.datalen; i++) {
15742                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
15743                 LDKSignature o_conv_8_ref;
15744                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
15745                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
15746                 o_constr.data[i] = o_conv_8_ref;
15747         }
15748         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15749         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
15750         return (int64_t)ret_conv;
15751 }
15752
15753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
15754         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15755         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
15756         return (int64_t)ret_conv;
15757 }
15758
15759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15760         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
15761         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
15762         return ret_conv;
15763 }
15764
15765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15766         if ((_res & 1) != 0) return;
15767         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15768         CHECK_ACCESS(_res_ptr);
15769         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
15770         FREE((void*)_res);
15771         CResult_CVec_SignatureZNoneZ_free(_res_conv);
15772 }
15773
15774 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
15775         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15776         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
15777         return (int64_t)ret_conv;
15778 }
15779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15780         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
15781         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
15782         return ret_conv;
15783 }
15784
15785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15786         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
15787         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15788         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
15789         return (int64_t)ret_conv;
15790 }
15791
15792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15793         LDKShutdownScript o_conv;
15794         o_conv.inner = (void*)(o & (~1));
15795         o_conv.is_owned = (o & 1) || (o == 0);
15796         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15797         o_conv = ShutdownScript_clone(&o_conv);
15798         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15799         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
15800         return (int64_t)ret_conv;
15801 }
15802
15803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15804         LDKDecodeError e_conv;
15805         e_conv.inner = (void*)(e & (~1));
15806         e_conv.is_owned = (e & 1) || (e == 0);
15807         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15808         e_conv = DecodeError_clone(&e_conv);
15809         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15810         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
15811         return (int64_t)ret_conv;
15812 }
15813
15814 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15815         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
15816         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
15817         return ret_conv;
15818 }
15819
15820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15821         if ((_res & 1) != 0) return;
15822         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15823         CHECK_ACCESS(_res_ptr);
15824         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
15825         FREE((void*)_res);
15826         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
15827 }
15828
15829 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
15830         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15831         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
15832         return (int64_t)ret_conv;
15833 }
15834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15835         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
15836         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
15837         return ret_conv;
15838 }
15839
15840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15841         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
15842         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15843         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
15844         return (int64_t)ret_conv;
15845 }
15846
15847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15848         LDKShutdownScript o_conv;
15849         o_conv.inner = (void*)(o & (~1));
15850         o_conv.is_owned = (o & 1) || (o == 0);
15851         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15852         o_conv = ShutdownScript_clone(&o_conv);
15853         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15854         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
15855         return (int64_t)ret_conv;
15856 }
15857
15858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15859         LDKInvalidShutdownScript e_conv;
15860         e_conv.inner = (void*)(e & (~1));
15861         e_conv.is_owned = (e & 1) || (e == 0);
15862         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15863         e_conv = InvalidShutdownScript_clone(&e_conv);
15864         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15865         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
15866         return (int64_t)ret_conv;
15867 }
15868
15869 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15870         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
15871         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
15872         return ret_conv;
15873 }
15874
15875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15876         if ((_res & 1) != 0) return;
15877         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15878         CHECK_ACCESS(_res_ptr);
15879         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
15880         FREE((void*)_res);
15881         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
15882 }
15883
15884 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
15885         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15886         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
15887         return (int64_t)ret_conv;
15888 }
15889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15890         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
15891         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
15892         return ret_conv;
15893 }
15894
15895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15896         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
15897         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15898         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
15899         return (int64_t)ret_conv;
15900 }
15901
15902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
15903         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15904         *ret_conv = CResult_NoneErrorZ_ok();
15905         return (int64_t)ret_conv;
15906 }
15907
15908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15909         LDKIOError e_conv = LDKIOError_from_java(env, e);
15910         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15911         *ret_conv = CResult_NoneErrorZ_err(e_conv);
15912         return (int64_t)ret_conv;
15913 }
15914
15915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15916         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
15917         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
15918         return ret_conv;
15919 }
15920
15921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15922         if ((_res & 1) != 0) return;
15923         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15924         CHECK_ACCESS(_res_ptr);
15925         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
15926         FREE((void*)_res);
15927         CResult_NoneErrorZ_free(_res_conv);
15928 }
15929
15930 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
15931         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15932         *ret_conv = CResult_NoneErrorZ_clone(arg);
15933         return (int64_t)ret_conv;
15934 }
15935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15936         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
15937         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
15938         return ret_conv;
15939 }
15940
15941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15942         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
15943         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15944         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
15945         return (int64_t)ret_conv;
15946 }
15947
15948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15949         LDKRouteHop o_conv;
15950         o_conv.inner = (void*)(o & (~1));
15951         o_conv.is_owned = (o & 1) || (o == 0);
15952         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15953         o_conv = RouteHop_clone(&o_conv);
15954         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15955         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
15956         return (int64_t)ret_conv;
15957 }
15958
15959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15960         LDKDecodeError e_conv;
15961         e_conv.inner = (void*)(e & (~1));
15962         e_conv.is_owned = (e & 1) || (e == 0);
15963         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15964         e_conv = DecodeError_clone(&e_conv);
15965         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15966         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
15967         return (int64_t)ret_conv;
15968 }
15969
15970 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15971         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
15972         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
15973         return ret_conv;
15974 }
15975
15976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15977         if ((_res & 1) != 0) return;
15978         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15979         CHECK_ACCESS(_res_ptr);
15980         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
15981         FREE((void*)_res);
15982         CResult_RouteHopDecodeErrorZ_free(_res_conv);
15983 }
15984
15985 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
15986         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15987         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
15988         return (int64_t)ret_conv;
15989 }
15990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15991         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
15992         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
15993         return ret_conv;
15994 }
15995
15996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15997         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
15998         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15999         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
16000         return (int64_t)ret_conv;
16001 }
16002
16003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16004         LDKCVec_RouteHopZ _res_constr;
16005         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16006         if (_res_constr.datalen > 0)
16007                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16008         else
16009                 _res_constr.data = NULL;
16010         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16011         for (size_t k = 0; k < _res_constr.datalen; k++) {
16012                 int64_t _res_conv_10 = _res_vals[k];
16013                 LDKRouteHop _res_conv_10_conv;
16014                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
16015                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
16016                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
16017                 _res_constr.data[k] = _res_conv_10_conv;
16018         }
16019         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16020         CVec_RouteHopZ_free(_res_constr);
16021 }
16022
16023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16024         LDKCVec_CVec_RouteHopZZ _res_constr;
16025         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16026         if (_res_constr.datalen > 0)
16027                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
16028         else
16029                 _res_constr.data = NULL;
16030         for (size_t m = 0; m < _res_constr.datalen; m++) {
16031                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
16032                 LDKCVec_RouteHopZ _res_conv_12_constr;
16033                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
16034                 if (_res_conv_12_constr.datalen > 0)
16035                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16036                 else
16037                         _res_conv_12_constr.data = NULL;
16038                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
16039                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
16040                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
16041                         LDKRouteHop _res_conv_12_conv_10_conv;
16042                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
16043                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
16044                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
16045                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
16046                 }
16047                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
16048                 _res_constr.data[m] = _res_conv_12_constr;
16049         }
16050         CVec_CVec_RouteHopZZ_free(_res_constr);
16051 }
16052
16053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16054         LDKRoute o_conv;
16055         o_conv.inner = (void*)(o & (~1));
16056         o_conv.is_owned = (o & 1) || (o == 0);
16057         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16058         o_conv = Route_clone(&o_conv);
16059         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16060         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
16061         return (int64_t)ret_conv;
16062 }
16063
16064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16065         LDKDecodeError e_conv;
16066         e_conv.inner = (void*)(e & (~1));
16067         e_conv.is_owned = (e & 1) || (e == 0);
16068         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16069         e_conv = DecodeError_clone(&e_conv);
16070         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16071         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
16072         return (int64_t)ret_conv;
16073 }
16074
16075 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16076         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
16077         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
16078         return ret_conv;
16079 }
16080
16081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16082         if ((_res & 1) != 0) return;
16083         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16084         CHECK_ACCESS(_res_ptr);
16085         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
16086         FREE((void*)_res);
16087         CResult_RouteDecodeErrorZ_free(_res_conv);
16088 }
16089
16090 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
16091         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16092         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
16093         return (int64_t)ret_conv;
16094 }
16095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16096         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
16097         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
16098         return ret_conv;
16099 }
16100
16101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16102         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
16103         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16104         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
16105         return (int64_t)ret_conv;
16106 }
16107
16108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16109         LDKRouteParameters o_conv;
16110         o_conv.inner = (void*)(o & (~1));
16111         o_conv.is_owned = (o & 1) || (o == 0);
16112         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16113         o_conv = RouteParameters_clone(&o_conv);
16114         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16115         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
16116         return (int64_t)ret_conv;
16117 }
16118
16119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16120         LDKDecodeError e_conv;
16121         e_conv.inner = (void*)(e & (~1));
16122         e_conv.is_owned = (e & 1) || (e == 0);
16123         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16124         e_conv = DecodeError_clone(&e_conv);
16125         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16126         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
16127         return (int64_t)ret_conv;
16128 }
16129
16130 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16131         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
16132         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
16133         return ret_conv;
16134 }
16135
16136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16137         if ((_res & 1) != 0) return;
16138         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16139         CHECK_ACCESS(_res_ptr);
16140         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
16141         FREE((void*)_res);
16142         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
16143 }
16144
16145 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
16146         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16147         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
16148         return (int64_t)ret_conv;
16149 }
16150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16151         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
16152         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
16153         return ret_conv;
16154 }
16155
16156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16157         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
16158         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16159         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
16160         return (int64_t)ret_conv;
16161 }
16162
16163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16164         LDKCVec_RouteHintZ _res_constr;
16165         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16166         if (_res_constr.datalen > 0)
16167                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
16168         else
16169                 _res_constr.data = NULL;
16170         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16171         for (size_t l = 0; l < _res_constr.datalen; l++) {
16172                 int64_t _res_conv_11 = _res_vals[l];
16173                 LDKRouteHint _res_conv_11_conv;
16174                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
16175                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
16176                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
16177                 _res_constr.data[l] = _res_conv_11_conv;
16178         }
16179         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16180         CVec_RouteHintZ_free(_res_constr);
16181 }
16182
16183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
16184         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16185         *ret_copy = COption_u64Z_some(o);
16186         int64_t ret_ref = (uintptr_t)ret_copy;
16187         return ret_ref;
16188 }
16189
16190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
16191         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16192         *ret_copy = COption_u64Z_none();
16193         int64_t ret_ref = (uintptr_t)ret_copy;
16194         return ret_ref;
16195 }
16196
16197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
16198         if ((_res & 1) != 0) return;
16199         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16200         CHECK_ACCESS(_res_ptr);
16201         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
16202         FREE((void*)_res);
16203         COption_u64Z_free(_res_conv);
16204 }
16205
16206 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
16207         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16208         *ret_copy = COption_u64Z_clone(arg);
16209 int64_t ret_ref = (uintptr_t)ret_copy;
16210         return ret_ref;
16211 }
16212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16213         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
16214         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
16215         return ret_conv;
16216 }
16217
16218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16219         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
16220         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16221         *ret_copy = COption_u64Z_clone(orig_conv);
16222         int64_t ret_ref = (uintptr_t)ret_copy;
16223         return ret_ref;
16224 }
16225
16226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16227         LDKCVec_u64Z _res_constr;
16228         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16229         if (_res_constr.datalen > 0)
16230                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16231         else
16232                 _res_constr.data = NULL;
16233         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16234         for (size_t g = 0; g < _res_constr.datalen; g++) {
16235                 int64_t _res_conv_6 = _res_vals[g];
16236                 _res_constr.data[g] = _res_conv_6;
16237         }
16238         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16239         CVec_u64Z_free(_res_constr);
16240 }
16241
16242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16243         LDKPaymentParameters o_conv;
16244         o_conv.inner = (void*)(o & (~1));
16245         o_conv.is_owned = (o & 1) || (o == 0);
16246         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16247         o_conv = PaymentParameters_clone(&o_conv);
16248         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16249         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
16250         return (int64_t)ret_conv;
16251 }
16252
16253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16254         LDKDecodeError e_conv;
16255         e_conv.inner = (void*)(e & (~1));
16256         e_conv.is_owned = (e & 1) || (e == 0);
16257         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16258         e_conv = DecodeError_clone(&e_conv);
16259         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16260         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
16261         return (int64_t)ret_conv;
16262 }
16263
16264 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16265         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
16266         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
16267         return ret_conv;
16268 }
16269
16270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16271         if ((_res & 1) != 0) return;
16272         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16273         CHECK_ACCESS(_res_ptr);
16274         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
16275         FREE((void*)_res);
16276         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
16277 }
16278
16279 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
16280         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16281         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
16282         return (int64_t)ret_conv;
16283 }
16284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16285         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
16286         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
16287         return ret_conv;
16288 }
16289
16290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16291         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
16292         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16293         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
16294         return (int64_t)ret_conv;
16295 }
16296
16297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16298         LDKCVec_RouteHintHopZ _res_constr;
16299         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16300         if (_res_constr.datalen > 0)
16301                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
16302         else
16303                 _res_constr.data = NULL;
16304         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16305         for (size_t o = 0; o < _res_constr.datalen; o++) {
16306                 int64_t _res_conv_14 = _res_vals[o];
16307                 LDKRouteHintHop _res_conv_14_conv;
16308                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
16309                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
16310                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
16311                 _res_constr.data[o] = _res_conv_14_conv;
16312         }
16313         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16314         CVec_RouteHintHopZ_free(_res_constr);
16315 }
16316
16317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16318         LDKRouteHint o_conv;
16319         o_conv.inner = (void*)(o & (~1));
16320         o_conv.is_owned = (o & 1) || (o == 0);
16321         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16322         o_conv = RouteHint_clone(&o_conv);
16323         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16324         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
16325         return (int64_t)ret_conv;
16326 }
16327
16328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16329         LDKDecodeError e_conv;
16330         e_conv.inner = (void*)(e & (~1));
16331         e_conv.is_owned = (e & 1) || (e == 0);
16332         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16333         e_conv = DecodeError_clone(&e_conv);
16334         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16335         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
16336         return (int64_t)ret_conv;
16337 }
16338
16339 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16340         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
16341         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
16342         return ret_conv;
16343 }
16344
16345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16346         if ((_res & 1) != 0) return;
16347         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16348         CHECK_ACCESS(_res_ptr);
16349         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
16350         FREE((void*)_res);
16351         CResult_RouteHintDecodeErrorZ_free(_res_conv);
16352 }
16353
16354 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
16355         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16356         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
16357         return (int64_t)ret_conv;
16358 }
16359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16360         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
16361         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
16362         return ret_conv;
16363 }
16364
16365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16366         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
16367         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16368         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
16369         return (int64_t)ret_conv;
16370 }
16371
16372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16373         LDKRouteHintHop o_conv;
16374         o_conv.inner = (void*)(o & (~1));
16375         o_conv.is_owned = (o & 1) || (o == 0);
16376         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16377         o_conv = RouteHintHop_clone(&o_conv);
16378         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16379         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
16380         return (int64_t)ret_conv;
16381 }
16382
16383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16384         LDKDecodeError e_conv;
16385         e_conv.inner = (void*)(e & (~1));
16386         e_conv.is_owned = (e & 1) || (e == 0);
16387         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16388         e_conv = DecodeError_clone(&e_conv);
16389         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16390         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
16391         return (int64_t)ret_conv;
16392 }
16393
16394 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16395         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
16396         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
16397         return ret_conv;
16398 }
16399
16400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16401         if ((_res & 1) != 0) return;
16402         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16403         CHECK_ACCESS(_res_ptr);
16404         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
16405         FREE((void*)_res);
16406         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
16407 }
16408
16409 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
16410         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16411         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
16412         return (int64_t)ret_conv;
16413 }
16414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16415         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
16416         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
16417         return ret_conv;
16418 }
16419
16420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16421         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
16422         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16423         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
16424         return (int64_t)ret_conv;
16425 }
16426
16427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16428         LDKCVec_ChannelDetailsZ _res_constr;
16429         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16430         if (_res_constr.datalen > 0)
16431                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
16432         else
16433                 _res_constr.data = NULL;
16434         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16435         for (size_t q = 0; q < _res_constr.datalen; q++) {
16436                 int64_t _res_conv_16 = _res_vals[q];
16437                 LDKChannelDetails _res_conv_16_conv;
16438                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
16439                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
16440                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
16441                 _res_constr.data[q] = _res_conv_16_conv;
16442         }
16443         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16444         CVec_ChannelDetailsZ_free(_res_constr);
16445 }
16446
16447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16448         LDKRoute o_conv;
16449         o_conv.inner = (void*)(o & (~1));
16450         o_conv.is_owned = (o & 1) || (o == 0);
16451         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16452         o_conv = Route_clone(&o_conv);
16453         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16454         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
16455         return (int64_t)ret_conv;
16456 }
16457
16458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16459         LDKLightningError e_conv;
16460         e_conv.inner = (void*)(e & (~1));
16461         e_conv.is_owned = (e & 1) || (e == 0);
16462         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16463         e_conv = LightningError_clone(&e_conv);
16464         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16465         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
16466         return (int64_t)ret_conv;
16467 }
16468
16469 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16470         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
16471         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
16472         return ret_conv;
16473 }
16474
16475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16476         if ((_res & 1) != 0) return;
16477         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16478         CHECK_ACCESS(_res_ptr);
16479         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
16480         FREE((void*)_res);
16481         CResult_RouteLightningErrorZ_free(_res_conv);
16482 }
16483
16484 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
16485         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16486         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
16487         return (int64_t)ret_conv;
16488 }
16489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16490         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
16491         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
16492         return ret_conv;
16493 }
16494
16495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16496         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
16497         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16498         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
16499         return (int64_t)ret_conv;
16500 }
16501
16502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16503         LDKCVec_PublicKeyZ _res_constr;
16504         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16505         if (_res_constr.datalen > 0)
16506                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16507         else
16508                 _res_constr.data = NULL;
16509         for (size_t i = 0; i < _res_constr.datalen; i++) {
16510                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16511                 LDKPublicKey _res_conv_8_ref;
16512                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
16513                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
16514                 _res_constr.data[i] = _res_conv_8_ref;
16515         }
16516         CVec_PublicKeyZ_free(_res_constr);
16517 }
16518
16519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16520         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16521         CHECK_ACCESS(o_ptr);
16522         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
16523         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)o) & ~1));
16524         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16525         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
16526         return (int64_t)ret_conv;
16527 }
16528
16529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16530         LDKDecodeError e_conv;
16531         e_conv.inner = (void*)(e & (~1));
16532         e_conv.is_owned = (e & 1) || (e == 0);
16533         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16534         e_conv = DecodeError_clone(&e_conv);
16535         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16536         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
16537         return (int64_t)ret_conv;
16538 }
16539
16540 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16541         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(o & ~1);
16542         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
16543         return ret_conv;
16544 }
16545
16546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16547         if ((_res & 1) != 0) return;
16548         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16549         CHECK_ACCESS(_res_ptr);
16550         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
16551         FREE((void*)_res);
16552         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
16553 }
16554
16555 static inline uintptr_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
16556         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16557         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
16558         return (int64_t)ret_conv;
16559 }
16560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16561         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(arg & ~1);
16562         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
16563         return ret_conv;
16564 }
16565
16566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16567         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(orig & ~1);
16568         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16569         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
16570         return (int64_t)ret_conv;
16571 }
16572
16573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16574         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16575         CHECK_ACCESS(o_ptr);
16576         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
16577         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
16578         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16579         *ret_copy = COption_ClosureReasonZ_some(o_conv);
16580         int64_t ret_ref = (uintptr_t)ret_copy;
16581         return ret_ref;
16582 }
16583
16584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
16585         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16586         *ret_copy = COption_ClosureReasonZ_none();
16587         int64_t ret_ref = (uintptr_t)ret_copy;
16588         return ret_ref;
16589 }
16590
16591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16592         if ((_res & 1) != 0) return;
16593         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16594         CHECK_ACCESS(_res_ptr);
16595         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
16596         FREE((void*)_res);
16597         COption_ClosureReasonZ_free(_res_conv);
16598 }
16599
16600 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
16601         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16602         *ret_copy = COption_ClosureReasonZ_clone(arg);
16603 int64_t ret_ref = (uintptr_t)ret_copy;
16604         return ret_ref;
16605 }
16606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16607         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
16608         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
16609         return ret_conv;
16610 }
16611
16612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16613         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
16614         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16615         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
16616         int64_t ret_ref = (uintptr_t)ret_copy;
16617         return ret_ref;
16618 }
16619
16620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16621         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16622         CHECK_ACCESS(o_ptr);
16623         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
16624         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
16625         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16626         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
16627         return (int64_t)ret_conv;
16628 }
16629
16630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16631         LDKDecodeError e_conv;
16632         e_conv.inner = (void*)(e & (~1));
16633         e_conv.is_owned = (e & 1) || (e == 0);
16634         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16635         e_conv = DecodeError_clone(&e_conv);
16636         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16637         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
16638         return (int64_t)ret_conv;
16639 }
16640
16641 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16642         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
16643         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
16644         return ret_conv;
16645 }
16646
16647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16648         if ((_res & 1) != 0) return;
16649         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16650         CHECK_ACCESS(_res_ptr);
16651         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
16652         FREE((void*)_res);
16653         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
16654 }
16655
16656 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
16657         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16658         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
16659         return (int64_t)ret_conv;
16660 }
16661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16662         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
16663         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
16664         return ret_conv;
16665 }
16666
16667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16668         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
16669         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16670         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
16671         return (int64_t)ret_conv;
16672 }
16673
16674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16675         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16676         CHECK_ACCESS(o_ptr);
16677         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
16678         o_conv = HTLCDestination_clone((LDKHTLCDestination*)(((uintptr_t)o) & ~1));
16679         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
16680         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
16681         int64_t ret_ref = (uintptr_t)ret_copy;
16682         return ret_ref;
16683 }
16684
16685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1none(JNIEnv *env, jclass clz) {
16686         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
16687         *ret_copy = COption_HTLCDestinationZ_none();
16688         int64_t ret_ref = (uintptr_t)ret_copy;
16689         return ret_ref;
16690 }
16691
16692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16693         if ((_res & 1) != 0) return;
16694         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16695         CHECK_ACCESS(_res_ptr);
16696         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
16697         FREE((void*)_res);
16698         COption_HTLCDestinationZ_free(_res_conv);
16699 }
16700
16701 static inline uintptr_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
16702         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
16703         *ret_copy = COption_HTLCDestinationZ_clone(arg);
16704 int64_t ret_ref = (uintptr_t)ret_copy;
16705         return ret_ref;
16706 }
16707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16708         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)arg;
16709         int64_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
16710         return ret_conv;
16711 }
16712
16713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16714         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)orig;
16715         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
16716         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
16717         int64_t ret_ref = (uintptr_t)ret_copy;
16718         return ret_ref;
16719 }
16720
16721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16722         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16723         CHECK_ACCESS(o_ptr);
16724         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
16725         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)(((uintptr_t)o) & ~1));
16726         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
16727         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
16728         return (int64_t)ret_conv;
16729 }
16730
16731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16732         LDKDecodeError e_conv;
16733         e_conv.inner = (void*)(e & (~1));
16734         e_conv.is_owned = (e & 1) || (e == 0);
16735         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16736         e_conv = DecodeError_clone(&e_conv);
16737         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
16738         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
16739         return (int64_t)ret_conv;
16740 }
16741
16742 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16743         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(o & ~1);
16744         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
16745         return ret_conv;
16746 }
16747
16748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16749         if ((_res & 1) != 0) return;
16750         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16751         CHECK_ACCESS(_res_ptr);
16752         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
16753         FREE((void*)_res);
16754         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
16755 }
16756
16757 static inline uintptr_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
16758         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
16759         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
16760         return (int64_t)ret_conv;
16761 }
16762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16763         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(arg & ~1);
16764         int64_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
16765         return ret_conv;
16766 }
16767
16768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16769         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(orig & ~1);
16770         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
16771         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
16772         return (int64_t)ret_conv;
16773 }
16774
16775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16776         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16777         CHECK_ACCESS(o_ptr);
16778         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
16779         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
16780         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16781         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
16782         int64_t ret_ref = (uintptr_t)ret_copy;
16783         return ret_ref;
16784 }
16785
16786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
16787         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16788         *ret_copy = COption_NetworkUpdateZ_none();
16789         int64_t ret_ref = (uintptr_t)ret_copy;
16790         return ret_ref;
16791 }
16792
16793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16794         if ((_res & 1) != 0) return;
16795         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16796         CHECK_ACCESS(_res_ptr);
16797         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
16798         FREE((void*)_res);
16799         COption_NetworkUpdateZ_free(_res_conv);
16800 }
16801
16802 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
16803         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16804         *ret_copy = COption_NetworkUpdateZ_clone(arg);
16805 int64_t ret_ref = (uintptr_t)ret_copy;
16806         return ret_ref;
16807 }
16808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16809         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
16810         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
16811         return ret_conv;
16812 }
16813
16814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16815         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
16816         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16817         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
16818         int64_t ret_ref = (uintptr_t)ret_copy;
16819         return ret_ref;
16820 }
16821
16822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16823         LDKCVec_SpendableOutputDescriptorZ _res_constr;
16824         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16825         if (_res_constr.datalen > 0)
16826                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16827         else
16828                 _res_constr.data = NULL;
16829         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16830         for (size_t b = 0; b < _res_constr.datalen; b++) {
16831                 int64_t _res_conv_27 = _res_vals[b];
16832                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
16833                 CHECK_ACCESS(_res_conv_27_ptr);
16834                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
16835                 FREE((void*)_res_conv_27);
16836                 _res_constr.data[b] = _res_conv_27_conv;
16837         }
16838         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16839         CVec_SpendableOutputDescriptorZ_free(_res_constr);
16840 }
16841
16842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16843         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16844         CHECK_ACCESS(o_ptr);
16845         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
16846         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
16847         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16848         *ret_copy = COption_EventZ_some(o_conv);
16849         int64_t ret_ref = (uintptr_t)ret_copy;
16850         return ret_ref;
16851 }
16852
16853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
16854         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16855         *ret_copy = COption_EventZ_none();
16856         int64_t ret_ref = (uintptr_t)ret_copy;
16857         return ret_ref;
16858 }
16859
16860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16861         if ((_res & 1) != 0) return;
16862         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16863         CHECK_ACCESS(_res_ptr);
16864         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
16865         FREE((void*)_res);
16866         COption_EventZ_free(_res_conv);
16867 }
16868
16869 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
16870         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16871         *ret_copy = COption_EventZ_clone(arg);
16872 int64_t ret_ref = (uintptr_t)ret_copy;
16873         return ret_ref;
16874 }
16875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16876         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
16877         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
16878         return ret_conv;
16879 }
16880
16881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16882         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
16883         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16884         *ret_copy = COption_EventZ_clone(orig_conv);
16885         int64_t ret_ref = (uintptr_t)ret_copy;
16886         return ret_ref;
16887 }
16888
16889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16890         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16891         CHECK_ACCESS(o_ptr);
16892         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
16893         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
16894         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16895         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
16896         return (int64_t)ret_conv;
16897 }
16898
16899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16900         LDKDecodeError e_conv;
16901         e_conv.inner = (void*)(e & (~1));
16902         e_conv.is_owned = (e & 1) || (e == 0);
16903         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16904         e_conv = DecodeError_clone(&e_conv);
16905         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16906         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
16907         return (int64_t)ret_conv;
16908 }
16909
16910 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16911         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
16912         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
16913         return ret_conv;
16914 }
16915
16916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16917         if ((_res & 1) != 0) return;
16918         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16919         CHECK_ACCESS(_res_ptr);
16920         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
16921         FREE((void*)_res);
16922         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
16923 }
16924
16925 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
16926         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16927         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
16928         return (int64_t)ret_conv;
16929 }
16930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16931         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
16932         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
16933         return ret_conv;
16934 }
16935
16936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16937         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
16938         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16939         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
16940         return (int64_t)ret_conv;
16941 }
16942
16943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16944         LDKCVec_MessageSendEventZ _res_constr;
16945         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16946         if (_res_constr.datalen > 0)
16947                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
16948         else
16949                 _res_constr.data = NULL;
16950         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16951         for (size_t s = 0; s < _res_constr.datalen; s++) {
16952                 int64_t _res_conv_18 = _res_vals[s];
16953                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
16954                 CHECK_ACCESS(_res_conv_18_ptr);
16955                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
16956                 FREE((void*)_res_conv_18);
16957                 _res_constr.data[s] = _res_conv_18_conv;
16958         }
16959         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16960         CVec_MessageSendEventZ_free(_res_constr);
16961 }
16962
16963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16964         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16965         CHECK_ACCESS(o_ptr);
16966         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
16967         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
16968         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16969         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
16970         return (int64_t)ret_conv;
16971 }
16972
16973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16974         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
16975         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16976         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
16977         return (int64_t)ret_conv;
16978 }
16979
16980 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16981         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
16982         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
16983         return ret_conv;
16984 }
16985
16986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16987         if ((_res & 1) != 0) return;
16988         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16989         CHECK_ACCESS(_res_ptr);
16990         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
16991         FREE((void*)_res);
16992         CResult_TxOutAccessErrorZ_free(_res_conv);
16993 }
16994
16995 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
16996         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16997         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
16998         return (int64_t)ret_conv;
16999 }
17000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17001         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
17002         int64_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
17003         return ret_conv;
17004 }
17005
17006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17007         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
17008         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
17009         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
17010         return (int64_t)ret_conv;
17011 }
17012
17013 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
17014         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17015         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
17016         return ((int64_t)ret_conv);
17017 }
17018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17019         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
17020         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
17021         return ret_conv;
17022 }
17023
17024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17025         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
17026         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17027         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
17028         return ((int64_t)ret_conv);
17029 }
17030
17031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
17032         LDKTransaction b_ref;
17033         b_ref.datalen = (*env)->GetArrayLength(env, b);
17034         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
17035         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
17036         b_ref.data_is_owned = true;
17037         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17038         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
17039         return ((int64_t)ret_conv);
17040 }
17041
17042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17043         if ((_res & 1) != 0) return;
17044         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17045         CHECK_ACCESS(_res_ptr);
17046         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
17047         FREE((void*)_res);
17048         C2Tuple_usizeTransactionZ_free(_res_conv);
17049 }
17050
17051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17052         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
17053         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17054         if (_res_constr.datalen > 0)
17055                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
17056         else
17057                 _res_constr.data = NULL;
17058         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17059         for (size_t c = 0; c < _res_constr.datalen; c++) {
17060                 int64_t _res_conv_28 = _res_vals[c];
17061                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
17062                 CHECK_ACCESS(_res_conv_28_ptr);
17063                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
17064                 FREE((void*)_res_conv_28);
17065                 _res_constr.data[c] = _res_conv_28_conv;
17066         }
17067         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17068         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
17069 }
17070
17071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17072         LDKCVec_TxidZ _res_constr;
17073         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17074         if (_res_constr.datalen > 0)
17075                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
17076         else
17077                 _res_constr.data = NULL;
17078         for (size_t i = 0; i < _res_constr.datalen; i++) {
17079                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
17080                 LDKThirtyTwoBytes _res_conv_8_ref;
17081                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
17082                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
17083                 _res_constr.data[i] = _res_conv_8_ref;
17084         }
17085         CVec_TxidZ_free(_res_constr);
17086 }
17087
17088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
17089         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
17090         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
17091         return (int64_t)ret_conv;
17092 }
17093
17094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
17095         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
17096         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
17097         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
17098         return (int64_t)ret_conv;
17099 }
17100
17101 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17102         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
17103         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
17104         return ret_conv;
17105 }
17106
17107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17108         if ((_res & 1) != 0) return;
17109         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17110         CHECK_ACCESS(_res_ptr);
17111         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
17112         FREE((void*)_res);
17113         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
17114 }
17115
17116 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
17117         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
17118         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
17119         return (int64_t)ret_conv;
17120 }
17121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17122         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
17123         int64_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
17124         return ret_conv;
17125 }
17126
17127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17128         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
17129         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
17130         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
17131         return (int64_t)ret_conv;
17132 }
17133
17134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17135         LDKCVec_MonitorEventZ _res_constr;
17136         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17137         if (_res_constr.datalen > 0)
17138                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
17139         else
17140                 _res_constr.data = NULL;
17141         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17142         for (size_t o = 0; o < _res_constr.datalen; o++) {
17143                 int64_t _res_conv_14 = _res_vals[o];
17144                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
17145                 CHECK_ACCESS(_res_conv_14_ptr);
17146                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
17147                 FREE((void*)_res_conv_14);
17148                 _res_constr.data[o] = _res_conv_14_conv;
17149         }
17150         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17151         CVec_MonitorEventZ_free(_res_constr);
17152 }
17153
17154 static inline uintptr_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
17155         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17156         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
17157         return ((int64_t)ret_conv);
17158 }
17159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17160         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(arg & ~1);
17161         int64_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
17162         return ret_conv;
17163 }
17164
17165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17166         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(orig & ~1);
17167         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17168         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
17169         return ((int64_t)ret_conv);
17170 }
17171
17172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_tArray b, int8_tArray c) {
17173         LDKOutPoint a_conv;
17174         a_conv.inner = (void*)(a & (~1));
17175         a_conv.is_owned = (a & 1) || (a == 0);
17176         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17177         a_conv = OutPoint_clone(&a_conv);
17178         LDKCVec_MonitorEventZ b_constr;
17179         b_constr.datalen = (*env)->GetArrayLength(env, b);
17180         if (b_constr.datalen > 0)
17181                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
17182         else
17183                 b_constr.data = NULL;
17184         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
17185         for (size_t o = 0; o < b_constr.datalen; o++) {
17186                 int64_t b_conv_14 = b_vals[o];
17187                 void* b_conv_14_ptr = (void*)(((uintptr_t)b_conv_14) & ~1);
17188                 CHECK_ACCESS(b_conv_14_ptr);
17189                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
17190                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)b_conv_14) & ~1));
17191                 b_constr.data[o] = b_conv_14_conv;
17192         }
17193         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
17194         LDKPublicKey c_ref;
17195         CHECK((*env)->GetArrayLength(env, c) == 33);
17196         (*env)->GetByteArrayRegion(env, c, 0, 33, c_ref.compressed_form);
17197         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17198         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
17199         return ((int64_t)ret_conv);
17200 }
17201
17202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17203         if ((_res & 1) != 0) return;
17204         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17205         CHECK_ACCESS(_res_ptr);
17206         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
17207         FREE((void*)_res);
17208         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
17209 }
17210
17211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17212         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
17213         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17214         if (_res_constr.datalen > 0)
17215                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
17216         else
17217                 _res_constr.data = NULL;
17218         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17219         for (size_t x = 0; x < _res_constr.datalen; x++) {
17220                 int64_t _res_conv_49 = _res_vals[x];
17221                 void* _res_conv_49_ptr = (void*)(((uintptr_t)_res_conv_49) & ~1);
17222                 CHECK_ACCESS(_res_conv_49_ptr);
17223                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
17224                 FREE((void*)_res_conv_49);
17225                 _res_constr.data[x] = _res_conv_49_conv;
17226         }
17227         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17228         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
17229 }
17230
17231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17232         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17233         CHECK_ACCESS(o_ptr);
17234         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
17235         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
17236         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
17237         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
17238         int64_t ret_ref = (uintptr_t)ret_copy;
17239         return ret_ref;
17240 }
17241
17242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
17243         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
17244         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
17245         int64_t ret_ref = (uintptr_t)ret_copy;
17246         return ret_ref;
17247 }
17248
17249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17250         if ((_res & 1) != 0) return;
17251         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17252         CHECK_ACCESS(_res_ptr);
17253         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
17254         FREE((void*)_res);
17255         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
17256 }
17257
17258 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
17259         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
17260         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
17261 int64_t ret_ref = (uintptr_t)ret_copy;
17262         return ret_ref;
17263 }
17264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17265         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
17266         int64_t ret_conv = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
17267         return ret_conv;
17268 }
17269
17270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17271         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
17272         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
17273         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
17274         int64_t ret_ref = (uintptr_t)ret_copy;
17275         return ret_ref;
17276 }
17277
17278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17279         LDKFixedPenaltyScorer o_conv;
17280         o_conv.inner = (void*)(o & (~1));
17281         o_conv.is_owned = (o & 1) || (o == 0);
17282         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17283         o_conv = FixedPenaltyScorer_clone(&o_conv);
17284         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17285         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
17286         return (int64_t)ret_conv;
17287 }
17288
17289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17290         LDKDecodeError e_conv;
17291         e_conv.inner = (void*)(e & (~1));
17292         e_conv.is_owned = (e & 1) || (e == 0);
17293         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17294         e_conv = DecodeError_clone(&e_conv);
17295         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17296         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
17297         return (int64_t)ret_conv;
17298 }
17299
17300 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17301         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
17302         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
17303         return ret_conv;
17304 }
17305
17306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17307         if ((_res & 1) != 0) return;
17308         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17309         CHECK_ACCESS(_res_ptr);
17310         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
17311         FREE((void*)_res);
17312         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
17313 }
17314
17315 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
17316         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17317         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
17318         return (int64_t)ret_conv;
17319 }
17320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17321         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
17322         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
17323         return ret_conv;
17324 }
17325
17326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17327         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
17328         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17329         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
17330         return (int64_t)ret_conv;
17331 }
17332
17333 static inline uintptr_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
17334         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17335         *ret_conv = C2Tuple_u64u64Z_clone(arg);
17336         return ((int64_t)ret_conv);
17337 }
17338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17339         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)(arg & ~1);
17340         int64_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
17341         return ret_conv;
17342 }
17343
17344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17345         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)(orig & ~1);
17346         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17347         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
17348         return ((int64_t)ret_conv);
17349 }
17350
17351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
17352         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17353         *ret_conv = C2Tuple_u64u64Z_new(a, b);
17354         return ((int64_t)ret_conv);
17355 }
17356
17357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
17358         if ((_res & 1) != 0) return;
17359         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17360         CHECK_ACCESS(_res_ptr);
17361         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
17362         FREE((void*)_res);
17363         C2Tuple_u64u64Z_free(_res_conv);
17364 }
17365
17366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17367         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17368         CHECK_ACCESS(o_ptr);
17369         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
17370         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)(((uintptr_t)o) & ~1));
17371         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17372         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
17373         int64_t ret_ref = (uintptr_t)ret_copy;
17374         return ret_ref;
17375 }
17376
17377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1none(JNIEnv *env, jclass clz) {
17378         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17379         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
17380         int64_t ret_ref = (uintptr_t)ret_copy;
17381         return ret_ref;
17382 }
17383
17384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17385         if ((_res & 1) != 0) return;
17386         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17387         CHECK_ACCESS(_res_ptr);
17388         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
17389         FREE((void*)_res);
17390         COption_C2Tuple_u64u64ZZ_free(_res_conv);
17391 }
17392
17393 static inline uintptr_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
17394         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17395         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
17396 int64_t ret_ref = (uintptr_t)ret_copy;
17397         return ret_ref;
17398 }
17399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17400         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)arg;
17401         int64_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
17402         return ret_conv;
17403 }
17404
17405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17406         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)orig;
17407         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17408         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
17409         int64_t ret_ref = (uintptr_t)ret_copy;
17410         return ret_ref;
17411 }
17412
17413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17414         LDKCVec_NodeIdZ _res_constr;
17415         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17416         if (_res_constr.datalen > 0)
17417                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
17418         else
17419                 _res_constr.data = NULL;
17420         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17421         for (size_t i = 0; i < _res_constr.datalen; i++) {
17422                 int64_t _res_conv_8 = _res_vals[i];
17423                 LDKNodeId _res_conv_8_conv;
17424                 _res_conv_8_conv.inner = (void*)(_res_conv_8 & (~1));
17425                 _res_conv_8_conv.is_owned = (_res_conv_8 & 1) || (_res_conv_8 == 0);
17426                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
17427                 _res_constr.data[i] = _res_conv_8_conv;
17428         }
17429         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17430         CVec_NodeIdZ_free(_res_constr);
17431 }
17432
17433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17434         LDKProbabilisticScorer o_conv;
17435         o_conv.inner = (void*)(o & (~1));
17436         o_conv.is_owned = (o & 1) || (o == 0);
17437         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17438         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
17439         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
17440         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
17441         return (int64_t)ret_conv;
17442 }
17443
17444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17445         LDKDecodeError e_conv;
17446         e_conv.inner = (void*)(e & (~1));
17447         e_conv.is_owned = (e & 1) || (e == 0);
17448         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17449         e_conv = DecodeError_clone(&e_conv);
17450         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
17451         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
17452         return (int64_t)ret_conv;
17453 }
17454
17455 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17456         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
17457         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
17458         return ret_conv;
17459 }
17460
17461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17462         if ((_res & 1) != 0) return;
17463         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17464         CHECK_ACCESS(_res_ptr);
17465         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
17466         FREE((void*)_res);
17467         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
17468 }
17469
17470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17471         LDKInitFeatures o_conv;
17472         o_conv.inner = (void*)(o & (~1));
17473         o_conv.is_owned = (o & 1) || (o == 0);
17474         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17475         o_conv = InitFeatures_clone(&o_conv);
17476         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17477         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
17478         return (int64_t)ret_conv;
17479 }
17480
17481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17482         LDKDecodeError e_conv;
17483         e_conv.inner = (void*)(e & (~1));
17484         e_conv.is_owned = (e & 1) || (e == 0);
17485         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17486         e_conv = DecodeError_clone(&e_conv);
17487         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17488         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
17489         return (int64_t)ret_conv;
17490 }
17491
17492 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17493         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
17494         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
17495         return ret_conv;
17496 }
17497
17498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17499         if ((_res & 1) != 0) return;
17500         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17501         CHECK_ACCESS(_res_ptr);
17502         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
17503         FREE((void*)_res);
17504         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
17505 }
17506
17507 static inline uintptr_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17508         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17509         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
17510         return (int64_t)ret_conv;
17511 }
17512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17513         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
17514         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17515         return ret_conv;
17516 }
17517
17518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17519         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(orig & ~1);
17520         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17521         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
17522         return (int64_t)ret_conv;
17523 }
17524
17525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17526         LDKChannelFeatures o_conv;
17527         o_conv.inner = (void*)(o & (~1));
17528         o_conv.is_owned = (o & 1) || (o == 0);
17529         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17530         o_conv = ChannelFeatures_clone(&o_conv);
17531         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17532         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
17533         return (int64_t)ret_conv;
17534 }
17535
17536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17537         LDKDecodeError e_conv;
17538         e_conv.inner = (void*)(e & (~1));
17539         e_conv.is_owned = (e & 1) || (e == 0);
17540         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17541         e_conv = DecodeError_clone(&e_conv);
17542         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17543         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
17544         return (int64_t)ret_conv;
17545 }
17546
17547 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17548         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
17549         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
17550         return ret_conv;
17551 }
17552
17553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17554         if ((_res & 1) != 0) return;
17555         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17556         CHECK_ACCESS(_res_ptr);
17557         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
17558         FREE((void*)_res);
17559         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
17560 }
17561
17562 static inline uintptr_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17563         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17564         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
17565         return (int64_t)ret_conv;
17566 }
17567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17568         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
17569         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17570         return ret_conv;
17571 }
17572
17573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17574         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(orig & ~1);
17575         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17576         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
17577         return (int64_t)ret_conv;
17578 }
17579
17580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17581         LDKNodeFeatures o_conv;
17582         o_conv.inner = (void*)(o & (~1));
17583         o_conv.is_owned = (o & 1) || (o == 0);
17584         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17585         o_conv = NodeFeatures_clone(&o_conv);
17586         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17587         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
17588         return (int64_t)ret_conv;
17589 }
17590
17591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17592         LDKDecodeError e_conv;
17593         e_conv.inner = (void*)(e & (~1));
17594         e_conv.is_owned = (e & 1) || (e == 0);
17595         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17596         e_conv = DecodeError_clone(&e_conv);
17597         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17598         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
17599         return (int64_t)ret_conv;
17600 }
17601
17602 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17603         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
17604         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
17605         return ret_conv;
17606 }
17607
17608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17609         if ((_res & 1) != 0) return;
17610         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17611         CHECK_ACCESS(_res_ptr);
17612         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
17613         FREE((void*)_res);
17614         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
17615 }
17616
17617 static inline uintptr_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17618         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17619         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
17620         return (int64_t)ret_conv;
17621 }
17622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17623         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
17624         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17625         return ret_conv;
17626 }
17627
17628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17629         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(orig & ~1);
17630         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17631         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
17632         return (int64_t)ret_conv;
17633 }
17634
17635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17636         LDKInvoiceFeatures o_conv;
17637         o_conv.inner = (void*)(o & (~1));
17638         o_conv.is_owned = (o & 1) || (o == 0);
17639         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17640         o_conv = InvoiceFeatures_clone(&o_conv);
17641         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17642         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
17643         return (int64_t)ret_conv;
17644 }
17645
17646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17647         LDKDecodeError e_conv;
17648         e_conv.inner = (void*)(e & (~1));
17649         e_conv.is_owned = (e & 1) || (e == 0);
17650         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17651         e_conv = DecodeError_clone(&e_conv);
17652         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17653         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
17654         return (int64_t)ret_conv;
17655 }
17656
17657 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17658         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
17659         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
17660         return ret_conv;
17661 }
17662
17663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17664         if ((_res & 1) != 0) return;
17665         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17666         CHECK_ACCESS(_res_ptr);
17667         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
17668         FREE((void*)_res);
17669         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
17670 }
17671
17672 static inline uintptr_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17673         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17674         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
17675         return (int64_t)ret_conv;
17676 }
17677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17678         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
17679         int64_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17680         return ret_conv;
17681 }
17682
17683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17684         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(orig & ~1);
17685         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17686         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
17687         return (int64_t)ret_conv;
17688 }
17689
17690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17691         LDKChannelTypeFeatures o_conv;
17692         o_conv.inner = (void*)(o & (~1));
17693         o_conv.is_owned = (o & 1) || (o == 0);
17694         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17695         o_conv = ChannelTypeFeatures_clone(&o_conv);
17696         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17697         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
17698         return (int64_t)ret_conv;
17699 }
17700
17701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17702         LDKDecodeError e_conv;
17703         e_conv.inner = (void*)(e & (~1));
17704         e_conv.is_owned = (e & 1) || (e == 0);
17705         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17706         e_conv = DecodeError_clone(&e_conv);
17707         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17708         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
17709         return (int64_t)ret_conv;
17710 }
17711
17712 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17713         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
17714         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
17715         return ret_conv;
17716 }
17717
17718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17719         if ((_res & 1) != 0) return;
17720         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17721         CHECK_ACCESS(_res_ptr);
17722         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
17723         FREE((void*)_res);
17724         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
17725 }
17726
17727 static inline uintptr_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17728         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17729         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
17730         return (int64_t)ret_conv;
17731 }
17732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17733         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(arg & ~1);
17734         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17735         return ret_conv;
17736 }
17737
17738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17739         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(orig & ~1);
17740         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17741         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
17742         return (int64_t)ret_conv;
17743 }
17744
17745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17746         LDKNodeId o_conv;
17747         o_conv.inner = (void*)(o & (~1));
17748         o_conv.is_owned = (o & 1) || (o == 0);
17749         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17750         o_conv = NodeId_clone(&o_conv);
17751         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17752         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
17753         return (int64_t)ret_conv;
17754 }
17755
17756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17757         LDKDecodeError e_conv;
17758         e_conv.inner = (void*)(e & (~1));
17759         e_conv.is_owned = (e & 1) || (e == 0);
17760         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17761         e_conv = DecodeError_clone(&e_conv);
17762         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17763         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
17764         return (int64_t)ret_conv;
17765 }
17766
17767 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17768         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
17769         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
17770         return ret_conv;
17771 }
17772
17773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17774         if ((_res & 1) != 0) return;
17775         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17776         CHECK_ACCESS(_res_ptr);
17777         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
17778         FREE((void*)_res);
17779         CResult_NodeIdDecodeErrorZ_free(_res_conv);
17780 }
17781
17782 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
17783         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17784         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
17785         return (int64_t)ret_conv;
17786 }
17787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17788         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
17789         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
17790         return ret_conv;
17791 }
17792
17793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17794         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
17795         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17796         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
17797         return (int64_t)ret_conv;
17798 }
17799
17800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17801         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17802         CHECK_ACCESS(o_ptr);
17803         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
17804         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
17805         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17806         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
17807         return (int64_t)ret_conv;
17808 }
17809
17810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17811         LDKDecodeError e_conv;
17812         e_conv.inner = (void*)(e & (~1));
17813         e_conv.is_owned = (e & 1) || (e == 0);
17814         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17815         e_conv = DecodeError_clone(&e_conv);
17816         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17817         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
17818         return (int64_t)ret_conv;
17819 }
17820
17821 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17822         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
17823         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
17824         return ret_conv;
17825 }
17826
17827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17828         if ((_res & 1) != 0) return;
17829         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17830         CHECK_ACCESS(_res_ptr);
17831         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
17832         FREE((void*)_res);
17833         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
17834 }
17835
17836 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
17837         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17838         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
17839         return (int64_t)ret_conv;
17840 }
17841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17842         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
17843         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
17844         return ret_conv;
17845 }
17846
17847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17848         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
17849         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17850         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
17851         return (int64_t)ret_conv;
17852 }
17853
17854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17855         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17856         CHECK_ACCESS(o_ptr);
17857         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
17858         if (o_conv.free == LDKAccess_JCalls_free) {
17859                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17860                 LDKAccess_JCalls_cloned(&o_conv);
17861         }
17862         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
17863         *ret_copy = COption_AccessZ_some(o_conv);
17864         int64_t ret_ref = (uintptr_t)ret_copy;
17865         return ret_ref;
17866 }
17867
17868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
17869         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
17870         *ret_copy = COption_AccessZ_none();
17871         int64_t ret_ref = (uintptr_t)ret_copy;
17872         return ret_ref;
17873 }
17874
17875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17876         if ((_res & 1) != 0) return;
17877         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17878         CHECK_ACCESS(_res_ptr);
17879         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
17880         FREE((void*)_res);
17881         COption_AccessZ_free(_res_conv);
17882 }
17883
17884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
17885         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17886         *ret_conv = CResult_boolLightningErrorZ_ok(o);
17887         return (int64_t)ret_conv;
17888 }
17889
17890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17891         LDKLightningError e_conv;
17892         e_conv.inner = (void*)(e & (~1));
17893         e_conv.is_owned = (e & 1) || (e == 0);
17894         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17895         e_conv = LightningError_clone(&e_conv);
17896         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17897         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
17898         return (int64_t)ret_conv;
17899 }
17900
17901 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17902         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
17903         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
17904         return ret_conv;
17905 }
17906
17907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17908         if ((_res & 1) != 0) return;
17909         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17910         CHECK_ACCESS(_res_ptr);
17911         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
17912         FREE((void*)_res);
17913         CResult_boolLightningErrorZ_free(_res_conv);
17914 }
17915
17916 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
17917         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17918         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
17919         return (int64_t)ret_conv;
17920 }
17921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17922         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
17923         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
17924         return ret_conv;
17925 }
17926
17927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17928         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
17929         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17930         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
17931         return (int64_t)ret_conv;
17932 }
17933
17934 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
17935         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17936         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
17937         return ((int64_t)ret_conv);
17938 }
17939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17940         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
17941         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
17942         return ret_conv;
17943 }
17944
17945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17946         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
17947         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17948         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
17949         return ((int64_t)ret_conv);
17950 }
17951
17952 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) {
17953         LDKChannelAnnouncement a_conv;
17954         a_conv.inner = (void*)(a & (~1));
17955         a_conv.is_owned = (a & 1) || (a == 0);
17956         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17957         a_conv = ChannelAnnouncement_clone(&a_conv);
17958         LDKChannelUpdate b_conv;
17959         b_conv.inner = (void*)(b & (~1));
17960         b_conv.is_owned = (b & 1) || (b == 0);
17961         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
17962         b_conv = ChannelUpdate_clone(&b_conv);
17963         LDKChannelUpdate c_conv;
17964         c_conv.inner = (void*)(c & (~1));
17965         c_conv.is_owned = (c & 1) || (c == 0);
17966         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
17967         c_conv = ChannelUpdate_clone(&c_conv);
17968         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17969         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
17970         return ((int64_t)ret_conv);
17971 }
17972
17973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17974         if ((_res & 1) != 0) return;
17975         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17976         CHECK_ACCESS(_res_ptr);
17977         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
17978         FREE((void*)_res);
17979         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
17980 }
17981
17982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17983         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
17984         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17985         if (_res_constr.datalen > 0)
17986                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
17987         else
17988                 _res_constr.data = NULL;
17989         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17990         for (size_t h = 0; h < _res_constr.datalen; h++) {
17991                 int64_t _res_conv_59 = _res_vals[h];
17992                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
17993                 CHECK_ACCESS(_res_conv_59_ptr);
17994                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
17995                 FREE((void*)_res_conv_59);
17996                 _res_constr.data[h] = _res_conv_59_conv;
17997         }
17998         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17999         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
18000 }
18001
18002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18003         LDKCVec_NodeAnnouncementZ _res_constr;
18004         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18005         if (_res_constr.datalen > 0)
18006                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
18007         else
18008                 _res_constr.data = NULL;
18009         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18010         for (size_t s = 0; s < _res_constr.datalen; s++) {
18011                 int64_t _res_conv_18 = _res_vals[s];
18012                 LDKNodeAnnouncement _res_conv_18_conv;
18013                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
18014                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
18015                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
18016                 _res_constr.data[s] = _res_conv_18_conv;
18017         }
18018         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18019         CVec_NodeAnnouncementZ_free(_res_constr);
18020 }
18021
18022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
18023         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18024         *ret_conv = CResult_NoneLightningErrorZ_ok();
18025         return (int64_t)ret_conv;
18026 }
18027
18028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18029         LDKLightningError e_conv;
18030         e_conv.inner = (void*)(e & (~1));
18031         e_conv.is_owned = (e & 1) || (e == 0);
18032         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18033         e_conv = LightningError_clone(&e_conv);
18034         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18035         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
18036         return (int64_t)ret_conv;
18037 }
18038
18039 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18040         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
18041         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
18042         return ret_conv;
18043 }
18044
18045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18046         if ((_res & 1) != 0) return;
18047         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18048         CHECK_ACCESS(_res_ptr);
18049         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
18050         FREE((void*)_res);
18051         CResult_NoneLightningErrorZ_free(_res_conv);
18052 }
18053
18054 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
18055         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18056         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
18057         return (int64_t)ret_conv;
18058 }
18059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18060         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
18061         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
18062         return ret_conv;
18063 }
18064
18065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18066         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
18067         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18068         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
18069         return (int64_t)ret_conv;
18070 }
18071
18072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18073         LDKChannelUpdateInfo o_conv;
18074         o_conv.inner = (void*)(o & (~1));
18075         o_conv.is_owned = (o & 1) || (o == 0);
18076         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18077         o_conv = ChannelUpdateInfo_clone(&o_conv);
18078         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18079         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
18080         return (int64_t)ret_conv;
18081 }
18082
18083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18084         LDKDecodeError e_conv;
18085         e_conv.inner = (void*)(e & (~1));
18086         e_conv.is_owned = (e & 1) || (e == 0);
18087         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18088         e_conv = DecodeError_clone(&e_conv);
18089         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18090         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
18091         return (int64_t)ret_conv;
18092 }
18093
18094 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18095         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
18096         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
18097         return ret_conv;
18098 }
18099
18100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18101         if ((_res & 1) != 0) return;
18102         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18103         CHECK_ACCESS(_res_ptr);
18104         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
18105         FREE((void*)_res);
18106         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
18107 }
18108
18109 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
18110         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18111         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
18112         return (int64_t)ret_conv;
18113 }
18114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18115         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
18116         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
18117         return ret_conv;
18118 }
18119
18120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18121         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
18122         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18123         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
18124         return (int64_t)ret_conv;
18125 }
18126
18127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18128         LDKChannelInfo o_conv;
18129         o_conv.inner = (void*)(o & (~1));
18130         o_conv.is_owned = (o & 1) || (o == 0);
18131         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18132         o_conv = ChannelInfo_clone(&o_conv);
18133         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18134         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
18135         return (int64_t)ret_conv;
18136 }
18137
18138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18139         LDKDecodeError e_conv;
18140         e_conv.inner = (void*)(e & (~1));
18141         e_conv.is_owned = (e & 1) || (e == 0);
18142         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18143         e_conv = DecodeError_clone(&e_conv);
18144         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18145         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
18146         return (int64_t)ret_conv;
18147 }
18148
18149 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18150         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
18151         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
18152         return ret_conv;
18153 }
18154
18155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18156         if ((_res & 1) != 0) return;
18157         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18158         CHECK_ACCESS(_res_ptr);
18159         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
18160         FREE((void*)_res);
18161         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
18162 }
18163
18164 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
18165         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18166         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
18167         return (int64_t)ret_conv;
18168 }
18169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18170         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
18171         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
18172         return ret_conv;
18173 }
18174
18175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18176         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
18177         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18178         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
18179         return (int64_t)ret_conv;
18180 }
18181
18182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18183         LDKRoutingFees o_conv;
18184         o_conv.inner = (void*)(o & (~1));
18185         o_conv.is_owned = (o & 1) || (o == 0);
18186         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18187         o_conv = RoutingFees_clone(&o_conv);
18188         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18189         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
18190         return (int64_t)ret_conv;
18191 }
18192
18193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18194         LDKDecodeError e_conv;
18195         e_conv.inner = (void*)(e & (~1));
18196         e_conv.is_owned = (e & 1) || (e == 0);
18197         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18198         e_conv = DecodeError_clone(&e_conv);
18199         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18200         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
18201         return (int64_t)ret_conv;
18202 }
18203
18204 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18205         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
18206         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
18207         return ret_conv;
18208 }
18209
18210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18211         if ((_res & 1) != 0) return;
18212         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18213         CHECK_ACCESS(_res_ptr);
18214         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
18215         FREE((void*)_res);
18216         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
18217 }
18218
18219 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
18220         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18221         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
18222         return (int64_t)ret_conv;
18223 }
18224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18225         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
18226         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
18227         return ret_conv;
18228 }
18229
18230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18231         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
18232         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18233         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
18234         return (int64_t)ret_conv;
18235 }
18236
18237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18238         LDKCVec_NetAddressZ _res_constr;
18239         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18240         if (_res_constr.datalen > 0)
18241                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18242         else
18243                 _res_constr.data = NULL;
18244         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18245         for (size_t m = 0; m < _res_constr.datalen; m++) {
18246                 int64_t _res_conv_12 = _res_vals[m];
18247                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
18248                 CHECK_ACCESS(_res_conv_12_ptr);
18249                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
18250                 FREE((void*)_res_conv_12);
18251                 _res_constr.data[m] = _res_conv_12_conv;
18252         }
18253         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18254         CVec_NetAddressZ_free(_res_constr);
18255 }
18256
18257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18258         LDKNodeAnnouncementInfo o_conv;
18259         o_conv.inner = (void*)(o & (~1));
18260         o_conv.is_owned = (o & 1) || (o == 0);
18261         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18262         o_conv = NodeAnnouncementInfo_clone(&o_conv);
18263         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18264         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
18265         return (int64_t)ret_conv;
18266 }
18267
18268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18269         LDKDecodeError e_conv;
18270         e_conv.inner = (void*)(e & (~1));
18271         e_conv.is_owned = (e & 1) || (e == 0);
18272         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18273         e_conv = DecodeError_clone(&e_conv);
18274         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18275         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
18276         return (int64_t)ret_conv;
18277 }
18278
18279 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18280         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
18281         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
18282         return ret_conv;
18283 }
18284
18285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18286         if ((_res & 1) != 0) return;
18287         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18288         CHECK_ACCESS(_res_ptr);
18289         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
18290         FREE((void*)_res);
18291         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
18292 }
18293
18294 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
18295         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18296         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
18297         return (int64_t)ret_conv;
18298 }
18299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18300         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
18301         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
18302         return ret_conv;
18303 }
18304
18305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18306         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
18307         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18308         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
18309         return (int64_t)ret_conv;
18310 }
18311
18312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18313         LDKNodeAlias o_conv;
18314         o_conv.inner = (void*)(o & (~1));
18315         o_conv.is_owned = (o & 1) || (o == 0);
18316         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18317         o_conv = NodeAlias_clone(&o_conv);
18318         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18319         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
18320         return (int64_t)ret_conv;
18321 }
18322
18323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18324         LDKDecodeError e_conv;
18325         e_conv.inner = (void*)(e & (~1));
18326         e_conv.is_owned = (e & 1) || (e == 0);
18327         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18328         e_conv = DecodeError_clone(&e_conv);
18329         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18330         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
18331         return (int64_t)ret_conv;
18332 }
18333
18334 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18335         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(o & ~1);
18336         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
18337         return ret_conv;
18338 }
18339
18340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18341         if ((_res & 1) != 0) return;
18342         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18343         CHECK_ACCESS(_res_ptr);
18344         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
18345         FREE((void*)_res);
18346         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
18347 }
18348
18349 static inline uintptr_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
18350         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18351         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
18352         return (int64_t)ret_conv;
18353 }
18354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18355         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(arg & ~1);
18356         int64_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
18357         return ret_conv;
18358 }
18359
18360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18361         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(orig & ~1);
18362         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18363         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
18364         return (int64_t)ret_conv;
18365 }
18366
18367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18368         LDKNodeInfo o_conv;
18369         o_conv.inner = (void*)(o & (~1));
18370         o_conv.is_owned = (o & 1) || (o == 0);
18371         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18372         o_conv = NodeInfo_clone(&o_conv);
18373         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18374         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
18375         return (int64_t)ret_conv;
18376 }
18377
18378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18379         LDKDecodeError e_conv;
18380         e_conv.inner = (void*)(e & (~1));
18381         e_conv.is_owned = (e & 1) || (e == 0);
18382         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18383         e_conv = DecodeError_clone(&e_conv);
18384         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18385         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
18386         return (int64_t)ret_conv;
18387 }
18388
18389 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18390         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
18391         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
18392         return ret_conv;
18393 }
18394
18395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18396         if ((_res & 1) != 0) return;
18397         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18398         CHECK_ACCESS(_res_ptr);
18399         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
18400         FREE((void*)_res);
18401         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
18402 }
18403
18404 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
18405         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18406         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
18407         return (int64_t)ret_conv;
18408 }
18409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18410         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
18411         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
18412         return ret_conv;
18413 }
18414
18415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18416         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
18417         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18418         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
18419         return (int64_t)ret_conv;
18420 }
18421
18422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18423         LDKNetworkGraph o_conv;
18424         o_conv.inner = (void*)(o & (~1));
18425         o_conv.is_owned = (o & 1) || (o == 0);
18426         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18427         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
18428         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
18429         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
18430         return (int64_t)ret_conv;
18431 }
18432
18433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18434         LDKDecodeError e_conv;
18435         e_conv.inner = (void*)(e & (~1));
18436         e_conv.is_owned = (e & 1) || (e == 0);
18437         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18438         e_conv = DecodeError_clone(&e_conv);
18439         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
18440         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
18441         return (int64_t)ret_conv;
18442 }
18443
18444 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18445         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
18446         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
18447         return ret_conv;
18448 }
18449
18450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18451         if ((_res & 1) != 0) return;
18452         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18453         CHECK_ACCESS(_res_ptr);
18454         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
18455         FREE((void*)_res);
18456         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
18457 }
18458
18459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
18460         LDKCVec_NetAddressZ o_constr;
18461         o_constr.datalen = (*env)->GetArrayLength(env, o);
18462         if (o_constr.datalen > 0)
18463                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18464         else
18465                 o_constr.data = NULL;
18466         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
18467         for (size_t m = 0; m < o_constr.datalen; m++) {
18468                 int64_t o_conv_12 = o_vals[m];
18469                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
18470                 CHECK_ACCESS(o_conv_12_ptr);
18471                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
18472                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
18473                 o_constr.data[m] = o_conv_12_conv;
18474         }
18475         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
18476         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18477         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
18478         int64_t ret_ref = (uintptr_t)ret_copy;
18479         return ret_ref;
18480 }
18481
18482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
18483         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18484         *ret_copy = COption_CVec_NetAddressZZ_none();
18485         int64_t ret_ref = (uintptr_t)ret_copy;
18486         return ret_ref;
18487 }
18488
18489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18490         if ((_res & 1) != 0) return;
18491         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18492         CHECK_ACCESS(_res_ptr);
18493         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
18494         FREE((void*)_res);
18495         COption_CVec_NetAddressZZ_free(_res_conv);
18496 }
18497
18498 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
18499         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18500         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
18501 int64_t ret_ref = (uintptr_t)ret_copy;
18502         return ret_ref;
18503 }
18504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18505         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
18506         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
18507         return ret_conv;
18508 }
18509
18510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18511         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
18512         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18513         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
18514         int64_t ret_ref = (uintptr_t)ret_copy;
18515         return ret_ref;
18516 }
18517
18518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18519         LDKDelayedPaymentOutputDescriptor o_conv;
18520         o_conv.inner = (void*)(o & (~1));
18521         o_conv.is_owned = (o & 1) || (o == 0);
18522         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18523         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
18524         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18525         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
18526         return (int64_t)ret_conv;
18527 }
18528
18529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18530         LDKDecodeError e_conv;
18531         e_conv.inner = (void*)(e & (~1));
18532         e_conv.is_owned = (e & 1) || (e == 0);
18533         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18534         e_conv = DecodeError_clone(&e_conv);
18535         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18536         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
18537         return (int64_t)ret_conv;
18538 }
18539
18540 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18541         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
18542         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18543         return ret_conv;
18544 }
18545
18546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18547         if ((_res & 1) != 0) return;
18548         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18549         CHECK_ACCESS(_res_ptr);
18550         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
18551         FREE((void*)_res);
18552         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
18553 }
18554
18555 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18556         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18557         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
18558         return (int64_t)ret_conv;
18559 }
18560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18561         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
18562         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
18563         return ret_conv;
18564 }
18565
18566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18567         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
18568         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18569         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
18570         return (int64_t)ret_conv;
18571 }
18572
18573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18574         LDKStaticPaymentOutputDescriptor o_conv;
18575         o_conv.inner = (void*)(o & (~1));
18576         o_conv.is_owned = (o & 1) || (o == 0);
18577         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18578         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
18579         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18580         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
18581         return (int64_t)ret_conv;
18582 }
18583
18584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18585         LDKDecodeError e_conv;
18586         e_conv.inner = (void*)(e & (~1));
18587         e_conv.is_owned = (e & 1) || (e == 0);
18588         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18589         e_conv = DecodeError_clone(&e_conv);
18590         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18591         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
18592         return (int64_t)ret_conv;
18593 }
18594
18595 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18596         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
18597         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18598         return ret_conv;
18599 }
18600
18601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18602         if ((_res & 1) != 0) return;
18603         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18604         CHECK_ACCESS(_res_ptr);
18605         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
18606         FREE((void*)_res);
18607         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
18608 }
18609
18610 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18611         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18612         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
18613         return (int64_t)ret_conv;
18614 }
18615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18616         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
18617         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
18618         return ret_conv;
18619 }
18620
18621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18622         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
18623         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18624         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
18625         return (int64_t)ret_conv;
18626 }
18627
18628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18629         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18630         CHECK_ACCESS(o_ptr);
18631         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
18632         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
18633         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18634         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
18635         return (int64_t)ret_conv;
18636 }
18637
18638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18639         LDKDecodeError e_conv;
18640         e_conv.inner = (void*)(e & (~1));
18641         e_conv.is_owned = (e & 1) || (e == 0);
18642         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18643         e_conv = DecodeError_clone(&e_conv);
18644         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18645         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
18646         return (int64_t)ret_conv;
18647 }
18648
18649 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18650         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
18651         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18652         return ret_conv;
18653 }
18654
18655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18656         if ((_res & 1) != 0) return;
18657         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18658         CHECK_ACCESS(_res_ptr);
18659         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
18660         FREE((void*)_res);
18661         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
18662 }
18663
18664 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18665         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18666         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
18667         return (int64_t)ret_conv;
18668 }
18669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18670         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
18671         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
18672         return ret_conv;
18673 }
18674
18675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18676         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
18677         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18678         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
18679         return (int64_t)ret_conv;
18680 }
18681
18682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
18683         LDKCVec_PaymentPreimageZ _res_constr;
18684         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18685         if (_res_constr.datalen > 0)
18686                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
18687         else
18688                 _res_constr.data = NULL;
18689         for (size_t i = 0; i < _res_constr.datalen; i++) {
18690                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
18691                 LDKThirtyTwoBytes _res_conv_8_ref;
18692                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
18693                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
18694                 _res_constr.data[i] = _res_conv_8_ref;
18695         }
18696         CVec_PaymentPreimageZ_free(_res_constr);
18697 }
18698
18699 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
18700         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18701         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
18702         return ((int64_t)ret_conv);
18703 }
18704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18705         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
18706         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
18707         return ret_conv;
18708 }
18709
18710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18711         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
18712         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18713         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
18714         return ((int64_t)ret_conv);
18715 }
18716
18717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
18718         LDKSignature a_ref;
18719         CHECK((*env)->GetArrayLength(env, a) == 64);
18720         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
18721         LDKCVec_SignatureZ b_constr;
18722         b_constr.datalen = (*env)->GetArrayLength(env, b);
18723         if (b_constr.datalen > 0)
18724                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18725         else
18726                 b_constr.data = NULL;
18727         for (size_t i = 0; i < b_constr.datalen; i++) {
18728                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
18729                 LDKSignature b_conv_8_ref;
18730                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
18731                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
18732                 b_constr.data[i] = b_conv_8_ref;
18733         }
18734         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18735         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
18736         return ((int64_t)ret_conv);
18737 }
18738
18739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18740         if ((_res & 1) != 0) return;
18741         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18742         CHECK_ACCESS(_res_ptr);
18743         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
18744         FREE((void*)_res);
18745         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
18746 }
18747
18748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18749         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18750         CHECK_ACCESS(o_ptr);
18751         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
18752         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
18753         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18754         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
18755         return (int64_t)ret_conv;
18756 }
18757
18758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
18759         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18760         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
18761         return (int64_t)ret_conv;
18762 }
18763
18764 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18765         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
18766         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
18767         return ret_conv;
18768 }
18769
18770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18771         if ((_res & 1) != 0) return;
18772         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18773         CHECK_ACCESS(_res_ptr);
18774         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
18775         FREE((void*)_res);
18776         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
18777 }
18778
18779 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
18780         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18781         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
18782         return (int64_t)ret_conv;
18783 }
18784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18785         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
18786         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
18787         return ret_conv;
18788 }
18789
18790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18791         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
18792         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18793         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
18794         return (int64_t)ret_conv;
18795 }
18796
18797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18798         LDKSignature o_ref;
18799         CHECK((*env)->GetArrayLength(env, o) == 64);
18800         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
18801         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18802         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
18803         return (int64_t)ret_conv;
18804 }
18805
18806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
18807         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18808         *ret_conv = CResult_SignatureNoneZ_err();
18809         return (int64_t)ret_conv;
18810 }
18811
18812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18813         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
18814         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
18815         return ret_conv;
18816 }
18817
18818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18819         if ((_res & 1) != 0) return;
18820         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18821         CHECK_ACCESS(_res_ptr);
18822         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
18823         FREE((void*)_res);
18824         CResult_SignatureNoneZ_free(_res_conv);
18825 }
18826
18827 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
18828         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18829         *ret_conv = CResult_SignatureNoneZ_clone(arg);
18830         return (int64_t)ret_conv;
18831 }
18832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18833         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
18834         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
18835         return ret_conv;
18836 }
18837
18838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18839         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
18840         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18841         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
18842         return (int64_t)ret_conv;
18843 }
18844
18845 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
18846         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18847         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
18848         return ((int64_t)ret_conv);
18849 }
18850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18851         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
18852         int64_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
18853         return ret_conv;
18854 }
18855
18856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18857         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
18858         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18859         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
18860         return ((int64_t)ret_conv);
18861 }
18862
18863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
18864         LDKSignature a_ref;
18865         CHECK((*env)->GetArrayLength(env, a) == 64);
18866         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
18867         LDKSignature b_ref;
18868         CHECK((*env)->GetArrayLength(env, b) == 64);
18869         (*env)->GetByteArrayRegion(env, b, 0, 64, b_ref.compact_form);
18870         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18871         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
18872         return ((int64_t)ret_conv);
18873 }
18874
18875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18876         if ((_res & 1) != 0) return;
18877         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18878         CHECK_ACCESS(_res_ptr);
18879         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
18880         FREE((void*)_res);
18881         C2Tuple_SignatureSignatureZ_free(_res_conv);
18882 }
18883
18884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18885         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18886         CHECK_ACCESS(o_ptr);
18887         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
18888         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
18889         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18890         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
18891         return (int64_t)ret_conv;
18892 }
18893
18894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
18895         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18896         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
18897         return (int64_t)ret_conv;
18898 }
18899
18900 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18901         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
18902         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
18903         return ret_conv;
18904 }
18905
18906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18907         if ((_res & 1) != 0) return;
18908         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18909         CHECK_ACCESS(_res_ptr);
18910         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
18911         FREE((void*)_res);
18912         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
18913 }
18914
18915 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
18916         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18917         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
18918         return (int64_t)ret_conv;
18919 }
18920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18921         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
18922         int64_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
18923         return ret_conv;
18924 }
18925
18926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18927         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
18928         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18929         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
18930         return (int64_t)ret_conv;
18931 }
18932
18933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18934         LDKSecretKey o_ref;
18935         CHECK((*env)->GetArrayLength(env, o) == 32);
18936         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
18937         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18938         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
18939         return (int64_t)ret_conv;
18940 }
18941
18942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1err(JNIEnv *env, jclass clz) {
18943         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18944         *ret_conv = CResult_SecretKeyNoneZ_err();
18945         return (int64_t)ret_conv;
18946 }
18947
18948 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18949         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
18950         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
18951         return ret_conv;
18952 }
18953
18954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18955         if ((_res & 1) != 0) return;
18956         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18957         CHECK_ACCESS(_res_ptr);
18958         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
18959         FREE((void*)_res);
18960         CResult_SecretKeyNoneZ_free(_res_conv);
18961 }
18962
18963 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
18964         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18965         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
18966         return (int64_t)ret_conv;
18967 }
18968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18969         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
18970         int64_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
18971         return ret_conv;
18972 }
18973
18974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18975         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
18976         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18977         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
18978         return (int64_t)ret_conv;
18979 }
18980
18981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18982         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18983         CHECK_ACCESS(o_ptr);
18984         LDKSign o_conv = *(LDKSign*)(o_ptr);
18985         if (o_conv.free == LDKSign_JCalls_free) {
18986                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18987                 LDKSign_JCalls_cloned(&o_conv);
18988         }
18989         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
18990         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
18991         return (int64_t)ret_conv;
18992 }
18993
18994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18995         LDKDecodeError e_conv;
18996         e_conv.inner = (void*)(e & (~1));
18997         e_conv.is_owned = (e & 1) || (e == 0);
18998         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18999         e_conv = DecodeError_clone(&e_conv);
19000         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19001         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
19002         return (int64_t)ret_conv;
19003 }
19004
19005 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19006         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
19007         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
19008         return ret_conv;
19009 }
19010
19011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19012         if ((_res & 1) != 0) return;
19013         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19014         CHECK_ACCESS(_res_ptr);
19015         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
19016         FREE((void*)_res);
19017         CResult_SignDecodeErrorZ_free(_res_conv);
19018 }
19019
19020 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
19021         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19022         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
19023         return (int64_t)ret_conv;
19024 }
19025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19026         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
19027         int64_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
19028         return ret_conv;
19029 }
19030
19031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19032         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
19033         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19034         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
19035         return (int64_t)ret_conv;
19036 }
19037
19038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19039         LDKCVec_u5Z _res_constr;
19040         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19041         if (_res_constr.datalen > 0)
19042                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
19043         else
19044                 _res_constr.data = NULL;
19045         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
19046         for (size_t h = 0; h < _res_constr.datalen; h++) {
19047                 int8_t _res_conv_7 = _res_vals[h];
19048                 
19049                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
19050         }
19051         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
19052         CVec_u5Z_free(_res_constr);
19053 }
19054
19055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19056         LDKRecoverableSignature o_ref;
19057         CHECK((*env)->GetArrayLength(env, o) == 68);
19058         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
19059         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19060         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
19061         return (int64_t)ret_conv;
19062 }
19063
19064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
19065         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19066         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
19067         return (int64_t)ret_conv;
19068 }
19069
19070 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19071         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
19072         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
19073         return ret_conv;
19074 }
19075
19076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19077         if ((_res & 1) != 0) return;
19078         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19079         CHECK_ACCESS(_res_ptr);
19080         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
19081         FREE((void*)_res);
19082         CResult_RecoverableSignatureNoneZ_free(_res_conv);
19083 }
19084
19085 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
19086         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19087         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
19088         return (int64_t)ret_conv;
19089 }
19090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19091         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
19092         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
19093         return ret_conv;
19094 }
19095
19096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19097         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
19098         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19099         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
19100         return (int64_t)ret_conv;
19101 }
19102
19103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
19104         LDKCVec_u8Z _res_ref;
19105         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
19106         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
19107         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
19108         CVec_u8Z_free(_res_ref);
19109 }
19110
19111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19112         LDKCVec_CVec_u8ZZ _res_constr;
19113         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19114         if (_res_constr.datalen > 0)
19115                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
19116         else
19117                 _res_constr.data = NULL;
19118         for (size_t i = 0; i < _res_constr.datalen; i++) {
19119                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19120                 LDKCVec_u8Z _res_conv_8_ref;
19121                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
19122                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
19123                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
19124                 _res_constr.data[i] = _res_conv_8_ref;
19125         }
19126         CVec_CVec_u8ZZ_free(_res_constr);
19127 }
19128
19129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
19130         LDKCVec_CVec_u8ZZ o_constr;
19131         o_constr.datalen = (*env)->GetArrayLength(env, o);
19132         if (o_constr.datalen > 0)
19133                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
19134         else
19135                 o_constr.data = NULL;
19136         for (size_t i = 0; i < o_constr.datalen; i++) {
19137                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
19138                 LDKCVec_u8Z o_conv_8_ref;
19139                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
19140                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
19141                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
19142                 o_constr.data[i] = o_conv_8_ref;
19143         }
19144         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19145         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
19146         return (int64_t)ret_conv;
19147 }
19148
19149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
19150         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19151         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
19152         return (int64_t)ret_conv;
19153 }
19154
19155 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19156         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
19157         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
19158         return ret_conv;
19159 }
19160
19161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19162         if ((_res & 1) != 0) return;
19163         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19164         CHECK_ACCESS(_res_ptr);
19165         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
19166         FREE((void*)_res);
19167         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
19168 }
19169
19170 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
19171         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19172         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
19173         return (int64_t)ret_conv;
19174 }
19175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19176         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
19177         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
19178         return ret_conv;
19179 }
19180
19181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19182         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
19183         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19184         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
19185         return (int64_t)ret_conv;
19186 }
19187
19188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19189         LDKInMemorySigner o_conv;
19190         o_conv.inner = (void*)(o & (~1));
19191         o_conv.is_owned = (o & 1) || (o == 0);
19192         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19193         o_conv = InMemorySigner_clone(&o_conv);
19194         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19195         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
19196         return (int64_t)ret_conv;
19197 }
19198
19199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19200         LDKDecodeError e_conv;
19201         e_conv.inner = (void*)(e & (~1));
19202         e_conv.is_owned = (e & 1) || (e == 0);
19203         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19204         e_conv = DecodeError_clone(&e_conv);
19205         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19206         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
19207         return (int64_t)ret_conv;
19208 }
19209
19210 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19211         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
19212         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
19213         return ret_conv;
19214 }
19215
19216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19217         if ((_res & 1) != 0) return;
19218         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19219         CHECK_ACCESS(_res_ptr);
19220         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
19221         FREE((void*)_res);
19222         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
19223 }
19224
19225 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
19226         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19227         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
19228         return (int64_t)ret_conv;
19229 }
19230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19231         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
19232         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
19233         return ret_conv;
19234 }
19235
19236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19237         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
19238         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19239         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
19240         return (int64_t)ret_conv;
19241 }
19242
19243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19244         LDKCVec_TxOutZ _res_constr;
19245         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19246         if (_res_constr.datalen > 0)
19247                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
19248         else
19249                 _res_constr.data = NULL;
19250         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19251         for (size_t h = 0; h < _res_constr.datalen; h++) {
19252                 int64_t _res_conv_7 = _res_vals[h];
19253                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
19254                 CHECK_ACCESS(_res_conv_7_ptr);
19255                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
19256                 FREE((void*)_res_conv_7);
19257                 _res_constr.data[h] = _res_conv_7_conv;
19258         }
19259         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19260         CVec_TxOutZ_free(_res_constr);
19261 }
19262
19263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19264         LDKTransaction o_ref;
19265         o_ref.datalen = (*env)->GetArrayLength(env, o);
19266         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
19267         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
19268         o_ref.data_is_owned = true;
19269         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19270         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
19271         return (int64_t)ret_conv;
19272 }
19273
19274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
19275         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19276         *ret_conv = CResult_TransactionNoneZ_err();
19277         return (int64_t)ret_conv;
19278 }
19279
19280 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19281         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
19282         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
19283         return ret_conv;
19284 }
19285
19286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19287         if ((_res & 1) != 0) return;
19288         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19289         CHECK_ACCESS(_res_ptr);
19290         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
19291         FREE((void*)_res);
19292         CResult_TransactionNoneZ_free(_res_conv);
19293 }
19294
19295 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
19296         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19297         *ret_conv = CResult_TransactionNoneZ_clone(arg);
19298         return (int64_t)ret_conv;
19299 }
19300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19301         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
19302         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
19303         return ret_conv;
19304 }
19305
19306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19307         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
19308         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19309         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
19310         return (int64_t)ret_conv;
19311 }
19312
19313 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
19314         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
19315         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
19316         return ((int64_t)ret_conv);
19317 }
19318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19319         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
19320         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
19321         return ret_conv;
19322 }
19323
19324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19325         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
19326         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
19327         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
19328         return ((int64_t)ret_conv);
19329 }
19330
19331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
19332         LDKThirtyTwoBytes a_ref;
19333         CHECK((*env)->GetArrayLength(env, a) == 32);
19334         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19335         LDKChannelMonitor b_conv;
19336         b_conv.inner = (void*)(b & (~1));
19337         b_conv.is_owned = (b & 1) || (b == 0);
19338         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19339         b_conv = ChannelMonitor_clone(&b_conv);
19340         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
19341         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
19342         return ((int64_t)ret_conv);
19343 }
19344
19345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19346         if ((_res & 1) != 0) return;
19347         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19348         CHECK_ACCESS(_res_ptr);
19349         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
19350         FREE((void*)_res);
19351         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
19352 }
19353
19354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19355         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
19356         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19357         if (_res_constr.datalen > 0)
19358                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
19359         else
19360                 _res_constr.data = NULL;
19361         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19362         for (size_t j = 0; j < _res_constr.datalen; j++) {
19363                 int64_t _res_conv_35 = _res_vals[j];
19364                 void* _res_conv_35_ptr = (void*)(((uintptr_t)_res_conv_35) & ~1);
19365                 CHECK_ACCESS(_res_conv_35_ptr);
19366                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
19367                 FREE((void*)_res_conv_35);
19368                 _res_constr.data[j] = _res_conv_35_conv;
19369         }
19370         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19371         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
19372 }
19373
19374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
19375         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
19376         o_constr.datalen = (*env)->GetArrayLength(env, o);
19377         if (o_constr.datalen > 0)
19378                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
19379         else
19380                 o_constr.data = NULL;
19381         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
19382         for (size_t j = 0; j < o_constr.datalen; j++) {
19383                 int64_t o_conv_35 = o_vals[j];
19384                 void* o_conv_35_ptr = (void*)(((uintptr_t)o_conv_35) & ~1);
19385                 CHECK_ACCESS(o_conv_35_ptr);
19386                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
19387                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o_conv_35) & ~1));
19388                 o_constr.data[j] = o_conv_35_conv;
19389         }
19390         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
19391         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
19392         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
19393         return (int64_t)ret_conv;
19394 }
19395
19396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19397         LDKIOError e_conv = LDKIOError_from_java(env, e);
19398         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
19399         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
19400         return (int64_t)ret_conv;
19401 }
19402
19403 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19404         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(o & ~1);
19405         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
19406         return ret_conv;
19407 }
19408
19409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19410         if ((_res & 1) != 0) return;
19411         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19412         CHECK_ACCESS(_res_ptr);
19413         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
19414         FREE((void*)_res);
19415         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
19416 }
19417
19418 static inline uintptr_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
19419         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
19420         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
19421         return (int64_t)ret_conv;
19422 }
19423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19424         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
19425         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
19426         return ret_conv;
19427 }
19428
19429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19430         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
19431         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
19432         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
19433         return (int64_t)ret_conv;
19434 }
19435
19436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
19437         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19438         *ret_copy = COption_u16Z_some(o);
19439         int64_t ret_ref = (uintptr_t)ret_copy;
19440         return ret_ref;
19441 }
19442
19443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
19444         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19445         *ret_copy = COption_u16Z_none();
19446         int64_t ret_ref = (uintptr_t)ret_copy;
19447         return ret_ref;
19448 }
19449
19450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
19451         if ((_res & 1) != 0) return;
19452         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19453         CHECK_ACCESS(_res_ptr);
19454         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
19455         FREE((void*)_res);
19456         COption_u16Z_free(_res_conv);
19457 }
19458
19459 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
19460         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19461         *ret_copy = COption_u16Z_clone(arg);
19462 int64_t ret_ref = (uintptr_t)ret_copy;
19463         return ret_ref;
19464 }
19465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19466         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
19467         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
19468         return ret_conv;
19469 }
19470
19471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19472         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
19473         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19474         *ret_copy = COption_u16Z_clone(orig_conv);
19475         int64_t ret_ref = (uintptr_t)ret_copy;
19476         return ret_ref;
19477 }
19478
19479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
19480         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19481         *ret_conv = CResult_NoneAPIErrorZ_ok();
19482         return (int64_t)ret_conv;
19483 }
19484
19485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19486         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19487         CHECK_ACCESS(e_ptr);
19488         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19489         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19490         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19491         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
19492         return (int64_t)ret_conv;
19493 }
19494
19495 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19496         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
19497         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
19498         return ret_conv;
19499 }
19500
19501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19502         if ((_res & 1) != 0) return;
19503         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19504         CHECK_ACCESS(_res_ptr);
19505         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
19506         FREE((void*)_res);
19507         CResult_NoneAPIErrorZ_free(_res_conv);
19508 }
19509
19510 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
19511         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19512         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
19513         return (int64_t)ret_conv;
19514 }
19515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19516         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
19517         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
19518         return ret_conv;
19519 }
19520
19521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19522         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
19523         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19524         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
19525         return (int64_t)ret_conv;
19526 }
19527
19528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19529         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
19530         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19531         if (_res_constr.datalen > 0)
19532                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
19533         else
19534                 _res_constr.data = NULL;
19535         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19536         for (size_t w = 0; w < _res_constr.datalen; w++) {
19537                 int64_t _res_conv_22 = _res_vals[w];
19538                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
19539                 CHECK_ACCESS(_res_conv_22_ptr);
19540                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
19541                 FREE((void*)_res_conv_22);
19542                 _res_constr.data[w] = _res_conv_22_conv;
19543         }
19544         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19545         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
19546 }
19547
19548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19549         LDKCVec_APIErrorZ _res_constr;
19550         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19551         if (_res_constr.datalen > 0)
19552                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
19553         else
19554                 _res_constr.data = NULL;
19555         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19556         for (size_t k = 0; k < _res_constr.datalen; k++) {
19557                 int64_t _res_conv_10 = _res_vals[k];
19558                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
19559                 CHECK_ACCESS(_res_conv_10_ptr);
19560                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
19561                 FREE((void*)_res_conv_10);
19562                 _res_constr.data[k] = _res_conv_10_conv;
19563         }
19564         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19565         CVec_APIErrorZ_free(_res_constr);
19566 }
19567
19568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19569         LDKThirtyTwoBytes o_ref;
19570         CHECK((*env)->GetArrayLength(env, o) == 32);
19571         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19572         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19573         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
19574         return (int64_t)ret_conv;
19575 }
19576
19577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19578         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19579         CHECK_ACCESS(e_ptr);
19580         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19581         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19582         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19583         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
19584         return (int64_t)ret_conv;
19585 }
19586
19587 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19588         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
19589         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
19590         return ret_conv;
19591 }
19592
19593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19594         if ((_res & 1) != 0) return;
19595         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19596         CHECK_ACCESS(_res_ptr);
19597         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
19598         FREE((void*)_res);
19599         CResult__u832APIErrorZ_free(_res_conv);
19600 }
19601
19602 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
19603         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19604         *ret_conv = CResult__u832APIErrorZ_clone(arg);
19605         return (int64_t)ret_conv;
19606 }
19607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19608         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
19609         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
19610         return ret_conv;
19611 }
19612
19613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19614         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
19615         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19616         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
19617         return (int64_t)ret_conv;
19618 }
19619
19620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19621         LDKThirtyTwoBytes o_ref;
19622         CHECK((*env)->GetArrayLength(env, o) == 32);
19623         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19624         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19625         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
19626         return (int64_t)ret_conv;
19627 }
19628
19629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19630         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19631         CHECK_ACCESS(e_ptr);
19632         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
19633         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
19634         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19635         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
19636         return (int64_t)ret_conv;
19637 }
19638
19639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19640         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
19641         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
19642         return ret_conv;
19643 }
19644
19645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19646         if ((_res & 1) != 0) return;
19647         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19648         CHECK_ACCESS(_res_ptr);
19649         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
19650         FREE((void*)_res);
19651         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
19652 }
19653
19654 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
19655         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19656         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
19657         return (int64_t)ret_conv;
19658 }
19659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19660         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
19661         int64_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
19662         return ret_conv;
19663 }
19664
19665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19666         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
19667         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19668         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
19669         return (int64_t)ret_conv;
19670 }
19671
19672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
19673         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19674         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
19675         return (int64_t)ret_conv;
19676 }
19677
19678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19679         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19680         CHECK_ACCESS(e_ptr);
19681         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
19682         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
19683         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19684         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
19685         return (int64_t)ret_conv;
19686 }
19687
19688 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19689         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
19690         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
19691         return ret_conv;
19692 }
19693
19694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19695         if ((_res & 1) != 0) return;
19696         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19697         CHECK_ACCESS(_res_ptr);
19698         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
19699         FREE((void*)_res);
19700         CResult_NonePaymentSendFailureZ_free(_res_conv);
19701 }
19702
19703 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
19704         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19705         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
19706         return (int64_t)ret_conv;
19707 }
19708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19709         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
19710         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
19711         return ret_conv;
19712 }
19713
19714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19715         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
19716         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19717         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
19718         return (int64_t)ret_conv;
19719 }
19720
19721 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
19722         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19723         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
19724         return ((int64_t)ret_conv);
19725 }
19726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19727         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
19728         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
19729         return ret_conv;
19730 }
19731
19732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19733         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
19734         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19735         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
19736         return ((int64_t)ret_conv);
19737 }
19738
19739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
19740         LDKThirtyTwoBytes a_ref;
19741         CHECK((*env)->GetArrayLength(env, a) == 32);
19742         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19743         LDKThirtyTwoBytes b_ref;
19744         CHECK((*env)->GetArrayLength(env, b) == 32);
19745         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
19746         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19747         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
19748         return ((int64_t)ret_conv);
19749 }
19750
19751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19752         if ((_res & 1) != 0) return;
19753         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19754         CHECK_ACCESS(_res_ptr);
19755         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
19756         FREE((void*)_res);
19757         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
19758 }
19759
19760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19761         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19762         CHECK_ACCESS(o_ptr);
19763         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
19764         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
19765         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19766         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
19767         return (int64_t)ret_conv;
19768 }
19769
19770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19771         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19772         CHECK_ACCESS(e_ptr);
19773         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
19774         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
19775         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19776         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
19777         return (int64_t)ret_conv;
19778 }
19779
19780 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19781         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
19782         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
19783         return ret_conv;
19784 }
19785
19786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19787         if ((_res & 1) != 0) return;
19788         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19789         CHECK_ACCESS(_res_ptr);
19790         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
19791         FREE((void*)_res);
19792         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
19793 }
19794
19795 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
19796         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19797         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
19798         return (int64_t)ret_conv;
19799 }
19800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19801         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
19802         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
19803         return ret_conv;
19804 }
19805
19806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19807         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
19808         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19809         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
19810         return (int64_t)ret_conv;
19811 }
19812
19813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ThirtyTwoBytesZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19814         LDKCVec_ThirtyTwoBytesZ _res_constr;
19815         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19816         if (_res_constr.datalen > 0)
19817                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
19818         else
19819                 _res_constr.data = NULL;
19820         for (size_t i = 0; i < _res_constr.datalen; i++) {
19821                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19822                 LDKThirtyTwoBytes _res_conv_8_ref;
19823                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
19824                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
19825                 _res_constr.data[i] = _res_conv_8_ref;
19826         }
19827         CVec_ThirtyTwoBytesZ_free(_res_constr);
19828 }
19829
19830 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
19831         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19832         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
19833         return ((int64_t)ret_conv);
19834 }
19835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19836         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
19837         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
19838         return ret_conv;
19839 }
19840
19841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19842         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
19843         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19844         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
19845         return ((int64_t)ret_conv);
19846 }
19847
19848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
19849         LDKThirtyTwoBytes a_ref;
19850         CHECK((*env)->GetArrayLength(env, a) == 32);
19851         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19852         LDKThirtyTwoBytes b_ref;
19853         CHECK((*env)->GetArrayLength(env, b) == 32);
19854         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
19855         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19856         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
19857         return ((int64_t)ret_conv);
19858 }
19859
19860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19861         if ((_res & 1) != 0) return;
19862         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19863         CHECK_ACCESS(_res_ptr);
19864         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
19865         FREE((void*)_res);
19866         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
19867 }
19868
19869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19870         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19871         CHECK_ACCESS(o_ptr);
19872         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
19873         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
19874         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19875         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
19876         return (int64_t)ret_conv;
19877 }
19878
19879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
19880         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19881         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
19882         return (int64_t)ret_conv;
19883 }
19884
19885 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19886         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
19887         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
19888         return ret_conv;
19889 }
19890
19891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19892         if ((_res & 1) != 0) return;
19893         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19894         CHECK_ACCESS(_res_ptr);
19895         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
19896         FREE((void*)_res);
19897         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
19898 }
19899
19900 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
19901         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19902         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
19903         return (int64_t)ret_conv;
19904 }
19905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19906         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
19907         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
19908         return ret_conv;
19909 }
19910
19911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19912         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
19913         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19914         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
19915         return (int64_t)ret_conv;
19916 }
19917
19918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19919         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19920         CHECK_ACCESS(o_ptr);
19921         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
19922         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
19923         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19924         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
19925         return (int64_t)ret_conv;
19926 }
19927
19928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19929         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19930         CHECK_ACCESS(e_ptr);
19931         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19932         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19933         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19934         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
19935         return (int64_t)ret_conv;
19936 }
19937
19938 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19939         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
19940         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
19941         return ret_conv;
19942 }
19943
19944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19945         if ((_res & 1) != 0) return;
19946         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19947         CHECK_ACCESS(_res_ptr);
19948         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
19949         FREE((void*)_res);
19950         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
19951 }
19952
19953 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
19954         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19955         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
19956         return (int64_t)ret_conv;
19957 }
19958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19959         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
19960         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
19961         return ret_conv;
19962 }
19963
19964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19965         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
19966         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19967         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
19968         return (int64_t)ret_conv;
19969 }
19970
19971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19972         LDKThirtyTwoBytes o_ref;
19973         CHECK((*env)->GetArrayLength(env, o) == 32);
19974         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19975         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19976         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
19977         return (int64_t)ret_conv;
19978 }
19979
19980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
19981         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19982         *ret_conv = CResult_PaymentSecretNoneZ_err();
19983         return (int64_t)ret_conv;
19984 }
19985
19986 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19987         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
19988         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
19989         return ret_conv;
19990 }
19991
19992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19993         if ((_res & 1) != 0) return;
19994         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19995         CHECK_ACCESS(_res_ptr);
19996         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
19997         FREE((void*)_res);
19998         CResult_PaymentSecretNoneZ_free(_res_conv);
19999 }
20000
20001 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
20002         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20003         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
20004         return (int64_t)ret_conv;
20005 }
20006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20007         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
20008         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
20009         return ret_conv;
20010 }
20011
20012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20013         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
20014         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20015         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
20016         return (int64_t)ret_conv;
20017 }
20018
20019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20020         LDKThirtyTwoBytes o_ref;
20021         CHECK((*env)->GetArrayLength(env, o) == 32);
20022         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20023         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20024         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
20025         return (int64_t)ret_conv;
20026 }
20027
20028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20029         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20030         CHECK_ACCESS(e_ptr);
20031         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20032         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
20033         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20034         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
20035         return (int64_t)ret_conv;
20036 }
20037
20038 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20039         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
20040         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
20041         return ret_conv;
20042 }
20043
20044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20045         if ((_res & 1) != 0) return;
20046         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20047         CHECK_ACCESS(_res_ptr);
20048         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
20049         FREE((void*)_res);
20050         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
20051 }
20052
20053 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
20054         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20055         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
20056         return (int64_t)ret_conv;
20057 }
20058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20059         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
20060         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
20061         return ret_conv;
20062 }
20063
20064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20065         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
20066         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20067         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
20068         return (int64_t)ret_conv;
20069 }
20070
20071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20072         LDKThirtyTwoBytes o_ref;
20073         CHECK((*env)->GetArrayLength(env, o) == 32);
20074         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20075         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20076         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
20077         return (int64_t)ret_conv;
20078 }
20079
20080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20081         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20082         CHECK_ACCESS(e_ptr);
20083         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20084         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
20085         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20086         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
20087         return (int64_t)ret_conv;
20088 }
20089
20090 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20091         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
20092         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
20093         return ret_conv;
20094 }
20095
20096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20097         if ((_res & 1) != 0) return;
20098         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20099         CHECK_ACCESS(_res_ptr);
20100         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
20101         FREE((void*)_res);
20102         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
20103 }
20104
20105 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
20106         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20107         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
20108         return (int64_t)ret_conv;
20109 }
20110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20111         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
20112         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
20113         return ret_conv;
20114 }
20115
20116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20117         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
20118         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20119         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
20120         return (int64_t)ret_conv;
20121 }
20122
20123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20124         LDKCounterpartyForwardingInfo o_conv;
20125         o_conv.inner = (void*)(o & (~1));
20126         o_conv.is_owned = (o & 1) || (o == 0);
20127         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20128         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
20129         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20130         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
20131         return (int64_t)ret_conv;
20132 }
20133
20134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20135         LDKDecodeError e_conv;
20136         e_conv.inner = (void*)(e & (~1));
20137         e_conv.is_owned = (e & 1) || (e == 0);
20138         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20139         e_conv = DecodeError_clone(&e_conv);
20140         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20141         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
20142         return (int64_t)ret_conv;
20143 }
20144
20145 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20146         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
20147         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
20148         return ret_conv;
20149 }
20150
20151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20152         if ((_res & 1) != 0) return;
20153         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20154         CHECK_ACCESS(_res_ptr);
20155         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
20156         FREE((void*)_res);
20157         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
20158 }
20159
20160 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
20161         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20162         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
20163         return (int64_t)ret_conv;
20164 }
20165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20166         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
20167         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
20168         return ret_conv;
20169 }
20170
20171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20172         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
20173         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20174         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
20175         return (int64_t)ret_conv;
20176 }
20177
20178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20179         LDKChannelCounterparty o_conv;
20180         o_conv.inner = (void*)(o & (~1));
20181         o_conv.is_owned = (o & 1) || (o == 0);
20182         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20183         o_conv = ChannelCounterparty_clone(&o_conv);
20184         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20185         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
20186         return (int64_t)ret_conv;
20187 }
20188
20189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20190         LDKDecodeError e_conv;
20191         e_conv.inner = (void*)(e & (~1));
20192         e_conv.is_owned = (e & 1) || (e == 0);
20193         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20194         e_conv = DecodeError_clone(&e_conv);
20195         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20196         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
20197         return (int64_t)ret_conv;
20198 }
20199
20200 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20201         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
20202         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
20203         return ret_conv;
20204 }
20205
20206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20207         if ((_res & 1) != 0) return;
20208         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20209         CHECK_ACCESS(_res_ptr);
20210         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
20211         FREE((void*)_res);
20212         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
20213 }
20214
20215 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
20216         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20217         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
20218         return (int64_t)ret_conv;
20219 }
20220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20221         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
20222         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
20223         return ret_conv;
20224 }
20225
20226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20227         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
20228         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20229         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
20230         return (int64_t)ret_conv;
20231 }
20232
20233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20234         LDKChannelDetails o_conv;
20235         o_conv.inner = (void*)(o & (~1));
20236         o_conv.is_owned = (o & 1) || (o == 0);
20237         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20238         o_conv = ChannelDetails_clone(&o_conv);
20239         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20240         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
20241         return (int64_t)ret_conv;
20242 }
20243
20244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20245         LDKDecodeError e_conv;
20246         e_conv.inner = (void*)(e & (~1));
20247         e_conv.is_owned = (e & 1) || (e == 0);
20248         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20249         e_conv = DecodeError_clone(&e_conv);
20250         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20251         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
20252         return (int64_t)ret_conv;
20253 }
20254
20255 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20256         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
20257         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
20258         return ret_conv;
20259 }
20260
20261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20262         if ((_res & 1) != 0) return;
20263         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20264         CHECK_ACCESS(_res_ptr);
20265         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
20266         FREE((void*)_res);
20267         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
20268 }
20269
20270 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
20271         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20272         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
20273         return (int64_t)ret_conv;
20274 }
20275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20276         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
20277         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
20278         return ret_conv;
20279 }
20280
20281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20282         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
20283         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20284         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
20285         return (int64_t)ret_conv;
20286 }
20287
20288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20289         LDKPhantomRouteHints o_conv;
20290         o_conv.inner = (void*)(o & (~1));
20291         o_conv.is_owned = (o & 1) || (o == 0);
20292         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20293         o_conv = PhantomRouteHints_clone(&o_conv);
20294         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20295         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
20296         return (int64_t)ret_conv;
20297 }
20298
20299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20300         LDKDecodeError e_conv;
20301         e_conv.inner = (void*)(e & (~1));
20302         e_conv.is_owned = (e & 1) || (e == 0);
20303         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20304         e_conv = DecodeError_clone(&e_conv);
20305         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20306         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
20307         return (int64_t)ret_conv;
20308 }
20309
20310 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20311         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
20312         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
20313         return ret_conv;
20314 }
20315
20316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20317         if ((_res & 1) != 0) return;
20318         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20319         CHECK_ACCESS(_res_ptr);
20320         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
20321         FREE((void*)_res);
20322         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
20323 }
20324
20325 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
20326         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20327         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
20328         return (int64_t)ret_conv;
20329 }
20330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20331         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
20332         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
20333         return ret_conv;
20334 }
20335
20336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20337         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
20338         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20339         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
20340         return (int64_t)ret_conv;
20341 }
20342
20343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20344         LDKCVec_ChannelMonitorZ _res_constr;
20345         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20346         if (_res_constr.datalen > 0)
20347                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
20348         else
20349                 _res_constr.data = NULL;
20350         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20351         for (size_t q = 0; q < _res_constr.datalen; q++) {
20352                 int64_t _res_conv_16 = _res_vals[q];
20353                 LDKChannelMonitor _res_conv_16_conv;
20354                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
20355                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
20356                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
20357                 _res_constr.data[q] = _res_conv_16_conv;
20358         }
20359         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20360         CVec_ChannelMonitorZ_free(_res_constr);
20361 }
20362
20363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
20364         LDKThirtyTwoBytes a_ref;
20365         CHECK((*env)->GetArrayLength(env, a) == 32);
20366         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20367         LDKChannelManager b_conv;
20368         b_conv.inner = (void*)(b & (~1));
20369         b_conv.is_owned = (b & 1) || (b == 0);
20370         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
20371         // WARNING: we need a move here but no clone is available for LDKChannelManager
20372         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
20373         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
20374         return ((int64_t)ret_conv);
20375 }
20376
20377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20378         if ((_res & 1) != 0) return;
20379         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20380         CHECK_ACCESS(_res_ptr);
20381         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
20382         FREE((void*)_res);
20383         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
20384 }
20385
20386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20387         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20388         CHECK_ACCESS(o_ptr);
20389         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
20390         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
20391         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
20392         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
20393         return (int64_t)ret_conv;
20394 }
20395
20396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20397         LDKDecodeError e_conv;
20398         e_conv.inner = (void*)(e & (~1));
20399         e_conv.is_owned = (e & 1) || (e == 0);
20400         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20401         e_conv = DecodeError_clone(&e_conv);
20402         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
20403         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
20404         return (int64_t)ret_conv;
20405 }
20406
20407 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20408         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
20409         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
20410         return ret_conv;
20411 }
20412
20413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20414         if ((_res & 1) != 0) return;
20415         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20416         CHECK_ACCESS(_res_ptr);
20417         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
20418         FREE((void*)_res);
20419         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
20420 }
20421
20422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20423         LDKChannelConfig o_conv;
20424         o_conv.inner = (void*)(o & (~1));
20425         o_conv.is_owned = (o & 1) || (o == 0);
20426         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20427         o_conv = ChannelConfig_clone(&o_conv);
20428         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20429         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
20430         return (int64_t)ret_conv;
20431 }
20432
20433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20434         LDKDecodeError e_conv;
20435         e_conv.inner = (void*)(e & (~1));
20436         e_conv.is_owned = (e & 1) || (e == 0);
20437         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20438         e_conv = DecodeError_clone(&e_conv);
20439         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20440         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
20441         return (int64_t)ret_conv;
20442 }
20443
20444 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20445         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
20446         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
20447         return ret_conv;
20448 }
20449
20450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20451         if ((_res & 1) != 0) return;
20452         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20453         CHECK_ACCESS(_res_ptr);
20454         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
20455         FREE((void*)_res);
20456         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
20457 }
20458
20459 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
20460         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20461         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
20462         return (int64_t)ret_conv;
20463 }
20464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20465         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
20466         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
20467         return ret_conv;
20468 }
20469
20470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20471         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
20472         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20473         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
20474         return (int64_t)ret_conv;
20475 }
20476
20477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20478         LDKOutPoint o_conv;
20479         o_conv.inner = (void*)(o & (~1));
20480         o_conv.is_owned = (o & 1) || (o == 0);
20481         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20482         o_conv = OutPoint_clone(&o_conv);
20483         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20484         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
20485         return (int64_t)ret_conv;
20486 }
20487
20488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20489         LDKDecodeError e_conv;
20490         e_conv.inner = (void*)(e & (~1));
20491         e_conv.is_owned = (e & 1) || (e == 0);
20492         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20493         e_conv = DecodeError_clone(&e_conv);
20494         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20495         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
20496         return (int64_t)ret_conv;
20497 }
20498
20499 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20500         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
20501         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
20502         return ret_conv;
20503 }
20504
20505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20506         if ((_res & 1) != 0) return;
20507         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20508         CHECK_ACCESS(_res_ptr);
20509         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
20510         FREE((void*)_res);
20511         CResult_OutPointDecodeErrorZ_free(_res_conv);
20512 }
20513
20514 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
20515         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20516         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
20517         return (int64_t)ret_conv;
20518 }
20519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20520         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
20521         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
20522         return ret_conv;
20523 }
20524
20525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20526         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
20527         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20528         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
20529         return (int64_t)ret_conv;
20530 }
20531
20532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20533         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20534         CHECK_ACCESS(o_ptr);
20535         LDKType o_conv = *(LDKType*)(o_ptr);
20536         if (o_conv.free == LDKType_JCalls_free) {
20537                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20538                 LDKType_JCalls_cloned(&o_conv);
20539         }
20540         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20541         *ret_copy = COption_TypeZ_some(o_conv);
20542         int64_t ret_ref = (uintptr_t)ret_copy;
20543         return ret_ref;
20544 }
20545
20546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
20547         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20548         *ret_copy = COption_TypeZ_none();
20549         int64_t ret_ref = (uintptr_t)ret_copy;
20550         return ret_ref;
20551 }
20552
20553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20554         if ((_res & 1) != 0) return;
20555         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20556         CHECK_ACCESS(_res_ptr);
20557         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
20558         FREE((void*)_res);
20559         COption_TypeZ_free(_res_conv);
20560 }
20561
20562 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
20563         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20564         *ret_copy = COption_TypeZ_clone(arg);
20565 int64_t ret_ref = (uintptr_t)ret_copy;
20566         return ret_ref;
20567 }
20568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20569         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
20570         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
20571         return ret_conv;
20572 }
20573
20574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20575         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
20576         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20577         *ret_copy = COption_TypeZ_clone(orig_conv);
20578         int64_t ret_ref = (uintptr_t)ret_copy;
20579         return ret_ref;
20580 }
20581
20582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20583         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20584         CHECK_ACCESS(o_ptr);
20585         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
20586         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
20587         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20588         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
20589         return (int64_t)ret_conv;
20590 }
20591
20592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20593         LDKDecodeError e_conv;
20594         e_conv.inner = (void*)(e & (~1));
20595         e_conv.is_owned = (e & 1) || (e == 0);
20596         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20597         e_conv = DecodeError_clone(&e_conv);
20598         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20599         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
20600         return (int64_t)ret_conv;
20601 }
20602
20603 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20604         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
20605         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
20606         return ret_conv;
20607 }
20608
20609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20610         if ((_res & 1) != 0) return;
20611         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20612         CHECK_ACCESS(_res_ptr);
20613         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
20614         FREE((void*)_res);
20615         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
20616 }
20617
20618 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
20619         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20620         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
20621         return (int64_t)ret_conv;
20622 }
20623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20624         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
20625         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
20626         return ret_conv;
20627 }
20628
20629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20630         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
20631         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20632         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
20633         return (int64_t)ret_conv;
20634 }
20635
20636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20637         LDKThirtyTwoBytes o_ref;
20638         CHECK((*env)->GetArrayLength(env, o) == 32);
20639         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20640         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20641         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
20642         return (int64_t)ret_conv;
20643 }
20644
20645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20646         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20647         CHECK_ACCESS(e_ptr);
20648         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
20649         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
20650         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20651         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
20652         return (int64_t)ret_conv;
20653 }
20654
20655 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20656         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
20657         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
20658         return ret_conv;
20659 }
20660
20661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20662         if ((_res & 1) != 0) return;
20663         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20664         CHECK_ACCESS(_res_ptr);
20665         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
20666         FREE((void*)_res);
20667         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
20668 }
20669
20670 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
20671         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20672         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
20673         return (int64_t)ret_conv;
20674 }
20675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20676         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
20677         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
20678         return ret_conv;
20679 }
20680
20681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20682         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
20683         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20684         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
20685         return (int64_t)ret_conv;
20686 }
20687
20688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
20689         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
20690         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20691         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
20692         return (int64_t)ret_conv;
20693 }
20694
20695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20696         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20697         CHECK_ACCESS(e_ptr);
20698         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
20699         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
20700         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20701         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
20702         return (int64_t)ret_conv;
20703 }
20704
20705 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20706         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
20707         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
20708         return ret_conv;
20709 }
20710
20711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20712         if ((_res & 1) != 0) return;
20713         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20714         CHECK_ACCESS(_res_ptr);
20715         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
20716         FREE((void*)_res);
20717         CResult_SiPrefixParseErrorZ_free(_res_conv);
20718 }
20719
20720 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
20721         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20722         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
20723         return (int64_t)ret_conv;
20724 }
20725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20726         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
20727         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
20728         return ret_conv;
20729 }
20730
20731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20732         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
20733         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20734         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
20735         return (int64_t)ret_conv;
20736 }
20737
20738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20739         LDKInvoice o_conv;
20740         o_conv.inner = (void*)(o & (~1));
20741         o_conv.is_owned = (o & 1) || (o == 0);
20742         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20743         o_conv = Invoice_clone(&o_conv);
20744         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20745         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
20746         return (int64_t)ret_conv;
20747 }
20748
20749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20750         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20751         CHECK_ACCESS(e_ptr);
20752         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
20753         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
20754         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20755         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
20756         return (int64_t)ret_conv;
20757 }
20758
20759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20760         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
20761         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
20762         return ret_conv;
20763 }
20764
20765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20766         if ((_res & 1) != 0) return;
20767         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20768         CHECK_ACCESS(_res_ptr);
20769         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
20770         FREE((void*)_res);
20771         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
20772 }
20773
20774 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
20775         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20776         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
20777         return (int64_t)ret_conv;
20778 }
20779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20780         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
20781         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
20782         return ret_conv;
20783 }
20784
20785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20786         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
20787         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20788         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
20789         return (int64_t)ret_conv;
20790 }
20791
20792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20793         LDKSignedRawInvoice o_conv;
20794         o_conv.inner = (void*)(o & (~1));
20795         o_conv.is_owned = (o & 1) || (o == 0);
20796         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20797         o_conv = SignedRawInvoice_clone(&o_conv);
20798         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20799         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
20800         return (int64_t)ret_conv;
20801 }
20802
20803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20804         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20805         CHECK_ACCESS(e_ptr);
20806         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
20807         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
20808         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20809         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
20810         return (int64_t)ret_conv;
20811 }
20812
20813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20814         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
20815         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
20816         return ret_conv;
20817 }
20818
20819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20820         if ((_res & 1) != 0) return;
20821         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20822         CHECK_ACCESS(_res_ptr);
20823         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
20824         FREE((void*)_res);
20825         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
20826 }
20827
20828 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
20829         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20830         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
20831         return (int64_t)ret_conv;
20832 }
20833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20834         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
20835         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
20836         return ret_conv;
20837 }
20838
20839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20840         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
20841         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20842         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
20843         return (int64_t)ret_conv;
20844 }
20845
20846 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
20847         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20848         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
20849         return ((int64_t)ret_conv);
20850 }
20851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20852         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
20853         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
20854         return ret_conv;
20855 }
20856
20857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20858         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
20859         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20860         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
20861         return ((int64_t)ret_conv);
20862 }
20863
20864 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) {
20865         LDKRawInvoice a_conv;
20866         a_conv.inner = (void*)(a & (~1));
20867         a_conv.is_owned = (a & 1) || (a == 0);
20868         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20869         a_conv = RawInvoice_clone(&a_conv);
20870         LDKThirtyTwoBytes b_ref;
20871         CHECK((*env)->GetArrayLength(env, b) == 32);
20872         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
20873         LDKInvoiceSignature c_conv;
20874         c_conv.inner = (void*)(c & (~1));
20875         c_conv.is_owned = (c & 1) || (c == 0);
20876         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
20877         c_conv = InvoiceSignature_clone(&c_conv);
20878         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20879         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
20880         return ((int64_t)ret_conv);
20881 }
20882
20883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20884         if ((_res & 1) != 0) return;
20885         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20886         CHECK_ACCESS(_res_ptr);
20887         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
20888         FREE((void*)_res);
20889         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
20890 }
20891
20892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20893         LDKPayeePubKey o_conv;
20894         o_conv.inner = (void*)(o & (~1));
20895         o_conv.is_owned = (o & 1) || (o == 0);
20896         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20897         o_conv = PayeePubKey_clone(&o_conv);
20898         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20899         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
20900         return (int64_t)ret_conv;
20901 }
20902
20903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20904         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
20905         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20906         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
20907         return (int64_t)ret_conv;
20908 }
20909
20910 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20911         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
20912         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
20913         return ret_conv;
20914 }
20915
20916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20917         if ((_res & 1) != 0) return;
20918         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20919         CHECK_ACCESS(_res_ptr);
20920         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
20921         FREE((void*)_res);
20922         CResult_PayeePubKeyErrorZ_free(_res_conv);
20923 }
20924
20925 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
20926         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20927         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
20928         return (int64_t)ret_conv;
20929 }
20930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20931         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
20932         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
20933         return ret_conv;
20934 }
20935
20936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20937         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
20938         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20939         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
20940         return (int64_t)ret_conv;
20941 }
20942
20943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20944         LDKCVec_PrivateRouteZ _res_constr;
20945         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20946         if (_res_constr.datalen > 0)
20947                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
20948         else
20949                 _res_constr.data = NULL;
20950         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20951         for (size_t o = 0; o < _res_constr.datalen; o++) {
20952                 int64_t _res_conv_14 = _res_vals[o];
20953                 LDKPrivateRoute _res_conv_14_conv;
20954                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
20955                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
20956                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
20957                 _res_constr.data[o] = _res_conv_14_conv;
20958         }
20959         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20960         CVec_PrivateRouteZ_free(_res_constr);
20961 }
20962
20963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20964         LDKPositiveTimestamp o_conv;
20965         o_conv.inner = (void*)(o & (~1));
20966         o_conv.is_owned = (o & 1) || (o == 0);
20967         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20968         o_conv = PositiveTimestamp_clone(&o_conv);
20969         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20970         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
20971         return (int64_t)ret_conv;
20972 }
20973
20974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20975         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
20976         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20977         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
20978         return (int64_t)ret_conv;
20979 }
20980
20981 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20982         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
20983         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
20984         return ret_conv;
20985 }
20986
20987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20988         if ((_res & 1) != 0) return;
20989         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20990         CHECK_ACCESS(_res_ptr);
20991         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
20992         FREE((void*)_res);
20993         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
20994 }
20995
20996 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
20997         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20998         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
20999         return (int64_t)ret_conv;
21000 }
21001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21002         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
21003         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
21004         return ret_conv;
21005 }
21006
21007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21008         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
21009         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
21010         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
21011         return (int64_t)ret_conv;
21012 }
21013
21014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
21015         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21016         *ret_conv = CResult_NoneSemanticErrorZ_ok();
21017         return (int64_t)ret_conv;
21018 }
21019
21020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21021         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
21022         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21023         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
21024         return (int64_t)ret_conv;
21025 }
21026
21027 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21028         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
21029         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
21030         return ret_conv;
21031 }
21032
21033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21034         if ((_res & 1) != 0) return;
21035         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21036         CHECK_ACCESS(_res_ptr);
21037         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
21038         FREE((void*)_res);
21039         CResult_NoneSemanticErrorZ_free(_res_conv);
21040 }
21041
21042 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
21043         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21044         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
21045         return (int64_t)ret_conv;
21046 }
21047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21048         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
21049         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
21050         return ret_conv;
21051 }
21052
21053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21054         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
21055         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21056         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
21057         return (int64_t)ret_conv;
21058 }
21059
21060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21061         LDKInvoice o_conv;
21062         o_conv.inner = (void*)(o & (~1));
21063         o_conv.is_owned = (o & 1) || (o == 0);
21064         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21065         o_conv = Invoice_clone(&o_conv);
21066         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21067         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
21068         return (int64_t)ret_conv;
21069 }
21070
21071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21072         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
21073         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21074         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
21075         return (int64_t)ret_conv;
21076 }
21077
21078 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21079         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
21080         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
21081         return ret_conv;
21082 }
21083
21084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21085         if ((_res & 1) != 0) return;
21086         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21087         CHECK_ACCESS(_res_ptr);
21088         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
21089         FREE((void*)_res);
21090         CResult_InvoiceSemanticErrorZ_free(_res_conv);
21091 }
21092
21093 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
21094         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21095         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
21096         return (int64_t)ret_conv;
21097 }
21098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21099         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
21100         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
21101         return ret_conv;
21102 }
21103
21104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21105         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
21106         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21107         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
21108         return (int64_t)ret_conv;
21109 }
21110
21111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21112         LDKDescription o_conv;
21113         o_conv.inner = (void*)(o & (~1));
21114         o_conv.is_owned = (o & 1) || (o == 0);
21115         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21116         o_conv = Description_clone(&o_conv);
21117         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21118         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
21119         return (int64_t)ret_conv;
21120 }
21121
21122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21123         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
21124         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21125         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
21126         return (int64_t)ret_conv;
21127 }
21128
21129 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21130         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
21131         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
21132         return ret_conv;
21133 }
21134
21135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21136         if ((_res & 1) != 0) return;
21137         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21138         CHECK_ACCESS(_res_ptr);
21139         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
21140         FREE((void*)_res);
21141         CResult_DescriptionCreationErrorZ_free(_res_conv);
21142 }
21143
21144 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
21145         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21146         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
21147         return (int64_t)ret_conv;
21148 }
21149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21150         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
21151         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
21152         return ret_conv;
21153 }
21154
21155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21156         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
21157         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21158         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
21159         return (int64_t)ret_conv;
21160 }
21161
21162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21163         LDKPrivateRoute o_conv;
21164         o_conv.inner = (void*)(o & (~1));
21165         o_conv.is_owned = (o & 1) || (o == 0);
21166         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21167         o_conv = PrivateRoute_clone(&o_conv);
21168         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21169         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
21170         return (int64_t)ret_conv;
21171 }
21172
21173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21174         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
21175         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21176         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
21177         return (int64_t)ret_conv;
21178 }
21179
21180 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21181         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
21182         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
21183         return ret_conv;
21184 }
21185
21186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21187         if ((_res & 1) != 0) return;
21188         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21189         CHECK_ACCESS(_res_ptr);
21190         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
21191         FREE((void*)_res);
21192         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
21193 }
21194
21195 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
21196         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21197         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
21198         return (int64_t)ret_conv;
21199 }
21200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21201         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
21202         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
21203         return ret_conv;
21204 }
21205
21206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21207         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
21208         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21209         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
21210         return (int64_t)ret_conv;
21211 }
21212
21213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
21214         LDKStr o_conv = java_to_owned_str(env, o);
21215         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21216         *ret_conv = CResult_StringErrorZ_ok(o_conv);
21217         return (int64_t)ret_conv;
21218 }
21219
21220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21221         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
21222         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21223         *ret_conv = CResult_StringErrorZ_err(e_conv);
21224         return (int64_t)ret_conv;
21225 }
21226
21227 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21228         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
21229         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
21230         return ret_conv;
21231 }
21232
21233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21234         if ((_res & 1) != 0) return;
21235         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21236         CHECK_ACCESS(_res_ptr);
21237         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
21238         FREE((void*)_res);
21239         CResult_StringErrorZ_free(_res_conv);
21240 }
21241
21242 static inline uintptr_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
21243         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21244         *ret_conv = CResult_StringErrorZ_clone(arg);
21245         return (int64_t)ret_conv;
21246 }
21247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21248         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)(arg & ~1);
21249         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
21250         return ret_conv;
21251 }
21252
21253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21254         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)(orig & ~1);
21255         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21256         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
21257         return (int64_t)ret_conv;
21258 }
21259
21260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21261         LDKChannelMonitorUpdate o_conv;
21262         o_conv.inner = (void*)(o & (~1));
21263         o_conv.is_owned = (o & 1) || (o == 0);
21264         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21265         o_conv = ChannelMonitorUpdate_clone(&o_conv);
21266         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21267         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
21268         return (int64_t)ret_conv;
21269 }
21270
21271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21272         LDKDecodeError e_conv;
21273         e_conv.inner = (void*)(e & (~1));
21274         e_conv.is_owned = (e & 1) || (e == 0);
21275         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21276         e_conv = DecodeError_clone(&e_conv);
21277         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21278         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
21279         return (int64_t)ret_conv;
21280 }
21281
21282 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21283         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
21284         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
21285         return ret_conv;
21286 }
21287
21288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21289         if ((_res & 1) != 0) return;
21290         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21291         CHECK_ACCESS(_res_ptr);
21292         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
21293         FREE((void*)_res);
21294         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
21295 }
21296
21297 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
21298         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21299         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
21300         return (int64_t)ret_conv;
21301 }
21302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21303         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
21304         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
21305         return ret_conv;
21306 }
21307
21308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21309         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
21310         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21311         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
21312         return (int64_t)ret_conv;
21313 }
21314
21315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
21316         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21317         CHECK_ACCESS(o_ptr);
21318         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
21319         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
21320         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
21321         *ret_copy = COption_MonitorEventZ_some(o_conv);
21322         int64_t ret_ref = (uintptr_t)ret_copy;
21323         return ret_ref;
21324 }
21325
21326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
21327         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
21328         *ret_copy = COption_MonitorEventZ_none();
21329         int64_t ret_ref = (uintptr_t)ret_copy;
21330         return ret_ref;
21331 }
21332
21333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21334         if ((_res & 1) != 0) return;
21335         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21336         CHECK_ACCESS(_res_ptr);
21337         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
21338         FREE((void*)_res);
21339         COption_MonitorEventZ_free(_res_conv);
21340 }
21341
21342 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
21343         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
21344         *ret_copy = COption_MonitorEventZ_clone(arg);
21345 int64_t ret_ref = (uintptr_t)ret_copy;
21346         return ret_ref;
21347 }
21348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21349         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
21350         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
21351         return ret_conv;
21352 }
21353
21354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21355         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
21356         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
21357         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
21358         int64_t ret_ref = (uintptr_t)ret_copy;
21359         return ret_ref;
21360 }
21361
21362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21363         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21364         CHECK_ACCESS(o_ptr);
21365         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
21366         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
21367         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21368         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
21369         return (int64_t)ret_conv;
21370 }
21371
21372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21373         LDKDecodeError e_conv;
21374         e_conv.inner = (void*)(e & (~1));
21375         e_conv.is_owned = (e & 1) || (e == 0);
21376         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21377         e_conv = DecodeError_clone(&e_conv);
21378         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21379         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
21380         return (int64_t)ret_conv;
21381 }
21382
21383 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21384         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
21385         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
21386         return ret_conv;
21387 }
21388
21389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21390         if ((_res & 1) != 0) return;
21391         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21392         CHECK_ACCESS(_res_ptr);
21393         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
21394         FREE((void*)_res);
21395         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
21396 }
21397
21398 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
21399         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21400         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
21401         return (int64_t)ret_conv;
21402 }
21403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21404         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
21405         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
21406         return ret_conv;
21407 }
21408
21409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21410         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
21411         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21412         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
21413         return (int64_t)ret_conv;
21414 }
21415
21416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21417         LDKHTLCUpdate o_conv;
21418         o_conv.inner = (void*)(o & (~1));
21419         o_conv.is_owned = (o & 1) || (o == 0);
21420         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21421         o_conv = HTLCUpdate_clone(&o_conv);
21422         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21423         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
21424         return (int64_t)ret_conv;
21425 }
21426
21427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21428         LDKDecodeError e_conv;
21429         e_conv.inner = (void*)(e & (~1));
21430         e_conv.is_owned = (e & 1) || (e == 0);
21431         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21432         e_conv = DecodeError_clone(&e_conv);
21433         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21434         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
21435         return (int64_t)ret_conv;
21436 }
21437
21438 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21439         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
21440         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
21441         return ret_conv;
21442 }
21443
21444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21445         if ((_res & 1) != 0) return;
21446         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21447         CHECK_ACCESS(_res_ptr);
21448         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
21449         FREE((void*)_res);
21450         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
21451 }
21452
21453 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
21454         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21455         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
21456         return (int64_t)ret_conv;
21457 }
21458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21459         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
21460         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
21461         return ret_conv;
21462 }
21463
21464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21465         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
21466         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21467         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
21468         return (int64_t)ret_conv;
21469 }
21470
21471 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
21472         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21473         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
21474         return ((int64_t)ret_conv);
21475 }
21476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21477         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
21478         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
21479         return ret_conv;
21480 }
21481
21482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21483         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
21484         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21485         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
21486         return ((int64_t)ret_conv);
21487 }
21488
21489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
21490         LDKOutPoint a_conv;
21491         a_conv.inner = (void*)(a & (~1));
21492         a_conv.is_owned = (a & 1) || (a == 0);
21493         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21494         a_conv = OutPoint_clone(&a_conv);
21495         LDKCVec_u8Z b_ref;
21496         b_ref.datalen = (*env)->GetArrayLength(env, b);
21497         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
21498         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
21499         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21500         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
21501         return ((int64_t)ret_conv);
21502 }
21503
21504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21505         if ((_res & 1) != 0) return;
21506         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21507         CHECK_ACCESS(_res_ptr);
21508         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
21509         FREE((void*)_res);
21510         C2Tuple_OutPointScriptZ_free(_res_conv);
21511 }
21512
21513 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
21514         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21515         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
21516         return ((int64_t)ret_conv);
21517 }
21518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21519         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
21520         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
21521         return ret_conv;
21522 }
21523
21524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21525         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
21526         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21527         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
21528         return ((int64_t)ret_conv);
21529 }
21530
21531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
21532         LDKCVec_u8Z b_ref;
21533         b_ref.datalen = (*env)->GetArrayLength(env, b);
21534         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
21535         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
21536         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21537         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
21538         return ((int64_t)ret_conv);
21539 }
21540
21541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21542         if ((_res & 1) != 0) return;
21543         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21544         CHECK_ACCESS(_res_ptr);
21545         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
21546         FREE((void*)_res);
21547         C2Tuple_u32ScriptZ_free(_res_conv);
21548 }
21549
21550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21551         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
21552         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21553         if (_res_constr.datalen > 0)
21554                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
21555         else
21556                 _res_constr.data = NULL;
21557         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21558         for (size_t v = 0; v < _res_constr.datalen; v++) {
21559                 int64_t _res_conv_21 = _res_vals[v];
21560                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
21561                 CHECK_ACCESS(_res_conv_21_ptr);
21562                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
21563                 FREE((void*)_res_conv_21);
21564                 _res_constr.data[v] = _res_conv_21_conv;
21565         }
21566         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21567         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
21568 }
21569
21570 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
21571         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
21572         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
21573         return ((int64_t)ret_conv);
21574 }
21575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21576         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
21577         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
21578         return ret_conv;
21579 }
21580
21581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21582         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
21583         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
21584         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
21585         return ((int64_t)ret_conv);
21586 }
21587
21588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
21589         LDKThirtyTwoBytes a_ref;
21590         CHECK((*env)->GetArrayLength(env, a) == 32);
21591         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21592         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
21593         b_constr.datalen = (*env)->GetArrayLength(env, b);
21594         if (b_constr.datalen > 0)
21595                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
21596         else
21597                 b_constr.data = NULL;
21598         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
21599         for (size_t v = 0; v < b_constr.datalen; v++) {
21600                 int64_t b_conv_21 = b_vals[v];
21601                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
21602                 CHECK_ACCESS(b_conv_21_ptr);
21603                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
21604                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
21605                 b_constr.data[v] = b_conv_21_conv;
21606         }
21607         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
21608         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
21609         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
21610         return ((int64_t)ret_conv);
21611 }
21612
21613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21614         if ((_res & 1) != 0) return;
21615         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21616         CHECK_ACCESS(_res_ptr);
21617         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
21618         FREE((void*)_res);
21619         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
21620 }
21621
21622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21623         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
21624         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21625         if (_res_constr.datalen > 0)
21626                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
21627         else
21628                 _res_constr.data = NULL;
21629         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21630         for (size_t o = 0; o < _res_constr.datalen; o++) {
21631                 int64_t _res_conv_40 = _res_vals[o];
21632                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
21633                 CHECK_ACCESS(_res_conv_40_ptr);
21634                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
21635                 FREE((void*)_res_conv_40);
21636                 _res_constr.data[o] = _res_conv_40_conv;
21637         }
21638         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21639         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
21640 }
21641
21642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21643         LDKCVec_EventZ _res_constr;
21644         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21645         if (_res_constr.datalen > 0)
21646                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
21647         else
21648                 _res_constr.data = NULL;
21649         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21650         for (size_t h = 0; h < _res_constr.datalen; h++) {
21651                 int64_t _res_conv_7 = _res_vals[h];
21652                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
21653                 CHECK_ACCESS(_res_conv_7_ptr);
21654                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
21655                 FREE((void*)_res_conv_7);
21656                 _res_constr.data[h] = _res_conv_7_conv;
21657         }
21658         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21659         CVec_EventZ_free(_res_constr);
21660 }
21661
21662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
21663         LDKCVec_TransactionZ _res_constr;
21664         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21665         if (_res_constr.datalen > 0)
21666                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
21667         else
21668                 _res_constr.data = NULL;
21669         for (size_t i = 0; i < _res_constr.datalen; i++) {
21670                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
21671                 LDKTransaction _res_conv_8_ref;
21672                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
21673                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
21674                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
21675                 _res_conv_8_ref.data_is_owned = true;
21676                 _res_constr.data[i] = _res_conv_8_ref;
21677         }
21678         CVec_TransactionZ_free(_res_constr);
21679 }
21680
21681 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
21682         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
21683         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
21684         return ((int64_t)ret_conv);
21685 }
21686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21687         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
21688         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
21689         return ret_conv;
21690 }
21691
21692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21693         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
21694         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
21695         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
21696         return ((int64_t)ret_conv);
21697 }
21698
21699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
21700         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
21701         CHECK_ACCESS(b_ptr);
21702         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
21703         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
21704         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
21705         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
21706         return ((int64_t)ret_conv);
21707 }
21708
21709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21710         if ((_res & 1) != 0) return;
21711         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21712         CHECK_ACCESS(_res_ptr);
21713         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
21714         FREE((void*)_res);
21715         C2Tuple_u32TxOutZ_free(_res_conv);
21716 }
21717
21718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21719         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
21720         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21721         if (_res_constr.datalen > 0)
21722                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
21723         else
21724                 _res_constr.data = NULL;
21725         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21726         for (size_t u = 0; u < _res_constr.datalen; u++) {
21727                 int64_t _res_conv_20 = _res_vals[u];
21728                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
21729                 CHECK_ACCESS(_res_conv_20_ptr);
21730                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
21731                 FREE((void*)_res_conv_20);
21732                 _res_constr.data[u] = _res_conv_20_conv;
21733         }
21734         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21735         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
21736 }
21737
21738 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
21739         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21740         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
21741         return ((int64_t)ret_conv);
21742 }
21743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21744         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
21745         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
21746         return ret_conv;
21747 }
21748
21749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21750         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
21751         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21752         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
21753         return ((int64_t)ret_conv);
21754 }
21755
21756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
21757         LDKThirtyTwoBytes a_ref;
21758         CHECK((*env)->GetArrayLength(env, a) == 32);
21759         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21760         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
21761         b_constr.datalen = (*env)->GetArrayLength(env, b);
21762         if (b_constr.datalen > 0)
21763                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
21764         else
21765                 b_constr.data = NULL;
21766         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
21767         for (size_t u = 0; u < b_constr.datalen; u++) {
21768                 int64_t b_conv_20 = b_vals[u];
21769                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
21770                 CHECK_ACCESS(b_conv_20_ptr);
21771                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
21772                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
21773                 b_constr.data[u] = b_conv_20_conv;
21774         }
21775         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
21776         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21777         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
21778         return ((int64_t)ret_conv);
21779 }
21780
21781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21782         if ((_res & 1) != 0) return;
21783         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21784         CHECK_ACCESS(_res_ptr);
21785         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
21786         FREE((void*)_res);
21787         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
21788 }
21789
21790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21791         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
21792         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21793         if (_res_constr.datalen > 0)
21794                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
21795         else
21796                 _res_constr.data = NULL;
21797         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21798         for (size_t n = 0; n < _res_constr.datalen; n++) {
21799                 int64_t _res_conv_39 = _res_vals[n];
21800                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
21801                 CHECK_ACCESS(_res_conv_39_ptr);
21802                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
21803                 FREE((void*)_res_conv_39);
21804                 _res_constr.data[n] = _res_conv_39_conv;
21805         }
21806         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21807         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
21808 }
21809
21810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21811         LDKCVec_BalanceZ _res_constr;
21812         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21813         if (_res_constr.datalen > 0)
21814                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
21815         else
21816                 _res_constr.data = NULL;
21817         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21818         for (size_t j = 0; j < _res_constr.datalen; j++) {
21819                 int64_t _res_conv_9 = _res_vals[j];
21820                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
21821                 CHECK_ACCESS(_res_conv_9_ptr);
21822                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
21823                 FREE((void*)_res_conv_9);
21824                 _res_constr.data[j] = _res_conv_9_conv;
21825         }
21826         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21827         CVec_BalanceZ_free(_res_constr);
21828 }
21829
21830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21831         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21832         CHECK_ACCESS(o_ptr);
21833         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
21834         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
21835         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21836         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
21837         return (int64_t)ret_conv;
21838 }
21839
21840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21841         LDKDecodeError e_conv;
21842         e_conv.inner = (void*)(e & (~1));
21843         e_conv.is_owned = (e & 1) || (e == 0);
21844         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21845         e_conv = DecodeError_clone(&e_conv);
21846         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21847         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
21848         return (int64_t)ret_conv;
21849 }
21850
21851 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21852         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
21853         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
21854         return ret_conv;
21855 }
21856
21857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21858         if ((_res & 1) != 0) return;
21859         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21860         CHECK_ACCESS(_res_ptr);
21861         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
21862         FREE((void*)_res);
21863         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
21864 }
21865
21866 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
21867         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21868         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
21869         return (int64_t)ret_conv;
21870 }
21871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21872         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
21873         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
21874         return ret_conv;
21875 }
21876
21877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21878         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
21879         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21880         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
21881         return (int64_t)ret_conv;
21882 }
21883
21884 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
21885         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21886         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
21887         return ((int64_t)ret_conv);
21888 }
21889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21890         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
21891         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
21892         return ret_conv;
21893 }
21894
21895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21896         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
21897         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21898         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
21899         return ((int64_t)ret_conv);
21900 }
21901
21902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
21903         LDKPublicKey a_ref;
21904         CHECK((*env)->GetArrayLength(env, a) == 33);
21905         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
21906         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
21907         CHECK_ACCESS(b_ptr);
21908         LDKType b_conv = *(LDKType*)(b_ptr);
21909         if (b_conv.free == LDKType_JCalls_free) {
21910                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21911                 LDKType_JCalls_cloned(&b_conv);
21912         }
21913         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21914         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
21915         return ((int64_t)ret_conv);
21916 }
21917
21918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21919         if ((_res & 1) != 0) return;
21920         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21921         CHECK_ACCESS(_res_ptr);
21922         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
21923         FREE((void*)_res);
21924         C2Tuple_PublicKeyTypeZ_free(_res_conv);
21925 }
21926
21927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21928         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
21929         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21930         if (_res_constr.datalen > 0)
21931                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
21932         else
21933                 _res_constr.data = NULL;
21934         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21935         for (size_t z = 0; z < _res_constr.datalen; z++) {
21936                 int64_t _res_conv_25 = _res_vals[z];
21937                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
21938                 CHECK_ACCESS(_res_conv_25_ptr);
21939                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
21940                 FREE((void*)_res_conv_25);
21941                 _res_constr.data[z] = _res_conv_25_conv;
21942         }
21943         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21944         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
21945 }
21946
21947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
21948         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21949         CHECK_ACCESS(o_ptr);
21950         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
21951         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
21952         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21953         *ret_copy = COption_NetAddressZ_some(o_conv);
21954         int64_t ret_ref = (uintptr_t)ret_copy;
21955         return ret_ref;
21956 }
21957
21958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
21959         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21960         *ret_copy = COption_NetAddressZ_none();
21961         int64_t ret_ref = (uintptr_t)ret_copy;
21962         return ret_ref;
21963 }
21964
21965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21966         if ((_res & 1) != 0) return;
21967         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21968         CHECK_ACCESS(_res_ptr);
21969         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
21970         FREE((void*)_res);
21971         COption_NetAddressZ_free(_res_conv);
21972 }
21973
21974 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
21975         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21976         *ret_copy = COption_NetAddressZ_clone(arg);
21977 int64_t ret_ref = (uintptr_t)ret_copy;
21978         return ret_ref;
21979 }
21980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21981         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
21982         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
21983         return ret_conv;
21984 }
21985
21986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21987         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
21988         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21989         *ret_copy = COption_NetAddressZ_clone(orig_conv);
21990         int64_t ret_ref = (uintptr_t)ret_copy;
21991         return ret_ref;
21992 }
21993
21994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21995         LDKCVec_u8Z o_ref;
21996         o_ref.datalen = (*env)->GetArrayLength(env, o);
21997         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
21998         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
21999         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22000         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
22001         return (int64_t)ret_conv;
22002 }
22003
22004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22005         LDKPeerHandleError e_conv;
22006         e_conv.inner = (void*)(e & (~1));
22007         e_conv.is_owned = (e & 1) || (e == 0);
22008         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22009         e_conv = PeerHandleError_clone(&e_conv);
22010         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22011         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
22012         return (int64_t)ret_conv;
22013 }
22014
22015 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22016         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
22017         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
22018         return ret_conv;
22019 }
22020
22021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22022         if ((_res & 1) != 0) return;
22023         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22024         CHECK_ACCESS(_res_ptr);
22025         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
22026         FREE((void*)_res);
22027         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
22028 }
22029
22030 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
22031         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22032         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
22033         return (int64_t)ret_conv;
22034 }
22035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22036         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
22037         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
22038         return ret_conv;
22039 }
22040
22041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22042         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
22043         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22044         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
22045         return (int64_t)ret_conv;
22046 }
22047
22048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
22049         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22050         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
22051         return (int64_t)ret_conv;
22052 }
22053
22054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22055         LDKPeerHandleError e_conv;
22056         e_conv.inner = (void*)(e & (~1));
22057         e_conv.is_owned = (e & 1) || (e == 0);
22058         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22059         e_conv = PeerHandleError_clone(&e_conv);
22060         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22061         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
22062         return (int64_t)ret_conv;
22063 }
22064
22065 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22066         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
22067         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
22068         return ret_conv;
22069 }
22070
22071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22072         if ((_res & 1) != 0) return;
22073         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22074         CHECK_ACCESS(_res_ptr);
22075         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
22076         FREE((void*)_res);
22077         CResult_NonePeerHandleErrorZ_free(_res_conv);
22078 }
22079
22080 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
22081         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22082         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
22083         return (int64_t)ret_conv;
22084 }
22085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22086         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
22087         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
22088         return ret_conv;
22089 }
22090
22091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22092         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
22093         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22094         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
22095         return (int64_t)ret_conv;
22096 }
22097
22098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
22099         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22100         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
22101         return (int64_t)ret_conv;
22102 }
22103
22104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22105         LDKPeerHandleError e_conv;
22106         e_conv.inner = (void*)(e & (~1));
22107         e_conv.is_owned = (e & 1) || (e == 0);
22108         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22109         e_conv = PeerHandleError_clone(&e_conv);
22110         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22111         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
22112         return (int64_t)ret_conv;
22113 }
22114
22115 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22116         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
22117         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
22118         return ret_conv;
22119 }
22120
22121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22122         if ((_res & 1) != 0) return;
22123         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22124         CHECK_ACCESS(_res_ptr);
22125         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
22126         FREE((void*)_res);
22127         CResult_boolPeerHandleErrorZ_free(_res_conv);
22128 }
22129
22130 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
22131         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22132         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
22133         return (int64_t)ret_conv;
22134 }
22135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22136         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
22137         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
22138         return ret_conv;
22139 }
22140
22141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22142         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
22143         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22144         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
22145         return (int64_t)ret_conv;
22146 }
22147
22148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1ok(JNIEnv *env, jclass clz, int32_t o) {
22149         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
22150         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
22151         return (int64_t)ret_conv;
22152 }
22153
22154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22155         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
22156         CHECK_ACCESS(e_ptr);
22157         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
22158         e_conv = GraphSyncError_clone((LDKGraphSyncError*)(((uintptr_t)e) & ~1));
22159         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
22160         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
22161         return (int64_t)ret_conv;
22162 }
22163
22164 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22165         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)(o & ~1);
22166         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
22167         return ret_conv;
22168 }
22169
22170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22171         if ((_res & 1) != 0) return;
22172         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22173         CHECK_ACCESS(_res_ptr);
22174         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
22175         FREE((void*)_res);
22176         CResult_u32GraphSyncErrorZ_free(_res_conv);
22177 }
22178
22179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22180         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
22181         CHECK_ACCESS(o_ptr);
22182         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
22183         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
22184         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22185         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
22186         return (int64_t)ret_conv;
22187 }
22188
22189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22190         LDKDecodeError e_conv;
22191         e_conv.inner = (void*)(e & (~1));
22192         e_conv.is_owned = (e & 1) || (e == 0);
22193         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22194         e_conv = DecodeError_clone(&e_conv);
22195         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22196         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
22197         return (int64_t)ret_conv;
22198 }
22199
22200 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22201         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
22202         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
22203         return ret_conv;
22204 }
22205
22206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22207         if ((_res & 1) != 0) return;
22208         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22209         CHECK_ACCESS(_res_ptr);
22210         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
22211         FREE((void*)_res);
22212         CResult_NetAddressDecodeErrorZ_free(_res_conv);
22213 }
22214
22215 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
22216         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22217         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
22218         return (int64_t)ret_conv;
22219 }
22220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22221         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
22222         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
22223         return ret_conv;
22224 }
22225
22226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22227         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
22228         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22229         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
22230         return (int64_t)ret_conv;
22231 }
22232
22233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22234         LDKCVec_UpdateAddHTLCZ _res_constr;
22235         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22236         if (_res_constr.datalen > 0)
22237                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
22238         else
22239                 _res_constr.data = NULL;
22240         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22241         for (size_t p = 0; p < _res_constr.datalen; p++) {
22242                 int64_t _res_conv_15 = _res_vals[p];
22243                 LDKUpdateAddHTLC _res_conv_15_conv;
22244                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
22245                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
22246                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
22247                 _res_constr.data[p] = _res_conv_15_conv;
22248         }
22249         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22250         CVec_UpdateAddHTLCZ_free(_res_constr);
22251 }
22252
22253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22254         LDKCVec_UpdateFulfillHTLCZ _res_constr;
22255         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22256         if (_res_constr.datalen > 0)
22257                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
22258         else
22259                 _res_constr.data = NULL;
22260         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22261         for (size_t t = 0; t < _res_constr.datalen; t++) {
22262                 int64_t _res_conv_19 = _res_vals[t];
22263                 LDKUpdateFulfillHTLC _res_conv_19_conv;
22264                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
22265                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
22266                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
22267                 _res_constr.data[t] = _res_conv_19_conv;
22268         }
22269         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22270         CVec_UpdateFulfillHTLCZ_free(_res_constr);
22271 }
22272
22273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22274         LDKCVec_UpdateFailHTLCZ _res_constr;
22275         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22276         if (_res_constr.datalen > 0)
22277                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
22278         else
22279                 _res_constr.data = NULL;
22280         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22281         for (size_t q = 0; q < _res_constr.datalen; q++) {
22282                 int64_t _res_conv_16 = _res_vals[q];
22283                 LDKUpdateFailHTLC _res_conv_16_conv;
22284                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
22285                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
22286                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
22287                 _res_constr.data[q] = _res_conv_16_conv;
22288         }
22289         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22290         CVec_UpdateFailHTLCZ_free(_res_constr);
22291 }
22292
22293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22294         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
22295         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22296         if (_res_constr.datalen > 0)
22297                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
22298         else
22299                 _res_constr.data = NULL;
22300         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22301         for (size_t z = 0; z < _res_constr.datalen; z++) {
22302                 int64_t _res_conv_25 = _res_vals[z];
22303                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
22304                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
22305                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
22306                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
22307                 _res_constr.data[z] = _res_conv_25_conv;
22308         }
22309         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22310         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
22311 }
22312
22313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22314         LDKAcceptChannel o_conv;
22315         o_conv.inner = (void*)(o & (~1));
22316         o_conv.is_owned = (o & 1) || (o == 0);
22317         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22318         o_conv = AcceptChannel_clone(&o_conv);
22319         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
22320         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
22321         return (int64_t)ret_conv;
22322 }
22323
22324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22325         LDKDecodeError e_conv;
22326         e_conv.inner = (void*)(e & (~1));
22327         e_conv.is_owned = (e & 1) || (e == 0);
22328         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22329         e_conv = DecodeError_clone(&e_conv);
22330         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
22331         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
22332         return (int64_t)ret_conv;
22333 }
22334
22335 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22336         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
22337         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
22338         return ret_conv;
22339 }
22340
22341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22342         if ((_res & 1) != 0) return;
22343         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22344         CHECK_ACCESS(_res_ptr);
22345         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
22346         FREE((void*)_res);
22347         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
22348 }
22349
22350 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
22351         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
22352         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
22353         return (int64_t)ret_conv;
22354 }
22355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22356         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
22357         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
22358         return ret_conv;
22359 }
22360
22361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22362         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
22363         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
22364         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
22365         return (int64_t)ret_conv;
22366 }
22367
22368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22369         LDKAnnouncementSignatures o_conv;
22370         o_conv.inner = (void*)(o & (~1));
22371         o_conv.is_owned = (o & 1) || (o == 0);
22372         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22373         o_conv = AnnouncementSignatures_clone(&o_conv);
22374         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
22375         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
22376         return (int64_t)ret_conv;
22377 }
22378
22379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22380         LDKDecodeError e_conv;
22381         e_conv.inner = (void*)(e & (~1));
22382         e_conv.is_owned = (e & 1) || (e == 0);
22383         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22384         e_conv = DecodeError_clone(&e_conv);
22385         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
22386         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
22387         return (int64_t)ret_conv;
22388 }
22389
22390 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22391         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
22392         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
22393         return ret_conv;
22394 }
22395
22396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22397         if ((_res & 1) != 0) return;
22398         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22399         CHECK_ACCESS(_res_ptr);
22400         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
22401         FREE((void*)_res);
22402         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
22403 }
22404
22405 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
22406         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
22407         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
22408         return (int64_t)ret_conv;
22409 }
22410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22411         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
22412         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
22413         return ret_conv;
22414 }
22415
22416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22417         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
22418         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
22419         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
22420         return (int64_t)ret_conv;
22421 }
22422
22423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22424         LDKChannelReestablish o_conv;
22425         o_conv.inner = (void*)(o & (~1));
22426         o_conv.is_owned = (o & 1) || (o == 0);
22427         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22428         o_conv = ChannelReestablish_clone(&o_conv);
22429         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22430         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
22431         return (int64_t)ret_conv;
22432 }
22433
22434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22435         LDKDecodeError e_conv;
22436         e_conv.inner = (void*)(e & (~1));
22437         e_conv.is_owned = (e & 1) || (e == 0);
22438         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22439         e_conv = DecodeError_clone(&e_conv);
22440         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22441         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
22442         return (int64_t)ret_conv;
22443 }
22444
22445 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22446         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
22447         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
22448         return ret_conv;
22449 }
22450
22451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22452         if ((_res & 1) != 0) return;
22453         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22454         CHECK_ACCESS(_res_ptr);
22455         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
22456         FREE((void*)_res);
22457         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
22458 }
22459
22460 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
22461         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22462         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
22463         return (int64_t)ret_conv;
22464 }
22465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22466         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
22467         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
22468         return ret_conv;
22469 }
22470
22471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22472         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
22473         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22474         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
22475         return (int64_t)ret_conv;
22476 }
22477
22478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22479         LDKClosingSigned o_conv;
22480         o_conv.inner = (void*)(o & (~1));
22481         o_conv.is_owned = (o & 1) || (o == 0);
22482         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22483         o_conv = ClosingSigned_clone(&o_conv);
22484         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22485         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
22486         return (int64_t)ret_conv;
22487 }
22488
22489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22490         LDKDecodeError e_conv;
22491         e_conv.inner = (void*)(e & (~1));
22492         e_conv.is_owned = (e & 1) || (e == 0);
22493         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22494         e_conv = DecodeError_clone(&e_conv);
22495         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22496         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
22497         return (int64_t)ret_conv;
22498 }
22499
22500 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22501         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
22502         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
22503         return ret_conv;
22504 }
22505
22506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22507         if ((_res & 1) != 0) return;
22508         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22509         CHECK_ACCESS(_res_ptr);
22510         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
22511         FREE((void*)_res);
22512         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
22513 }
22514
22515 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
22516         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22517         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
22518         return (int64_t)ret_conv;
22519 }
22520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22521         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
22522         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
22523         return ret_conv;
22524 }
22525
22526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22527         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
22528         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22529         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
22530         return (int64_t)ret_conv;
22531 }
22532
22533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22534         LDKClosingSignedFeeRange o_conv;
22535         o_conv.inner = (void*)(o & (~1));
22536         o_conv.is_owned = (o & 1) || (o == 0);
22537         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22538         o_conv = ClosingSignedFeeRange_clone(&o_conv);
22539         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22540         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
22541         return (int64_t)ret_conv;
22542 }
22543
22544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22545         LDKDecodeError e_conv;
22546         e_conv.inner = (void*)(e & (~1));
22547         e_conv.is_owned = (e & 1) || (e == 0);
22548         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22549         e_conv = DecodeError_clone(&e_conv);
22550         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22551         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
22552         return (int64_t)ret_conv;
22553 }
22554
22555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22556         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
22557         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
22558         return ret_conv;
22559 }
22560
22561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22562         if ((_res & 1) != 0) return;
22563         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22564         CHECK_ACCESS(_res_ptr);
22565         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
22566         FREE((void*)_res);
22567         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
22568 }
22569
22570 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
22571         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22572         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
22573         return (int64_t)ret_conv;
22574 }
22575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22576         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
22577         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
22578         return ret_conv;
22579 }
22580
22581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22582         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
22583         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22584         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
22585         return (int64_t)ret_conv;
22586 }
22587
22588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22589         LDKCommitmentSigned o_conv;
22590         o_conv.inner = (void*)(o & (~1));
22591         o_conv.is_owned = (o & 1) || (o == 0);
22592         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22593         o_conv = CommitmentSigned_clone(&o_conv);
22594         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22595         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
22596         return (int64_t)ret_conv;
22597 }
22598
22599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22600         LDKDecodeError e_conv;
22601         e_conv.inner = (void*)(e & (~1));
22602         e_conv.is_owned = (e & 1) || (e == 0);
22603         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22604         e_conv = DecodeError_clone(&e_conv);
22605         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22606         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
22607         return (int64_t)ret_conv;
22608 }
22609
22610 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22611         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
22612         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
22613         return ret_conv;
22614 }
22615
22616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22617         if ((_res & 1) != 0) return;
22618         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22619         CHECK_ACCESS(_res_ptr);
22620         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
22621         FREE((void*)_res);
22622         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
22623 }
22624
22625 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
22626         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22627         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
22628         return (int64_t)ret_conv;
22629 }
22630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22631         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
22632         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
22633         return ret_conv;
22634 }
22635
22636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22637         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
22638         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22639         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
22640         return (int64_t)ret_conv;
22641 }
22642
22643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22644         LDKFundingCreated o_conv;
22645         o_conv.inner = (void*)(o & (~1));
22646         o_conv.is_owned = (o & 1) || (o == 0);
22647         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22648         o_conv = FundingCreated_clone(&o_conv);
22649         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22650         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
22651         return (int64_t)ret_conv;
22652 }
22653
22654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22655         LDKDecodeError e_conv;
22656         e_conv.inner = (void*)(e & (~1));
22657         e_conv.is_owned = (e & 1) || (e == 0);
22658         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22659         e_conv = DecodeError_clone(&e_conv);
22660         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22661         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
22662         return (int64_t)ret_conv;
22663 }
22664
22665 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22666         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
22667         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
22668         return ret_conv;
22669 }
22670
22671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22672         if ((_res & 1) != 0) return;
22673         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22674         CHECK_ACCESS(_res_ptr);
22675         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
22676         FREE((void*)_res);
22677         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
22678 }
22679
22680 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
22681         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22682         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
22683         return (int64_t)ret_conv;
22684 }
22685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22686         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
22687         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
22688         return ret_conv;
22689 }
22690
22691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22692         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
22693         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22694         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
22695         return (int64_t)ret_conv;
22696 }
22697
22698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22699         LDKFundingSigned o_conv;
22700         o_conv.inner = (void*)(o & (~1));
22701         o_conv.is_owned = (o & 1) || (o == 0);
22702         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22703         o_conv = FundingSigned_clone(&o_conv);
22704         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22705         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
22706         return (int64_t)ret_conv;
22707 }
22708
22709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22710         LDKDecodeError e_conv;
22711         e_conv.inner = (void*)(e & (~1));
22712         e_conv.is_owned = (e & 1) || (e == 0);
22713         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22714         e_conv = DecodeError_clone(&e_conv);
22715         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22716         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
22717         return (int64_t)ret_conv;
22718 }
22719
22720 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22721         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
22722         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
22723         return ret_conv;
22724 }
22725
22726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22727         if ((_res & 1) != 0) return;
22728         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22729         CHECK_ACCESS(_res_ptr);
22730         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
22731         FREE((void*)_res);
22732         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
22733 }
22734
22735 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
22736         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22737         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
22738         return (int64_t)ret_conv;
22739 }
22740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22741         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
22742         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
22743         return ret_conv;
22744 }
22745
22746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22747         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
22748         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22749         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
22750         return (int64_t)ret_conv;
22751 }
22752
22753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22754         LDKChannelReady o_conv;
22755         o_conv.inner = (void*)(o & (~1));
22756         o_conv.is_owned = (o & 1) || (o == 0);
22757         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22758         o_conv = ChannelReady_clone(&o_conv);
22759         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22760         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
22761         return (int64_t)ret_conv;
22762 }
22763
22764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22765         LDKDecodeError e_conv;
22766         e_conv.inner = (void*)(e & (~1));
22767         e_conv.is_owned = (e & 1) || (e == 0);
22768         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22769         e_conv = DecodeError_clone(&e_conv);
22770         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22771         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
22772         return (int64_t)ret_conv;
22773 }
22774
22775 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22776         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(o & ~1);
22777         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
22778         return ret_conv;
22779 }
22780
22781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22782         if ((_res & 1) != 0) return;
22783         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22784         CHECK_ACCESS(_res_ptr);
22785         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
22786         FREE((void*)_res);
22787         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
22788 }
22789
22790 static inline uintptr_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
22791         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22792         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
22793         return (int64_t)ret_conv;
22794 }
22795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22796         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(arg & ~1);
22797         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
22798         return ret_conv;
22799 }
22800
22801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22802         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(orig & ~1);
22803         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22804         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
22805         return (int64_t)ret_conv;
22806 }
22807
22808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22809         LDKInit o_conv;
22810         o_conv.inner = (void*)(o & (~1));
22811         o_conv.is_owned = (o & 1) || (o == 0);
22812         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22813         o_conv = Init_clone(&o_conv);
22814         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22815         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
22816         return (int64_t)ret_conv;
22817 }
22818
22819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22820         LDKDecodeError e_conv;
22821         e_conv.inner = (void*)(e & (~1));
22822         e_conv.is_owned = (e & 1) || (e == 0);
22823         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22824         e_conv = DecodeError_clone(&e_conv);
22825         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22826         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
22827         return (int64_t)ret_conv;
22828 }
22829
22830 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22831         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
22832         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
22833         return ret_conv;
22834 }
22835
22836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22837         if ((_res & 1) != 0) return;
22838         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22839         CHECK_ACCESS(_res_ptr);
22840         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
22841         FREE((void*)_res);
22842         CResult_InitDecodeErrorZ_free(_res_conv);
22843 }
22844
22845 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
22846         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22847         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
22848         return (int64_t)ret_conv;
22849 }
22850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22851         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
22852         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
22853         return ret_conv;
22854 }
22855
22856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22857         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
22858         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22859         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
22860         return (int64_t)ret_conv;
22861 }
22862
22863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22864         LDKOpenChannel o_conv;
22865         o_conv.inner = (void*)(o & (~1));
22866         o_conv.is_owned = (o & 1) || (o == 0);
22867         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22868         o_conv = OpenChannel_clone(&o_conv);
22869         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22870         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
22871         return (int64_t)ret_conv;
22872 }
22873
22874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22875         LDKDecodeError e_conv;
22876         e_conv.inner = (void*)(e & (~1));
22877         e_conv.is_owned = (e & 1) || (e == 0);
22878         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22879         e_conv = DecodeError_clone(&e_conv);
22880         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22881         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
22882         return (int64_t)ret_conv;
22883 }
22884
22885 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22886         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
22887         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
22888         return ret_conv;
22889 }
22890
22891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22892         if ((_res & 1) != 0) return;
22893         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22894         CHECK_ACCESS(_res_ptr);
22895         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
22896         FREE((void*)_res);
22897         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
22898 }
22899
22900 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
22901         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22902         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
22903         return (int64_t)ret_conv;
22904 }
22905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22906         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
22907         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
22908         return ret_conv;
22909 }
22910
22911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22912         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
22913         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22914         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
22915         return (int64_t)ret_conv;
22916 }
22917
22918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22919         LDKRevokeAndACK o_conv;
22920         o_conv.inner = (void*)(o & (~1));
22921         o_conv.is_owned = (o & 1) || (o == 0);
22922         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22923         o_conv = RevokeAndACK_clone(&o_conv);
22924         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22925         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
22926         return (int64_t)ret_conv;
22927 }
22928
22929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22930         LDKDecodeError e_conv;
22931         e_conv.inner = (void*)(e & (~1));
22932         e_conv.is_owned = (e & 1) || (e == 0);
22933         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22934         e_conv = DecodeError_clone(&e_conv);
22935         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22936         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
22937         return (int64_t)ret_conv;
22938 }
22939
22940 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22941         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
22942         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
22943         return ret_conv;
22944 }
22945
22946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22947         if ((_res & 1) != 0) return;
22948         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22949         CHECK_ACCESS(_res_ptr);
22950         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
22951         FREE((void*)_res);
22952         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
22953 }
22954
22955 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
22956         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22957         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
22958         return (int64_t)ret_conv;
22959 }
22960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22961         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
22962         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
22963         return ret_conv;
22964 }
22965
22966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22967         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
22968         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22969         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
22970         return (int64_t)ret_conv;
22971 }
22972
22973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22974         LDKShutdown o_conv;
22975         o_conv.inner = (void*)(o & (~1));
22976         o_conv.is_owned = (o & 1) || (o == 0);
22977         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22978         o_conv = Shutdown_clone(&o_conv);
22979         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22980         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
22981         return (int64_t)ret_conv;
22982 }
22983
22984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22985         LDKDecodeError e_conv;
22986         e_conv.inner = (void*)(e & (~1));
22987         e_conv.is_owned = (e & 1) || (e == 0);
22988         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22989         e_conv = DecodeError_clone(&e_conv);
22990         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22991         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
22992         return (int64_t)ret_conv;
22993 }
22994
22995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22996         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
22997         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
22998         return ret_conv;
22999 }
23000
23001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23002         if ((_res & 1) != 0) return;
23003         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23004         CHECK_ACCESS(_res_ptr);
23005         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
23006         FREE((void*)_res);
23007         CResult_ShutdownDecodeErrorZ_free(_res_conv);
23008 }
23009
23010 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
23011         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23012         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
23013         return (int64_t)ret_conv;
23014 }
23015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23016         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
23017         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
23018         return ret_conv;
23019 }
23020
23021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23022         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
23023         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23024         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
23025         return (int64_t)ret_conv;
23026 }
23027
23028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23029         LDKUpdateFailHTLC o_conv;
23030         o_conv.inner = (void*)(o & (~1));
23031         o_conv.is_owned = (o & 1) || (o == 0);
23032         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23033         o_conv = UpdateFailHTLC_clone(&o_conv);
23034         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23035         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
23036         return (int64_t)ret_conv;
23037 }
23038
23039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23040         LDKDecodeError e_conv;
23041         e_conv.inner = (void*)(e & (~1));
23042         e_conv.is_owned = (e & 1) || (e == 0);
23043         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23044         e_conv = DecodeError_clone(&e_conv);
23045         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23046         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
23047         return (int64_t)ret_conv;
23048 }
23049
23050 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23051         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
23052         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
23053         return ret_conv;
23054 }
23055
23056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23057         if ((_res & 1) != 0) return;
23058         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23059         CHECK_ACCESS(_res_ptr);
23060         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
23061         FREE((void*)_res);
23062         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
23063 }
23064
23065 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
23066         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23067         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
23068         return (int64_t)ret_conv;
23069 }
23070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23071         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
23072         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
23073         return ret_conv;
23074 }
23075
23076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23077         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
23078         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23079         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
23080         return (int64_t)ret_conv;
23081 }
23082
23083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23084         LDKUpdateFailMalformedHTLC o_conv;
23085         o_conv.inner = (void*)(o & (~1));
23086         o_conv.is_owned = (o & 1) || (o == 0);
23087         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23088         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
23089         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23090         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
23091         return (int64_t)ret_conv;
23092 }
23093
23094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23095         LDKDecodeError e_conv;
23096         e_conv.inner = (void*)(e & (~1));
23097         e_conv.is_owned = (e & 1) || (e == 0);
23098         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23099         e_conv = DecodeError_clone(&e_conv);
23100         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23101         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
23102         return (int64_t)ret_conv;
23103 }
23104
23105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23106         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
23107         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
23108         return ret_conv;
23109 }
23110
23111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23112         if ((_res & 1) != 0) return;
23113         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23114         CHECK_ACCESS(_res_ptr);
23115         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
23116         FREE((void*)_res);
23117         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
23118 }
23119
23120 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
23121         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23122         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
23123         return (int64_t)ret_conv;
23124 }
23125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23126         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
23127         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
23128         return ret_conv;
23129 }
23130
23131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23132         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
23133         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23134         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
23135         return (int64_t)ret_conv;
23136 }
23137
23138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23139         LDKUpdateFee o_conv;
23140         o_conv.inner = (void*)(o & (~1));
23141         o_conv.is_owned = (o & 1) || (o == 0);
23142         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23143         o_conv = UpdateFee_clone(&o_conv);
23144         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23145         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
23146         return (int64_t)ret_conv;
23147 }
23148
23149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23150         LDKDecodeError e_conv;
23151         e_conv.inner = (void*)(e & (~1));
23152         e_conv.is_owned = (e & 1) || (e == 0);
23153         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23154         e_conv = DecodeError_clone(&e_conv);
23155         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23156         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
23157         return (int64_t)ret_conv;
23158 }
23159
23160 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23161         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
23162         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
23163         return ret_conv;
23164 }
23165
23166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23167         if ((_res & 1) != 0) return;
23168         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23169         CHECK_ACCESS(_res_ptr);
23170         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
23171         FREE((void*)_res);
23172         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
23173 }
23174
23175 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
23176         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23177         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
23178         return (int64_t)ret_conv;
23179 }
23180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23181         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
23182         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
23183         return ret_conv;
23184 }
23185
23186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23187         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
23188         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23189         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
23190         return (int64_t)ret_conv;
23191 }
23192
23193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23194         LDKUpdateFulfillHTLC o_conv;
23195         o_conv.inner = (void*)(o & (~1));
23196         o_conv.is_owned = (o & 1) || (o == 0);
23197         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23198         o_conv = UpdateFulfillHTLC_clone(&o_conv);
23199         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23200         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
23201         return (int64_t)ret_conv;
23202 }
23203
23204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23205         LDKDecodeError e_conv;
23206         e_conv.inner = (void*)(e & (~1));
23207         e_conv.is_owned = (e & 1) || (e == 0);
23208         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23209         e_conv = DecodeError_clone(&e_conv);
23210         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23211         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
23212         return (int64_t)ret_conv;
23213 }
23214
23215 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23216         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
23217         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
23218         return ret_conv;
23219 }
23220
23221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23222         if ((_res & 1) != 0) return;
23223         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23224         CHECK_ACCESS(_res_ptr);
23225         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
23226         FREE((void*)_res);
23227         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
23228 }
23229
23230 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
23231         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23232         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
23233         return (int64_t)ret_conv;
23234 }
23235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23236         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
23237         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
23238         return ret_conv;
23239 }
23240
23241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23242         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
23243         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23244         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
23245         return (int64_t)ret_conv;
23246 }
23247
23248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23249         LDKUpdateAddHTLC o_conv;
23250         o_conv.inner = (void*)(o & (~1));
23251         o_conv.is_owned = (o & 1) || (o == 0);
23252         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23253         o_conv = UpdateAddHTLC_clone(&o_conv);
23254         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23255         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
23256         return (int64_t)ret_conv;
23257 }
23258
23259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23260         LDKDecodeError e_conv;
23261         e_conv.inner = (void*)(e & (~1));
23262         e_conv.is_owned = (e & 1) || (e == 0);
23263         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23264         e_conv = DecodeError_clone(&e_conv);
23265         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23266         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
23267         return (int64_t)ret_conv;
23268 }
23269
23270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23271         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
23272         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
23273         return ret_conv;
23274 }
23275
23276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23277         if ((_res & 1) != 0) return;
23278         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23279         CHECK_ACCESS(_res_ptr);
23280         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
23281         FREE((void*)_res);
23282         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
23283 }
23284
23285 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
23286         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23287         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
23288         return (int64_t)ret_conv;
23289 }
23290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23291         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
23292         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
23293         return ret_conv;
23294 }
23295
23296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23297         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
23298         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23299         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
23300         return (int64_t)ret_conv;
23301 }
23302
23303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23304         LDKPing o_conv;
23305         o_conv.inner = (void*)(o & (~1));
23306         o_conv.is_owned = (o & 1) || (o == 0);
23307         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23308         o_conv = Ping_clone(&o_conv);
23309         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23310         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
23311         return (int64_t)ret_conv;
23312 }
23313
23314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23315         LDKDecodeError e_conv;
23316         e_conv.inner = (void*)(e & (~1));
23317         e_conv.is_owned = (e & 1) || (e == 0);
23318         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23319         e_conv = DecodeError_clone(&e_conv);
23320         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23321         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
23322         return (int64_t)ret_conv;
23323 }
23324
23325 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23326         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
23327         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
23328         return ret_conv;
23329 }
23330
23331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23332         if ((_res & 1) != 0) return;
23333         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23334         CHECK_ACCESS(_res_ptr);
23335         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
23336         FREE((void*)_res);
23337         CResult_PingDecodeErrorZ_free(_res_conv);
23338 }
23339
23340 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
23341         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23342         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
23343         return (int64_t)ret_conv;
23344 }
23345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23346         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
23347         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
23348         return ret_conv;
23349 }
23350
23351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23352         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
23353         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23354         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
23355         return (int64_t)ret_conv;
23356 }
23357
23358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23359         LDKPong o_conv;
23360         o_conv.inner = (void*)(o & (~1));
23361         o_conv.is_owned = (o & 1) || (o == 0);
23362         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23363         o_conv = Pong_clone(&o_conv);
23364         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23365         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
23366         return (int64_t)ret_conv;
23367 }
23368
23369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23370         LDKDecodeError e_conv;
23371         e_conv.inner = (void*)(e & (~1));
23372         e_conv.is_owned = (e & 1) || (e == 0);
23373         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23374         e_conv = DecodeError_clone(&e_conv);
23375         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23376         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
23377         return (int64_t)ret_conv;
23378 }
23379
23380 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23381         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
23382         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
23383         return ret_conv;
23384 }
23385
23386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23387         if ((_res & 1) != 0) return;
23388         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23389         CHECK_ACCESS(_res_ptr);
23390         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
23391         FREE((void*)_res);
23392         CResult_PongDecodeErrorZ_free(_res_conv);
23393 }
23394
23395 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
23396         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23397         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
23398         return (int64_t)ret_conv;
23399 }
23400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23401         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
23402         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
23403         return ret_conv;
23404 }
23405
23406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23407         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
23408         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23409         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
23410         return (int64_t)ret_conv;
23411 }
23412
23413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23414         LDKUnsignedChannelAnnouncement o_conv;
23415         o_conv.inner = (void*)(o & (~1));
23416         o_conv.is_owned = (o & 1) || (o == 0);
23417         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23418         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
23419         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23420         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
23421         return (int64_t)ret_conv;
23422 }
23423
23424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23425         LDKDecodeError e_conv;
23426         e_conv.inner = (void*)(e & (~1));
23427         e_conv.is_owned = (e & 1) || (e == 0);
23428         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23429         e_conv = DecodeError_clone(&e_conv);
23430         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23431         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
23432         return (int64_t)ret_conv;
23433 }
23434
23435 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23436         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
23437         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
23438         return ret_conv;
23439 }
23440
23441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23442         if ((_res & 1) != 0) return;
23443         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23444         CHECK_ACCESS(_res_ptr);
23445         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
23446         FREE((void*)_res);
23447         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
23448 }
23449
23450 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23451         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23452         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
23453         return (int64_t)ret_conv;
23454 }
23455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23456         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
23457         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23458         return ret_conv;
23459 }
23460
23461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23462         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
23463         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23464         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
23465         return (int64_t)ret_conv;
23466 }
23467
23468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23469         LDKChannelAnnouncement o_conv;
23470         o_conv.inner = (void*)(o & (~1));
23471         o_conv.is_owned = (o & 1) || (o == 0);
23472         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23473         o_conv = ChannelAnnouncement_clone(&o_conv);
23474         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23475         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
23476         return (int64_t)ret_conv;
23477 }
23478
23479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23480         LDKDecodeError e_conv;
23481         e_conv.inner = (void*)(e & (~1));
23482         e_conv.is_owned = (e & 1) || (e == 0);
23483         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23484         e_conv = DecodeError_clone(&e_conv);
23485         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23486         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
23487         return (int64_t)ret_conv;
23488 }
23489
23490 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23491         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
23492         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
23493         return ret_conv;
23494 }
23495
23496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23497         if ((_res & 1) != 0) return;
23498         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23499         CHECK_ACCESS(_res_ptr);
23500         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
23501         FREE((void*)_res);
23502         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
23503 }
23504
23505 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23506         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23507         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
23508         return (int64_t)ret_conv;
23509 }
23510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23511         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
23512         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23513         return ret_conv;
23514 }
23515
23516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23517         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
23518         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23519         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
23520         return (int64_t)ret_conv;
23521 }
23522
23523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23524         LDKUnsignedChannelUpdate o_conv;
23525         o_conv.inner = (void*)(o & (~1));
23526         o_conv.is_owned = (o & 1) || (o == 0);
23527         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23528         o_conv = UnsignedChannelUpdate_clone(&o_conv);
23529         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23530         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
23531         return (int64_t)ret_conv;
23532 }
23533
23534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23535         LDKDecodeError e_conv;
23536         e_conv.inner = (void*)(e & (~1));
23537         e_conv.is_owned = (e & 1) || (e == 0);
23538         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23539         e_conv = DecodeError_clone(&e_conv);
23540         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23541         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
23542         return (int64_t)ret_conv;
23543 }
23544
23545 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23546         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
23547         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
23548         return ret_conv;
23549 }
23550
23551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23552         if ((_res & 1) != 0) return;
23553         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23554         CHECK_ACCESS(_res_ptr);
23555         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
23556         FREE((void*)_res);
23557         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
23558 }
23559
23560 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
23561         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23562         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
23563         return (int64_t)ret_conv;
23564 }
23565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23566         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
23567         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
23568         return ret_conv;
23569 }
23570
23571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23572         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
23573         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23574         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
23575         return (int64_t)ret_conv;
23576 }
23577
23578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23579         LDKChannelUpdate o_conv;
23580         o_conv.inner = (void*)(o & (~1));
23581         o_conv.is_owned = (o & 1) || (o == 0);
23582         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23583         o_conv = ChannelUpdate_clone(&o_conv);
23584         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23585         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
23586         return (int64_t)ret_conv;
23587 }
23588
23589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23590         LDKDecodeError e_conv;
23591         e_conv.inner = (void*)(e & (~1));
23592         e_conv.is_owned = (e & 1) || (e == 0);
23593         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23594         e_conv = DecodeError_clone(&e_conv);
23595         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23596         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
23597         return (int64_t)ret_conv;
23598 }
23599
23600 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23601         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
23602         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
23603         return ret_conv;
23604 }
23605
23606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23607         if ((_res & 1) != 0) return;
23608         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23609         CHECK_ACCESS(_res_ptr);
23610         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
23611         FREE((void*)_res);
23612         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
23613 }
23614
23615 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
23616         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23617         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
23618         return (int64_t)ret_conv;
23619 }
23620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23621         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
23622         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
23623         return ret_conv;
23624 }
23625
23626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23627         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
23628         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23629         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
23630         return (int64_t)ret_conv;
23631 }
23632
23633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23634         LDKErrorMessage o_conv;
23635         o_conv.inner = (void*)(o & (~1));
23636         o_conv.is_owned = (o & 1) || (o == 0);
23637         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23638         o_conv = ErrorMessage_clone(&o_conv);
23639         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23640         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
23641         return (int64_t)ret_conv;
23642 }
23643
23644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23645         LDKDecodeError e_conv;
23646         e_conv.inner = (void*)(e & (~1));
23647         e_conv.is_owned = (e & 1) || (e == 0);
23648         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23649         e_conv = DecodeError_clone(&e_conv);
23650         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23651         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
23652         return (int64_t)ret_conv;
23653 }
23654
23655 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23656         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
23657         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
23658         return ret_conv;
23659 }
23660
23661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23662         if ((_res & 1) != 0) return;
23663         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23664         CHECK_ACCESS(_res_ptr);
23665         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
23666         FREE((void*)_res);
23667         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
23668 }
23669
23670 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
23671         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23672         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
23673         return (int64_t)ret_conv;
23674 }
23675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23676         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
23677         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
23678         return ret_conv;
23679 }
23680
23681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23682         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
23683         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23684         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
23685         return (int64_t)ret_conv;
23686 }
23687
23688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23689         LDKWarningMessage o_conv;
23690         o_conv.inner = (void*)(o & (~1));
23691         o_conv.is_owned = (o & 1) || (o == 0);
23692         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23693         o_conv = WarningMessage_clone(&o_conv);
23694         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23695         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
23696         return (int64_t)ret_conv;
23697 }
23698
23699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23700         LDKDecodeError e_conv;
23701         e_conv.inner = (void*)(e & (~1));
23702         e_conv.is_owned = (e & 1) || (e == 0);
23703         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23704         e_conv = DecodeError_clone(&e_conv);
23705         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23706         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
23707         return (int64_t)ret_conv;
23708 }
23709
23710 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23711         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
23712         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
23713         return ret_conv;
23714 }
23715
23716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23717         if ((_res & 1) != 0) return;
23718         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23719         CHECK_ACCESS(_res_ptr);
23720         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
23721         FREE((void*)_res);
23722         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
23723 }
23724
23725 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
23726         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23727         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
23728         return (int64_t)ret_conv;
23729 }
23730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23731         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
23732         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
23733         return ret_conv;
23734 }
23735
23736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23737         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
23738         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23739         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
23740         return (int64_t)ret_conv;
23741 }
23742
23743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23744         LDKUnsignedNodeAnnouncement o_conv;
23745         o_conv.inner = (void*)(o & (~1));
23746         o_conv.is_owned = (o & 1) || (o == 0);
23747         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23748         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
23749         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23750         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
23751         return (int64_t)ret_conv;
23752 }
23753
23754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23755         LDKDecodeError e_conv;
23756         e_conv.inner = (void*)(e & (~1));
23757         e_conv.is_owned = (e & 1) || (e == 0);
23758         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23759         e_conv = DecodeError_clone(&e_conv);
23760         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23761         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
23762         return (int64_t)ret_conv;
23763 }
23764
23765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23766         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
23767         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
23768         return ret_conv;
23769 }
23770
23771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23772         if ((_res & 1) != 0) return;
23773         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23774         CHECK_ACCESS(_res_ptr);
23775         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
23776         FREE((void*)_res);
23777         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
23778 }
23779
23780 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23781         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23782         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
23783         return (int64_t)ret_conv;
23784 }
23785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23786         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
23787         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23788         return ret_conv;
23789 }
23790
23791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23792         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
23793         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23794         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
23795         return (int64_t)ret_conv;
23796 }
23797
23798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23799         LDKNodeAnnouncement o_conv;
23800         o_conv.inner = (void*)(o & (~1));
23801         o_conv.is_owned = (o & 1) || (o == 0);
23802         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23803         o_conv = NodeAnnouncement_clone(&o_conv);
23804         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23805         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
23806         return (int64_t)ret_conv;
23807 }
23808
23809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23810         LDKDecodeError e_conv;
23811         e_conv.inner = (void*)(e & (~1));
23812         e_conv.is_owned = (e & 1) || (e == 0);
23813         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23814         e_conv = DecodeError_clone(&e_conv);
23815         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23816         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
23817         return (int64_t)ret_conv;
23818 }
23819
23820 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23821         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
23822         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
23823         return ret_conv;
23824 }
23825
23826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23827         if ((_res & 1) != 0) return;
23828         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23829         CHECK_ACCESS(_res_ptr);
23830         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
23831         FREE((void*)_res);
23832         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
23833 }
23834
23835 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23836         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23837         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
23838         return (int64_t)ret_conv;
23839 }
23840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23841         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
23842         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23843         return ret_conv;
23844 }
23845
23846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23847         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
23848         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23849         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
23850         return (int64_t)ret_conv;
23851 }
23852
23853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23854         LDKQueryShortChannelIds o_conv;
23855         o_conv.inner = (void*)(o & (~1));
23856         o_conv.is_owned = (o & 1) || (o == 0);
23857         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23858         o_conv = QueryShortChannelIds_clone(&o_conv);
23859         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23860         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
23861         return (int64_t)ret_conv;
23862 }
23863
23864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23865         LDKDecodeError e_conv;
23866         e_conv.inner = (void*)(e & (~1));
23867         e_conv.is_owned = (e & 1) || (e == 0);
23868         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23869         e_conv = DecodeError_clone(&e_conv);
23870         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23871         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
23872         return (int64_t)ret_conv;
23873 }
23874
23875 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23876         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
23877         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
23878         return ret_conv;
23879 }
23880
23881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23882         if ((_res & 1) != 0) return;
23883         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23884         CHECK_ACCESS(_res_ptr);
23885         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
23886         FREE((void*)_res);
23887         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
23888 }
23889
23890 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
23891         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23892         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
23893         return (int64_t)ret_conv;
23894 }
23895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23896         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
23897         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
23898         return ret_conv;
23899 }
23900
23901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23902         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
23903         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23904         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
23905         return (int64_t)ret_conv;
23906 }
23907
23908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23909         LDKReplyShortChannelIdsEnd o_conv;
23910         o_conv.inner = (void*)(o & (~1));
23911         o_conv.is_owned = (o & 1) || (o == 0);
23912         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23913         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
23914         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23915         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
23916         return (int64_t)ret_conv;
23917 }
23918
23919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23920         LDKDecodeError e_conv;
23921         e_conv.inner = (void*)(e & (~1));
23922         e_conv.is_owned = (e & 1) || (e == 0);
23923         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23924         e_conv = DecodeError_clone(&e_conv);
23925         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23926         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
23927         return (int64_t)ret_conv;
23928 }
23929
23930 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23931         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
23932         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
23933         return ret_conv;
23934 }
23935
23936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23937         if ((_res & 1) != 0) return;
23938         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23939         CHECK_ACCESS(_res_ptr);
23940         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
23941         FREE((void*)_res);
23942         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
23943 }
23944
23945 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
23946         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23947         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
23948         return (int64_t)ret_conv;
23949 }
23950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23951         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
23952         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
23953         return ret_conv;
23954 }
23955
23956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23957         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
23958         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23959         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
23960         return (int64_t)ret_conv;
23961 }
23962
23963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23964         LDKQueryChannelRange o_conv;
23965         o_conv.inner = (void*)(o & (~1));
23966         o_conv.is_owned = (o & 1) || (o == 0);
23967         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23968         o_conv = QueryChannelRange_clone(&o_conv);
23969         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23970         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
23971         return (int64_t)ret_conv;
23972 }
23973
23974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23975         LDKDecodeError e_conv;
23976         e_conv.inner = (void*)(e & (~1));
23977         e_conv.is_owned = (e & 1) || (e == 0);
23978         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23979         e_conv = DecodeError_clone(&e_conv);
23980         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23981         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
23982         return (int64_t)ret_conv;
23983 }
23984
23985 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23986         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
23987         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
23988         return ret_conv;
23989 }
23990
23991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23992         if ((_res & 1) != 0) return;
23993         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23994         CHECK_ACCESS(_res_ptr);
23995         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
23996         FREE((void*)_res);
23997         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
23998 }
23999
24000 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
24001         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24002         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
24003         return (int64_t)ret_conv;
24004 }
24005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24006         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
24007         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
24008         return ret_conv;
24009 }
24010
24011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24012         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
24013         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24014         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
24015         return (int64_t)ret_conv;
24016 }
24017
24018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24019         LDKReplyChannelRange o_conv;
24020         o_conv.inner = (void*)(o & (~1));
24021         o_conv.is_owned = (o & 1) || (o == 0);
24022         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24023         o_conv = ReplyChannelRange_clone(&o_conv);
24024         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24025         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
24026         return (int64_t)ret_conv;
24027 }
24028
24029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24030         LDKDecodeError e_conv;
24031         e_conv.inner = (void*)(e & (~1));
24032         e_conv.is_owned = (e & 1) || (e == 0);
24033         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24034         e_conv = DecodeError_clone(&e_conv);
24035         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24036         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
24037         return (int64_t)ret_conv;
24038 }
24039
24040 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24041         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
24042         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
24043         return ret_conv;
24044 }
24045
24046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24047         if ((_res & 1) != 0) return;
24048         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
24049         CHECK_ACCESS(_res_ptr);
24050         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
24051         FREE((void*)_res);
24052         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
24053 }
24054
24055 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
24056         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24057         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
24058         return (int64_t)ret_conv;
24059 }
24060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24061         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
24062         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
24063         return ret_conv;
24064 }
24065
24066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24067         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
24068         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24069         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
24070         return (int64_t)ret_conv;
24071 }
24072
24073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24074         LDKGossipTimestampFilter o_conv;
24075         o_conv.inner = (void*)(o & (~1));
24076         o_conv.is_owned = (o & 1) || (o == 0);
24077         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24078         o_conv = GossipTimestampFilter_clone(&o_conv);
24079         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24080         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
24081         return (int64_t)ret_conv;
24082 }
24083
24084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24085         LDKDecodeError e_conv;
24086         e_conv.inner = (void*)(e & (~1));
24087         e_conv.is_owned = (e & 1) || (e == 0);
24088         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24089         e_conv = DecodeError_clone(&e_conv);
24090         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24091         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
24092         return (int64_t)ret_conv;
24093 }
24094
24095 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24096         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
24097         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
24098         return ret_conv;
24099 }
24100
24101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24102         if ((_res & 1) != 0) return;
24103         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
24104         CHECK_ACCESS(_res_ptr);
24105         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
24106         FREE((void*)_res);
24107         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
24108 }
24109
24110 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
24111         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24112         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
24113         return (int64_t)ret_conv;
24114 }
24115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24116         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
24117         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
24118         return ret_conv;
24119 }
24120
24121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24122         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
24123         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24124         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
24125         return (int64_t)ret_conv;
24126 }
24127
24128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24129         LDKCVec_PhantomRouteHintsZ _res_constr;
24130         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24131         if (_res_constr.datalen > 0)
24132                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
24133         else
24134                 _res_constr.data = NULL;
24135         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24136         for (size_t t = 0; t < _res_constr.datalen; t++) {
24137                 int64_t _res_conv_19 = _res_vals[t];
24138                 LDKPhantomRouteHints _res_conv_19_conv;
24139                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
24140                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
24141                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
24142                 _res_constr.data[t] = _res_conv_19_conv;
24143         }
24144         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24145         CVec_PhantomRouteHintsZ_free(_res_constr);
24146 }
24147
24148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24149         LDKInvoice o_conv;
24150         o_conv.inner = (void*)(o & (~1));
24151         o_conv.is_owned = (o & 1) || (o == 0);
24152         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24153         o_conv = Invoice_clone(&o_conv);
24154         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
24155         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
24156         return (int64_t)ret_conv;
24157 }
24158
24159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24160         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
24161         CHECK_ACCESS(e_ptr);
24162         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
24163         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
24164         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
24165         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
24166         return (int64_t)ret_conv;
24167 }
24168
24169 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24170         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
24171         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
24172         return ret_conv;
24173 }
24174
24175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24176         if ((_res & 1) != 0) return;
24177         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
24178         CHECK_ACCESS(_res_ptr);
24179         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
24180         FREE((void*)_res);
24181         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
24182 }
24183
24184 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
24185         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
24186         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
24187         return (int64_t)ret_conv;
24188 }
24189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24190         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
24191         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
24192         return ret_conv;
24193 }
24194
24195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24196         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
24197         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
24198         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
24199         return (int64_t)ret_conv;
24200 }
24201
24202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
24203         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
24204         CHECK_ACCESS(o_ptr);
24205         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
24206         if (o_conv.free == LDKFilter_JCalls_free) {
24207                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24208                 LDKFilter_JCalls_cloned(&o_conv);
24209         }
24210         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
24211         *ret_copy = COption_FilterZ_some(o_conv);
24212         int64_t ret_ref = (uintptr_t)ret_copy;
24213         return ret_ref;
24214 }
24215
24216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
24217         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
24218         *ret_copy = COption_FilterZ_none();
24219         int64_t ret_ref = (uintptr_t)ret_copy;
24220         return ret_ref;
24221 }
24222
24223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24224         if ((_res & 1) != 0) return;
24225         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
24226         CHECK_ACCESS(_res_ptr);
24227         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
24228         FREE((void*)_res);
24229         COption_FilterZ_free(_res_conv);
24230 }
24231
24232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24233         LDKLockedChannelMonitor o_conv;
24234         o_conv.inner = (void*)(o & (~1));
24235         o_conv.is_owned = (o & 1) || (o == 0);
24236         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24237         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
24238         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
24239         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
24240         return (int64_t)ret_conv;
24241 }
24242
24243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
24244         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
24245         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
24246         return (int64_t)ret_conv;
24247 }
24248
24249 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24250         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
24251         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
24252         return ret_conv;
24253 }
24254
24255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24256         if ((_res & 1) != 0) return;
24257         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
24258         CHECK_ACCESS(_res_ptr);
24259         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
24260         FREE((void*)_res);
24261         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
24262 }
24263
24264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24265         LDKCVec_OutPointZ _res_constr;
24266         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24267         if (_res_constr.datalen > 0)
24268                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
24269         else
24270                 _res_constr.data = NULL;
24271         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24272         for (size_t k = 0; k < _res_constr.datalen; k++) {
24273                 int64_t _res_conv_10 = _res_vals[k];
24274                 LDKOutPoint _res_conv_10_conv;
24275                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
24276                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
24277                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
24278                 _res_constr.data[k] = _res_conv_10_conv;
24279         }
24280         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24281         CVec_OutPointZ_free(_res_constr);
24282 }
24283
24284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24285         if ((this_ptr & 1) != 0) return;
24286         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24287         CHECK_ACCESS(this_ptr_ptr);
24288         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
24289         FREE((void*)this_ptr);
24290         PaymentPurpose_free(this_ptr_conv);
24291 }
24292
24293 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
24294         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
24295         *ret_copy = PaymentPurpose_clone(arg);
24296 int64_t ret_ref = (uintptr_t)ret_copy;
24297         return ret_ref;
24298 }
24299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24300         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
24301         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
24302         return ret_conv;
24303 }
24304
24305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24306         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
24307         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
24308         *ret_copy = PaymentPurpose_clone(orig_conv);
24309         int64_t ret_ref = (uintptr_t)ret_copy;
24310         return ret_ref;
24311 }
24312
24313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
24314         LDKThirtyTwoBytes payment_preimage_ref;
24315         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
24316         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
24317         LDKThirtyTwoBytes payment_secret_ref;
24318         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
24319         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
24320         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
24321         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
24322         int64_t ret_ref = (uintptr_t)ret_copy;
24323         return ret_ref;
24324 }
24325
24326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
24327         LDKThirtyTwoBytes a_ref;
24328         CHECK((*env)->GetArrayLength(env, a) == 32);
24329         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
24330         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
24331         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
24332         int64_t ret_ref = (uintptr_t)ret_copy;
24333         return ret_ref;
24334 }
24335
24336 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1write(JNIEnv *env, jclass clz, int64_t obj) {
24337         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)obj;
24338         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
24339         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24340         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24341         CVec_u8Z_free(ret_var);
24342         return ret_arr;
24343 }
24344
24345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24346         LDKu8slice ser_ref;
24347         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24348         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24349         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
24350         *ret_conv = PaymentPurpose_read(ser_ref);
24351         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24352         return (int64_t)ret_conv;
24353 }
24354
24355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24356         if ((this_ptr & 1) != 0) return;
24357         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24358         CHECK_ACCESS(this_ptr_ptr);
24359         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
24360         FREE((void*)this_ptr);
24361         ClosureReason_free(this_ptr_conv);
24362 }
24363
24364 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
24365         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24366         *ret_copy = ClosureReason_clone(arg);
24367 int64_t ret_ref = (uintptr_t)ret_copy;
24368         return ret_ref;
24369 }
24370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24371         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
24372         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
24373         return ret_conv;
24374 }
24375
24376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24377         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
24378         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24379         *ret_copy = ClosureReason_clone(orig_conv);
24380         int64_t ret_ref = (uintptr_t)ret_copy;
24381         return ret_ref;
24382 }
24383
24384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
24385         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
24386         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24387         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
24388         int64_t ret_ref = (uintptr_t)ret_copy;
24389         return ret_ref;
24390 }
24391
24392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
24393         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24394         *ret_copy = ClosureReason_holder_force_closed();
24395         int64_t ret_ref = (uintptr_t)ret_copy;
24396         return ret_ref;
24397 }
24398
24399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
24400         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24401         *ret_copy = ClosureReason_cooperative_closure();
24402         int64_t ret_ref = (uintptr_t)ret_copy;
24403         return ret_ref;
24404 }
24405
24406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
24407         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24408         *ret_copy = ClosureReason_commitment_tx_confirmed();
24409         int64_t ret_ref = (uintptr_t)ret_copy;
24410         return ret_ref;
24411 }
24412
24413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
24414         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24415         *ret_copy = ClosureReason_funding_timed_out();
24416         int64_t ret_ref = (uintptr_t)ret_copy;
24417         return ret_ref;
24418 }
24419
24420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
24421         LDKStr err_conv = java_to_owned_str(env, err);
24422         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24423         *ret_copy = ClosureReason_processing_error(err_conv);
24424         int64_t ret_ref = (uintptr_t)ret_copy;
24425         return ret_ref;
24426 }
24427
24428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
24429         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24430         *ret_copy = ClosureReason_disconnected_peer();
24431         int64_t ret_ref = (uintptr_t)ret_copy;
24432         return ret_ref;
24433 }
24434
24435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
24436         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24437         *ret_copy = ClosureReason_outdated_channel_manager();
24438         int64_t ret_ref = (uintptr_t)ret_copy;
24439         return ret_ref;
24440 }
24441
24442 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
24443         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
24444         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
24445         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24446         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24447         CVec_u8Z_free(ret_var);
24448         return ret_arr;
24449 }
24450
24451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24452         LDKu8slice ser_ref;
24453         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24454         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24455         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
24456         *ret_conv = ClosureReason_read(ser_ref);
24457         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24458         return (int64_t)ret_conv;
24459 }
24460
24461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24462         if ((this_ptr & 1) != 0) return;
24463         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24464         CHECK_ACCESS(this_ptr_ptr);
24465         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
24466         FREE((void*)this_ptr);
24467         HTLCDestination_free(this_ptr_conv);
24468 }
24469
24470 static inline uintptr_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
24471         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
24472         *ret_copy = HTLCDestination_clone(arg);
24473 int64_t ret_ref = (uintptr_t)ret_copy;
24474         return ret_ref;
24475 }
24476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24477         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)arg;
24478         int64_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
24479         return ret_conv;
24480 }
24481
24482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24483         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)orig;
24484         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
24485         *ret_copy = HTLCDestination_clone(orig_conv);
24486         int64_t ret_ref = (uintptr_t)ret_copy;
24487         return ret_ref;
24488 }
24489
24490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1next_1hop_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int8_tArray channel_id) {
24491         LDKPublicKey node_id_ref;
24492         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24493         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24494         LDKThirtyTwoBytes channel_id_ref;
24495         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24496         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
24497         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
24498         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
24499         int64_t ret_ref = (uintptr_t)ret_copy;
24500         return ret_ref;
24501 }
24502
24503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1unknown_1next_1hop(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
24504         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
24505         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
24506         int64_t ret_ref = (uintptr_t)ret_copy;
24507         return ret_ref;
24508 }
24509
24510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1failed_1payment(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
24511         LDKThirtyTwoBytes payment_hash_ref;
24512         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24513         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24514         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
24515         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
24516         int64_t ret_ref = (uintptr_t)ret_copy;
24517         return ret_ref;
24518 }
24519
24520 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1write(JNIEnv *env, jclass clz, int64_t obj) {
24521         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)obj;
24522         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
24523         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24524         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24525         CVec_u8Z_free(ret_var);
24526         return ret_arr;
24527 }
24528
24529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24530         LDKu8slice ser_ref;
24531         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24532         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24533         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
24534         *ret_conv = HTLCDestination_read(ser_ref);
24535         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24536         return (int64_t)ret_conv;
24537 }
24538
24539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24540         if ((this_ptr & 1) != 0) return;
24541         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24542         CHECK_ACCESS(this_ptr_ptr);
24543         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
24544         FREE((void*)this_ptr);
24545         Event_free(this_ptr_conv);
24546 }
24547
24548 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
24549         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24550         *ret_copy = Event_clone(arg);
24551 int64_t ret_ref = (uintptr_t)ret_copy;
24552         return ret_ref;
24553 }
24554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24555         LDKEvent* arg_conv = (LDKEvent*)arg;
24556         int64_t ret_conv = Event_clone_ptr(arg_conv);
24557         return ret_conv;
24558 }
24559
24560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24561         LDKEvent* orig_conv = (LDKEvent*)orig;
24562         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24563         *ret_copy = Event_clone(orig_conv);
24564         int64_t ret_ref = (uintptr_t)ret_copy;
24565         return ret_ref;
24566 }
24567
24568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1funding_1generation_1ready(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
24569         LDKThirtyTwoBytes temporary_channel_id_ref;
24570         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
24571         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
24572         LDKPublicKey counterparty_node_id_ref;
24573         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
24574         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
24575         LDKCVec_u8Z output_script_ref;
24576         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
24577         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
24578         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
24579         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24580         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
24581         int64_t ret_ref = (uintptr_t)ret_copy;
24582         return ret_ref;
24583 }
24584
24585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amount_msat, int64_t purpose) {
24586         LDKThirtyTwoBytes payment_hash_ref;
24587         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24588         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24589         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
24590         CHECK_ACCESS(purpose_ptr);
24591         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
24592         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
24593         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24594         *ret_copy = Event_payment_received(payment_hash_ref, amount_msat, purpose_conv);
24595         int64_t ret_ref = (uintptr_t)ret_copy;
24596         return ret_ref;
24597 }
24598
24599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1claimed(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amount_msat, int64_t purpose) {
24600         LDKThirtyTwoBytes payment_hash_ref;
24601         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24602         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24603         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
24604         CHECK_ACCESS(purpose_ptr);
24605         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
24606         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
24607         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24608         *ret_copy = Event_payment_claimed(payment_hash_ref, amount_msat, purpose_conv);
24609         int64_t ret_ref = (uintptr_t)ret_copy;
24610         return ret_ref;
24611 }
24612
24613 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) {
24614         LDKThirtyTwoBytes payment_id_ref;
24615         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24616         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24617         LDKThirtyTwoBytes payment_preimage_ref;
24618         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
24619         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
24620         LDKThirtyTwoBytes payment_hash_ref;
24621         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24622         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24623         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
24624         CHECK_ACCESS(fee_paid_msat_ptr);
24625         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
24626         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
24627         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24628         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
24629         int64_t ret_ref = (uintptr_t)ret_copy;
24630         return ret_ref;
24631 }
24632
24633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
24634         LDKThirtyTwoBytes payment_id_ref;
24635         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24636         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24637         LDKThirtyTwoBytes payment_hash_ref;
24638         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24639         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24640         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24641         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
24642         int64_t ret_ref = (uintptr_t)ret_copy;
24643         return ret_ref;
24644 }
24645
24646 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) {
24647         LDKThirtyTwoBytes payment_id_ref;
24648         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24649         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24650         LDKThirtyTwoBytes payment_hash_ref;
24651         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24652         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24653         LDKCVec_RouteHopZ path_constr;
24654         path_constr.datalen = (*env)->GetArrayLength(env, path);
24655         if (path_constr.datalen > 0)
24656                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24657         else
24658                 path_constr.data = NULL;
24659         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
24660         for (size_t k = 0; k < path_constr.datalen; k++) {
24661                 int64_t path_conv_10 = path_vals[k];
24662                 LDKRouteHop path_conv_10_conv;
24663                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
24664                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
24665                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
24666                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
24667                 path_constr.data[k] = path_conv_10_conv;
24668         }
24669         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
24670         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24671         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
24672         int64_t ret_ref = (uintptr_t)ret_copy;
24673         return ret_ref;
24674 }
24675
24676 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) {
24677         LDKThirtyTwoBytes payment_id_ref;
24678         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24679         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24680         LDKThirtyTwoBytes payment_hash_ref;
24681         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24682         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24683         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
24684         CHECK_ACCESS(network_update_ptr);
24685         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
24686         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
24687         LDKCVec_RouteHopZ path_constr;
24688         path_constr.datalen = (*env)->GetArrayLength(env, path);
24689         if (path_constr.datalen > 0)
24690                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24691         else
24692                 path_constr.data = NULL;
24693         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
24694         for (size_t k = 0; k < path_constr.datalen; k++) {
24695                 int64_t path_conv_10 = path_vals[k];
24696                 LDKRouteHop path_conv_10_conv;
24697                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
24698                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
24699                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
24700                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
24701                 path_constr.data[k] = path_conv_10_conv;
24702         }
24703         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
24704         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
24705         CHECK_ACCESS(short_channel_id_ptr);
24706         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
24707         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
24708         LDKRouteParameters retry_conv;
24709         retry_conv.inner = (void*)(retry & (~1));
24710         retry_conv.is_owned = (retry & 1) || (retry == 0);
24711         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
24712         retry_conv = RouteParameters_clone(&retry_conv);
24713         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24714         *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);
24715         int64_t ret_ref = (uintptr_t)ret_copy;
24716         return ret_ref;
24717 }
24718
24719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1probe_1successful(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_tArray path) {
24720         LDKThirtyTwoBytes payment_id_ref;
24721         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24722         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24723         LDKThirtyTwoBytes payment_hash_ref;
24724         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24725         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24726         LDKCVec_RouteHopZ path_constr;
24727         path_constr.datalen = (*env)->GetArrayLength(env, path);
24728         if (path_constr.datalen > 0)
24729                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24730         else
24731                 path_constr.data = NULL;
24732         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
24733         for (size_t k = 0; k < path_constr.datalen; k++) {
24734                 int64_t path_conv_10 = path_vals[k];
24735                 LDKRouteHop path_conv_10_conv;
24736                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
24737                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
24738                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
24739                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
24740                 path_constr.data[k] = path_conv_10_conv;
24741         }
24742         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
24743         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24744         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_constr);
24745         int64_t ret_ref = (uintptr_t)ret_copy;
24746         return ret_ref;
24747 }
24748
24749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1probe_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_tArray path, int64_t short_channel_id) {
24750         LDKThirtyTwoBytes payment_id_ref;
24751         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24752         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24753         LDKThirtyTwoBytes payment_hash_ref;
24754         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24755         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24756         LDKCVec_RouteHopZ path_constr;
24757         path_constr.datalen = (*env)->GetArrayLength(env, path);
24758         if (path_constr.datalen > 0)
24759                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24760         else
24761                 path_constr.data = NULL;
24762         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
24763         for (size_t k = 0; k < path_constr.datalen; k++) {
24764                 int64_t path_conv_10 = path_vals[k];
24765                 LDKRouteHop path_conv_10_conv;
24766                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
24767                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
24768                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
24769                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
24770                 path_constr.data[k] = path_conv_10_conv;
24771         }
24772         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
24773         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
24774         CHECK_ACCESS(short_channel_id_ptr);
24775         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
24776         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
24777         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24778         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_constr, short_channel_id_conv);
24779         int64_t ret_ref = (uintptr_t)ret_copy;
24780         return ret_ref;
24781 }
24782
24783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
24784         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24785         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
24786         int64_t ret_ref = (uintptr_t)ret_copy;
24787         return ret_ref;
24788 }
24789
24790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
24791         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
24792         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
24793         if (outputs_constr.datalen > 0)
24794                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
24795         else
24796                 outputs_constr.data = NULL;
24797         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
24798         for (size_t b = 0; b < outputs_constr.datalen; b++) {
24799                 int64_t outputs_conv_27 = outputs_vals[b];
24800                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
24801                 CHECK_ACCESS(outputs_conv_27_ptr);
24802                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
24803                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
24804                 outputs_constr.data[b] = outputs_conv_27_conv;
24805         }
24806         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
24807         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24808         *ret_copy = Event_spendable_outputs(outputs_constr);
24809         int64_t ret_ref = (uintptr_t)ret_copy;
24810         return ret_ref;
24811 }
24812
24813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int8_tArray prev_channel_id, int8_tArray next_channel_id, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) {
24814         LDKThirtyTwoBytes prev_channel_id_ref;
24815         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
24816         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
24817         LDKThirtyTwoBytes next_channel_id_ref;
24818         CHECK((*env)->GetArrayLength(env, next_channel_id) == 32);
24819         (*env)->GetByteArrayRegion(env, next_channel_id, 0, 32, next_channel_id_ref.data);
24820         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
24821         CHECK_ACCESS(fee_earned_msat_ptr);
24822         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
24823         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
24824         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24825         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
24826         int64_t ret_ref = (uintptr_t)ret_copy;
24827         return ret_ref;
24828 }
24829
24830 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) {
24831         LDKThirtyTwoBytes channel_id_ref;
24832         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24833         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
24834         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
24835         CHECK_ACCESS(reason_ptr);
24836         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
24837         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
24838         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24839         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
24840         int64_t ret_ref = (uintptr_t)ret_copy;
24841         return ret_ref;
24842 }
24843
24844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
24845         LDKThirtyTwoBytes channel_id_ref;
24846         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24847         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
24848         LDKTransaction transaction_ref;
24849         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
24850         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
24851         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
24852         transaction_ref.data_is_owned = true;
24853         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24854         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
24855         int64_t ret_ref = (uintptr_t)ret_copy;
24856         return ret_ref;
24857 }
24858
24859 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) {
24860         LDKThirtyTwoBytes temporary_channel_id_ref;
24861         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
24862         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
24863         LDKPublicKey counterparty_node_id_ref;
24864         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
24865         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
24866         LDKChannelTypeFeatures channel_type_conv;
24867         channel_type_conv.inner = (void*)(channel_type & (~1));
24868         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
24869         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
24870         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
24871         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24872         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
24873         int64_t ret_ref = (uintptr_t)ret_copy;
24874         return ret_ref;
24875 }
24876
24877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1htlchandling_1failed(JNIEnv *env, jclass clz, int8_tArray prev_channel_id, int64_t failed_next_destination) {
24878         LDKThirtyTwoBytes prev_channel_id_ref;
24879         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
24880         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
24881         void* failed_next_destination_ptr = (void*)(((uintptr_t)failed_next_destination) & ~1);
24882         CHECK_ACCESS(failed_next_destination_ptr);
24883         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
24884         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)(((uintptr_t)failed_next_destination) & ~1));
24885         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24886         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
24887         int64_t ret_ref = (uintptr_t)ret_copy;
24888         return ret_ref;
24889 }
24890
24891 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
24892         LDKEvent* obj_conv = (LDKEvent*)obj;
24893         LDKCVec_u8Z ret_var = Event_write(obj_conv);
24894         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24895         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24896         CVec_u8Z_free(ret_var);
24897         return ret_arr;
24898 }
24899
24900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24901         LDKu8slice ser_ref;
24902         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24903         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24904         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
24905         *ret_conv = Event_read(ser_ref);
24906         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24907         return (int64_t)ret_conv;
24908 }
24909
24910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24911         if ((this_ptr & 1) != 0) return;
24912         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24913         CHECK_ACCESS(this_ptr_ptr);
24914         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
24915         FREE((void*)this_ptr);
24916         MessageSendEvent_free(this_ptr_conv);
24917 }
24918
24919 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
24920         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24921         *ret_copy = MessageSendEvent_clone(arg);
24922 int64_t ret_ref = (uintptr_t)ret_copy;
24923         return ret_ref;
24924 }
24925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24926         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
24927         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
24928         return ret_conv;
24929 }
24930
24931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24932         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
24933         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24934         *ret_copy = MessageSendEvent_clone(orig_conv);
24935         int64_t ret_ref = (uintptr_t)ret_copy;
24936         return ret_ref;
24937 }
24938
24939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24940         LDKPublicKey node_id_ref;
24941         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24942         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24943         LDKAcceptChannel msg_conv;
24944         msg_conv.inner = (void*)(msg & (~1));
24945         msg_conv.is_owned = (msg & 1) || (msg == 0);
24946         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24947         msg_conv = AcceptChannel_clone(&msg_conv);
24948         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24949         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
24950         int64_t ret_ref = (uintptr_t)ret_copy;
24951         return ret_ref;
24952 }
24953
24954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24955         LDKPublicKey node_id_ref;
24956         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24957         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24958         LDKOpenChannel msg_conv;
24959         msg_conv.inner = (void*)(msg & (~1));
24960         msg_conv.is_owned = (msg & 1) || (msg == 0);
24961         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24962         msg_conv = OpenChannel_clone(&msg_conv);
24963         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24964         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
24965         int64_t ret_ref = (uintptr_t)ret_copy;
24966         return ret_ref;
24967 }
24968
24969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24970         LDKPublicKey node_id_ref;
24971         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24972         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24973         LDKFundingCreated msg_conv;
24974         msg_conv.inner = (void*)(msg & (~1));
24975         msg_conv.is_owned = (msg & 1) || (msg == 0);
24976         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24977         msg_conv = FundingCreated_clone(&msg_conv);
24978         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24979         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
24980         int64_t ret_ref = (uintptr_t)ret_copy;
24981         return ret_ref;
24982 }
24983
24984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24985         LDKPublicKey node_id_ref;
24986         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24987         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24988         LDKFundingSigned msg_conv;
24989         msg_conv.inner = (void*)(msg & (~1));
24990         msg_conv.is_owned = (msg & 1) || (msg == 0);
24991         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24992         msg_conv = FundingSigned_clone(&msg_conv);
24993         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24994         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
24995         int64_t ret_ref = (uintptr_t)ret_copy;
24996         return ret_ref;
24997 }
24998
24999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25000         LDKPublicKey node_id_ref;
25001         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25002         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25003         LDKChannelReady msg_conv;
25004         msg_conv.inner = (void*)(msg & (~1));
25005         msg_conv.is_owned = (msg & 1) || (msg == 0);
25006         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25007         msg_conv = ChannelReady_clone(&msg_conv);
25008         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25009         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
25010         int64_t ret_ref = (uintptr_t)ret_copy;
25011         return ret_ref;
25012 }
25013
25014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25015         LDKPublicKey node_id_ref;
25016         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25017         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25018         LDKAnnouncementSignatures msg_conv;
25019         msg_conv.inner = (void*)(msg & (~1));
25020         msg_conv.is_owned = (msg & 1) || (msg == 0);
25021         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25022         msg_conv = AnnouncementSignatures_clone(&msg_conv);
25023         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25024         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
25025         int64_t ret_ref = (uintptr_t)ret_copy;
25026         return ret_ref;
25027 }
25028
25029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
25030         LDKPublicKey node_id_ref;
25031         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25032         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25033         LDKCommitmentUpdate updates_conv;
25034         updates_conv.inner = (void*)(updates & (~1));
25035         updates_conv.is_owned = (updates & 1) || (updates == 0);
25036         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
25037         updates_conv = CommitmentUpdate_clone(&updates_conv);
25038         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25039         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
25040         int64_t ret_ref = (uintptr_t)ret_copy;
25041         return ret_ref;
25042 }
25043
25044 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) {
25045         LDKPublicKey node_id_ref;
25046         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25047         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25048         LDKRevokeAndACK msg_conv;
25049         msg_conv.inner = (void*)(msg & (~1));
25050         msg_conv.is_owned = (msg & 1) || (msg == 0);
25051         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25052         msg_conv = RevokeAndACK_clone(&msg_conv);
25053         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25054         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
25055         int64_t ret_ref = (uintptr_t)ret_copy;
25056         return ret_ref;
25057 }
25058
25059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25060         LDKPublicKey node_id_ref;
25061         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25062         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25063         LDKClosingSigned msg_conv;
25064         msg_conv.inner = (void*)(msg & (~1));
25065         msg_conv.is_owned = (msg & 1) || (msg == 0);
25066         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25067         msg_conv = ClosingSigned_clone(&msg_conv);
25068         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25069         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
25070         int64_t ret_ref = (uintptr_t)ret_copy;
25071         return ret_ref;
25072 }
25073
25074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25075         LDKPublicKey node_id_ref;
25076         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25077         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25078         LDKShutdown msg_conv;
25079         msg_conv.inner = (void*)(msg & (~1));
25080         msg_conv.is_owned = (msg & 1) || (msg == 0);
25081         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25082         msg_conv = Shutdown_clone(&msg_conv);
25083         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25084         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
25085         int64_t ret_ref = (uintptr_t)ret_copy;
25086         return ret_ref;
25087 }
25088
25089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25090         LDKPublicKey node_id_ref;
25091         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25092         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25093         LDKChannelReestablish msg_conv;
25094         msg_conv.inner = (void*)(msg & (~1));
25095         msg_conv.is_owned = (msg & 1) || (msg == 0);
25096         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25097         msg_conv = ChannelReestablish_clone(&msg_conv);
25098         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25099         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
25100         int64_t ret_ref = (uintptr_t)ret_copy;
25101         return ret_ref;
25102 }
25103
25104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
25105         LDKChannelAnnouncement msg_conv;
25106         msg_conv.inner = (void*)(msg & (~1));
25107         msg_conv.is_owned = (msg & 1) || (msg == 0);
25108         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25109         msg_conv = ChannelAnnouncement_clone(&msg_conv);
25110         LDKChannelUpdate update_msg_conv;
25111         update_msg_conv.inner = (void*)(update_msg & (~1));
25112         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
25113         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
25114         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
25115         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25116         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
25117         int64_t ret_ref = (uintptr_t)ret_copy;
25118         return ret_ref;
25119 }
25120
25121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
25122         LDKNodeAnnouncement msg_conv;
25123         msg_conv.inner = (void*)(msg & (~1));
25124         msg_conv.is_owned = (msg & 1) || (msg == 0);
25125         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25126         msg_conv = NodeAnnouncement_clone(&msg_conv);
25127         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25128         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
25129         int64_t ret_ref = (uintptr_t)ret_copy;
25130         return ret_ref;
25131 }
25132
25133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
25134         LDKChannelUpdate msg_conv;
25135         msg_conv.inner = (void*)(msg & (~1));
25136         msg_conv.is_owned = (msg & 1) || (msg == 0);
25137         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25138         msg_conv = ChannelUpdate_clone(&msg_conv);
25139         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25140         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
25141         int64_t ret_ref = (uintptr_t)ret_copy;
25142         return ret_ref;
25143 }
25144
25145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25146         LDKPublicKey node_id_ref;
25147         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25148         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25149         LDKChannelUpdate msg_conv;
25150         msg_conv.inner = (void*)(msg & (~1));
25151         msg_conv.is_owned = (msg & 1) || (msg == 0);
25152         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25153         msg_conv = ChannelUpdate_clone(&msg_conv);
25154         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25155         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
25156         int64_t ret_ref = (uintptr_t)ret_copy;
25157         return ret_ref;
25158 }
25159
25160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
25161         LDKPublicKey node_id_ref;
25162         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25163         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25164         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
25165         CHECK_ACCESS(action_ptr);
25166         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
25167         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
25168         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25169         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
25170         int64_t ret_ref = (uintptr_t)ret_copy;
25171         return ret_ref;
25172 }
25173
25174 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) {
25175         LDKPublicKey node_id_ref;
25176         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25177         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25178         LDKQueryChannelRange msg_conv;
25179         msg_conv.inner = (void*)(msg & (~1));
25180         msg_conv.is_owned = (msg & 1) || (msg == 0);
25181         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25182         msg_conv = QueryChannelRange_clone(&msg_conv);
25183         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25184         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
25185         int64_t ret_ref = (uintptr_t)ret_copy;
25186         return ret_ref;
25187 }
25188
25189 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) {
25190         LDKPublicKey node_id_ref;
25191         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25192         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25193         LDKQueryShortChannelIds msg_conv;
25194         msg_conv.inner = (void*)(msg & (~1));
25195         msg_conv.is_owned = (msg & 1) || (msg == 0);
25196         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25197         msg_conv = QueryShortChannelIds_clone(&msg_conv);
25198         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25199         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
25200         int64_t ret_ref = (uintptr_t)ret_copy;
25201         return ret_ref;
25202 }
25203
25204 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) {
25205         LDKPublicKey node_id_ref;
25206         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25207         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25208         LDKReplyChannelRange msg_conv;
25209         msg_conv.inner = (void*)(msg & (~1));
25210         msg_conv.is_owned = (msg & 1) || (msg == 0);
25211         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25212         msg_conv = ReplyChannelRange_clone(&msg_conv);
25213         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25214         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
25215         int64_t ret_ref = (uintptr_t)ret_copy;
25216         return ret_ref;
25217 }
25218
25219 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) {
25220         LDKPublicKey node_id_ref;
25221         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25222         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25223         LDKGossipTimestampFilter msg_conv;
25224         msg_conv.inner = (void*)(msg & (~1));
25225         msg_conv.is_owned = (msg & 1) || (msg == 0);
25226         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25227         msg_conv = GossipTimestampFilter_clone(&msg_conv);
25228         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25229         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
25230         int64_t ret_ref = (uintptr_t)ret_copy;
25231         return ret_ref;
25232 }
25233
25234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25235         if ((this_ptr & 1) != 0) return;
25236         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25237         CHECK_ACCESS(this_ptr_ptr);
25238         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
25239         FREE((void*)this_ptr);
25240         MessageSendEventsProvider_free(this_ptr_conv);
25241 }
25242
25243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25244         if ((this_ptr & 1) != 0) return;
25245         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25246         CHECK_ACCESS(this_ptr_ptr);
25247         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
25248         FREE((void*)this_ptr);
25249         EventsProvider_free(this_ptr_conv);
25250 }
25251
25252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25253         if ((this_ptr & 1) != 0) return;
25254         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25255         CHECK_ACCESS(this_ptr_ptr);
25256         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
25257         FREE((void*)this_ptr);
25258         EventHandler_free(this_ptr_conv);
25259 }
25260
25261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25262         if ((this_ptr & 1) != 0) return;
25263         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25264         CHECK_ACCESS(this_ptr_ptr);
25265         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
25266         FREE((void*)this_ptr);
25267         APIError_free(this_ptr_conv);
25268 }
25269
25270 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
25271         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25272         *ret_copy = APIError_clone(arg);
25273 int64_t ret_ref = (uintptr_t)ret_copy;
25274         return ret_ref;
25275 }
25276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25277         LDKAPIError* arg_conv = (LDKAPIError*)arg;
25278         int64_t ret_conv = APIError_clone_ptr(arg_conv);
25279         return ret_conv;
25280 }
25281
25282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25283         LDKAPIError* orig_conv = (LDKAPIError*)orig;
25284         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25285         *ret_copy = APIError_clone(orig_conv);
25286         int64_t ret_ref = (uintptr_t)ret_copy;
25287         return ret_ref;
25288 }
25289
25290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
25291         LDKStr err_conv = java_to_owned_str(env, err);
25292         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25293         *ret_copy = APIError_apimisuse_error(err_conv);
25294         int64_t ret_ref = (uintptr_t)ret_copy;
25295         return ret_ref;
25296 }
25297
25298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
25299         LDKStr err_conv = java_to_owned_str(env, err);
25300         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25301         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
25302         int64_t ret_ref = (uintptr_t)ret_copy;
25303         return ret_ref;
25304 }
25305
25306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
25307         LDKStr err_conv = java_to_owned_str(env, err);
25308         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25309         *ret_copy = APIError_route_error(err_conv);
25310         int64_t ret_ref = (uintptr_t)ret_copy;
25311         return ret_ref;
25312 }
25313
25314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
25315         LDKStr err_conv = java_to_owned_str(env, err);
25316         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25317         *ret_copy = APIError_channel_unavailable(err_conv);
25318         int64_t ret_ref = (uintptr_t)ret_copy;
25319         return ret_ref;
25320 }
25321
25322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
25323         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25324         *ret_copy = APIError_monitor_update_failed();
25325         int64_t ret_ref = (uintptr_t)ret_copy;
25326         return ret_ref;
25327 }
25328
25329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
25330         LDKShutdownScript script_conv;
25331         script_conv.inner = (void*)(script & (~1));
25332         script_conv.is_owned = (script & 1) || (script == 0);
25333         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
25334         script_conv = ShutdownScript_clone(&script_conv);
25335         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25336         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
25337         int64_t ret_ref = (uintptr_t)ret_copy;
25338         return ret_ref;
25339 }
25340
25341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25342         LDKBigSize this_obj_conv;
25343         this_obj_conv.inner = (void*)(this_obj & (~1));
25344         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25346         BigSize_free(this_obj_conv);
25347 }
25348
25349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
25350         LDKBigSize this_ptr_conv;
25351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25352         this_ptr_conv.is_owned = false;
25353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25354         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
25355         return ret_conv;
25356 }
25357
25358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25359         LDKBigSize this_ptr_conv;
25360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25361         this_ptr_conv.is_owned = false;
25362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25363         BigSize_set_a(&this_ptr_conv, val);
25364 }
25365
25366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
25367         LDKBigSize ret_var = BigSize_new(a_arg);
25368         int64_t ret_ref = 0;
25369         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25370         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25372         ret_ref = (uintptr_t)ret_var.inner;
25373         if (ret_var.is_owned) {
25374                 ret_ref |= 1;
25375         }
25376         return ret_ref;
25377 }
25378
25379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Hostname_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25380         LDKHostname this_obj_conv;
25381         this_obj_conv.inner = (void*)(this_obj & (~1));
25382         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25384         Hostname_free(this_obj_conv);
25385 }
25386
25387 static inline uintptr_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
25388         LDKHostname ret_var = Hostname_clone(arg);
25389 int64_t ret_ref = 0;
25390 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25391 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25392 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25393 ret_ref = (uintptr_t)ret_var.inner;
25394 if (ret_var.is_owned) {
25395         ret_ref |= 1;
25396 }
25397         return ret_ref;
25398 }
25399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25400         LDKHostname arg_conv;
25401         arg_conv.inner = (void*)(arg & (~1));
25402         arg_conv.is_owned = false;
25403         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25404         int64_t ret_conv = Hostname_clone_ptr(&arg_conv);
25405         return ret_conv;
25406 }
25407
25408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25409         LDKHostname orig_conv;
25410         orig_conv.inner = (void*)(orig & (~1));
25411         orig_conv.is_owned = false;
25412         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25413         LDKHostname ret_var = Hostname_clone(&orig_conv);
25414         int64_t ret_ref = 0;
25415         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25416         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25418         ret_ref = (uintptr_t)ret_var.inner;
25419         if (ret_var.is_owned) {
25420                 ret_ref |= 1;
25421         }
25422         return ret_ref;
25423 }
25424
25425 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_Hostname_1len(JNIEnv *env, jclass clz, int64_t this_arg) {
25426         LDKHostname this_arg_conv;
25427         this_arg_conv.inner = (void*)(this_arg & (~1));
25428         this_arg_conv.is_owned = false;
25429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25430         int8_t ret_conv = Hostname_len(&this_arg_conv);
25431         return ret_conv;
25432 }
25433
25434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
25435         LDKu8slice msg_ref;
25436         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
25437         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
25438         unsigned char sk_arr[32];
25439         CHECK((*env)->GetArrayLength(env, sk) == 32);
25440         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
25441         unsigned char (*sk_ref)[32] = &sk_arr;
25442         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
25443         *ret_conv = sign(msg_ref, sk_ref);
25444         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
25445         return (int64_t)ret_conv;
25446 }
25447
25448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
25449         LDKu8slice msg_ref;
25450         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
25451         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
25452         LDKStr sig_conv = java_to_owned_str(env, sig);
25453         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
25454         *ret_conv = recover_pk(msg_ref, sig_conv);
25455         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
25456         return (int64_t)ret_conv;
25457 }
25458
25459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
25460         LDKu8slice msg_ref;
25461         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
25462         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
25463         LDKStr sig_conv = java_to_owned_str(env, sig);
25464         LDKPublicKey pk_ref;
25465         CHECK((*env)->GetArrayLength(env, pk) == 33);
25466         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
25467         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
25468         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
25469         return ret_conv;
25470 }
25471
25472 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
25473         LDKu8slice hrp_bytes_ref;
25474         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
25475         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
25476         LDKCVec_u5Z data_without_signature_constr;
25477         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
25478         if (data_without_signature_constr.datalen > 0)
25479                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
25480         else
25481                 data_without_signature_constr.data = NULL;
25482         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
25483         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
25484                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
25485                 
25486                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
25487         }
25488         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
25489         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
25490         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25491         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25492         CVec_u8Z_free(ret_var);
25493         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
25494         return ret_arr;
25495 }
25496
25497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25498         if ((this_ptr & 1) != 0) return;
25499         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25500         CHECK_ACCESS(this_ptr_ptr);
25501         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
25502         FREE((void*)this_ptr);
25503         Persister_free(this_ptr_conv);
25504 }
25505
25506 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25507         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
25508         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
25509         return ret_conv;
25510 }
25511
25512 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
25513         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
25514         return ret_conv;
25515 }
25516
25517 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
25518         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
25519         return ret_conv;
25520 }
25521
25522 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
25523         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
25524         return ret_conv;
25525 }
25526
25527 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
25528         jclass ret_conv = LDKLevel_to_java(env, Level_info());
25529         return ret_conv;
25530 }
25531
25532 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
25533         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
25534         return ret_conv;
25535 }
25536
25537 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
25538         jclass ret_conv = LDKLevel_to_java(env, Level_error());
25539         return ret_conv;
25540 }
25541
25542 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25543         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
25544         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
25545         jboolean ret_conv = Level_eq(a_conv, b_conv);
25546         return ret_conv;
25547 }
25548
25549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
25550         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
25551         int64_t ret_conv = Level_hash(o_conv);
25552         return ret_conv;
25553 }
25554
25555 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
25556         jclass ret_conv = LDKLevel_to_java(env, Level_max());
25557         return ret_conv;
25558 }
25559
25560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25561         LDKRecord this_obj_conv;
25562         this_obj_conv.inner = (void*)(this_obj & (~1));
25563         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25565         Record_free(this_obj_conv);
25566 }
25567
25568 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
25569         LDKRecord this_ptr_conv;
25570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25571         this_ptr_conv.is_owned = false;
25572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25573         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
25574         return ret_conv;
25575 }
25576
25577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
25578         LDKRecord this_ptr_conv;
25579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25580         this_ptr_conv.is_owned = false;
25581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25582         LDKLevel val_conv = LDKLevel_from_java(env, val);
25583         Record_set_level(&this_ptr_conv, val_conv);
25584 }
25585
25586 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
25587         LDKRecord this_ptr_conv;
25588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25589         this_ptr_conv.is_owned = false;
25590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25591         LDKStr ret_str = Record_get_args(&this_ptr_conv);
25592         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25593         Str_free(ret_str);
25594         return ret_conv;
25595 }
25596
25597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
25598         LDKRecord this_ptr_conv;
25599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25600         this_ptr_conv.is_owned = false;
25601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25602         LDKStr val_conv = java_to_owned_str(env, val);
25603         Record_set_args(&this_ptr_conv, val_conv);
25604 }
25605
25606 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
25607         LDKRecord this_ptr_conv;
25608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25609         this_ptr_conv.is_owned = false;
25610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25611         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
25612         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25613         Str_free(ret_str);
25614         return ret_conv;
25615 }
25616
25617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
25618         LDKRecord this_ptr_conv;
25619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25620         this_ptr_conv.is_owned = false;
25621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25622         LDKStr val_conv = java_to_owned_str(env, val);
25623         Record_set_module_path(&this_ptr_conv, val_conv);
25624 }
25625
25626 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
25627         LDKRecord this_ptr_conv;
25628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25629         this_ptr_conv.is_owned = false;
25630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25631         LDKStr ret_str = Record_get_file(&this_ptr_conv);
25632         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25633         Str_free(ret_str);
25634         return ret_conv;
25635 }
25636
25637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
25638         LDKRecord this_ptr_conv;
25639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25640         this_ptr_conv.is_owned = false;
25641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25642         LDKStr val_conv = java_to_owned_str(env, val);
25643         Record_set_file(&this_ptr_conv, val_conv);
25644 }
25645
25646 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
25647         LDKRecord this_ptr_conv;
25648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25649         this_ptr_conv.is_owned = false;
25650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25651         int32_t ret_conv = Record_get_line(&this_ptr_conv);
25652         return ret_conv;
25653 }
25654
25655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25656         LDKRecord this_ptr_conv;
25657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25658         this_ptr_conv.is_owned = false;
25659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25660         Record_set_line(&this_ptr_conv, val);
25661 }
25662
25663 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
25664         LDKRecord ret_var = Record_clone(arg);
25665 int64_t ret_ref = 0;
25666 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25667 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25668 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25669 ret_ref = (uintptr_t)ret_var.inner;
25670 if (ret_var.is_owned) {
25671         ret_ref |= 1;
25672 }
25673         return ret_ref;
25674 }
25675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25676         LDKRecord arg_conv;
25677         arg_conv.inner = (void*)(arg & (~1));
25678         arg_conv.is_owned = false;
25679         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25680         int64_t ret_conv = Record_clone_ptr(&arg_conv);
25681         return ret_conv;
25682 }
25683
25684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25685         LDKRecord orig_conv;
25686         orig_conv.inner = (void*)(orig & (~1));
25687         orig_conv.is_owned = false;
25688         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25689         LDKRecord ret_var = Record_clone(&orig_conv);
25690         int64_t ret_ref = 0;
25691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25694         ret_ref = (uintptr_t)ret_var.inner;
25695         if (ret_var.is_owned) {
25696                 ret_ref |= 1;
25697         }
25698         return ret_ref;
25699 }
25700
25701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25702         if ((this_ptr & 1) != 0) return;
25703         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25704         CHECK_ACCESS(this_ptr_ptr);
25705         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
25706         FREE((void*)this_ptr);
25707         Logger_free(this_ptr_conv);
25708 }
25709
25710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25711         LDKChannelHandshakeConfig this_obj_conv;
25712         this_obj_conv.inner = (void*)(this_obj & (~1));
25713         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25715         ChannelHandshakeConfig_free(this_obj_conv);
25716 }
25717
25718 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
25719         LDKChannelHandshakeConfig this_ptr_conv;
25720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25721         this_ptr_conv.is_owned = false;
25722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25723         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
25724         return ret_conv;
25725 }
25726
25727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25728         LDKChannelHandshakeConfig this_ptr_conv;
25729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25730         this_ptr_conv.is_owned = false;
25731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25732         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
25733 }
25734
25735 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
25736         LDKChannelHandshakeConfig this_ptr_conv;
25737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25738         this_ptr_conv.is_owned = false;
25739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25740         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
25741         return ret_conv;
25742 }
25743
25744 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) {
25745         LDKChannelHandshakeConfig this_ptr_conv;
25746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25747         this_ptr_conv.is_owned = false;
25748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25749         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
25750 }
25751
25752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25753         LDKChannelHandshakeConfig this_ptr_conv;
25754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25755         this_ptr_conv.is_owned = false;
25756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25757         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
25758         return ret_conv;
25759 }
25760
25761 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) {
25762         LDKChannelHandshakeConfig this_ptr_conv;
25763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25764         this_ptr_conv.is_owned = false;
25765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25766         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
25767 }
25768
25769 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1max_1inbound_1htlc_1value_1in_1flight_1percent_1of_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
25770         LDKChannelHandshakeConfig this_ptr_conv;
25771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25772         this_ptr_conv.is_owned = false;
25773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25774         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
25775         return ret_conv;
25776 }
25777
25778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1max_1inbound_1htlc_1value_1in_1flight_1percent_1of_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
25779         LDKChannelHandshakeConfig this_ptr_conv;
25780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25781         this_ptr_conv.is_owned = false;
25782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25783         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
25784 }
25785
25786 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
25787         LDKChannelHandshakeConfig this_ptr_conv;
25788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25789         this_ptr_conv.is_owned = false;
25790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25791         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
25792         return ret_conv;
25793 }
25794
25795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25796         LDKChannelHandshakeConfig this_ptr_conv;
25797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25798         this_ptr_conv.is_owned = false;
25799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25800         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
25801 }
25802
25803 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
25804         LDKChannelHandshakeConfig this_ptr_conv;
25805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25806         this_ptr_conv.is_owned = false;
25807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25808         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
25809         return ret_conv;
25810 }
25811
25812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25813         LDKChannelHandshakeConfig this_ptr_conv;
25814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25815         this_ptr_conv.is_owned = false;
25816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25817         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
25818 }
25819
25820 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
25821         LDKChannelHandshakeConfig this_ptr_conv;
25822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25823         this_ptr_conv.is_owned = false;
25824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25825         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
25826         return ret_conv;
25827 }
25828
25829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25830         LDKChannelHandshakeConfig this_ptr_conv;
25831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25832         this_ptr_conv.is_owned = false;
25833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25834         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
25835 }
25836
25837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1new(JNIEnv *env, jclass clz, int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg, int8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, jboolean negotiate_scid_privacy_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
25838         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, max_inbound_htlc_value_in_flight_percent_of_channel_arg, negotiate_scid_privacy_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
25839         int64_t ret_ref = 0;
25840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25843         ret_ref = (uintptr_t)ret_var.inner;
25844         if (ret_var.is_owned) {
25845                 ret_ref |= 1;
25846         }
25847         return ret_ref;
25848 }
25849
25850 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
25851         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
25852 int64_t ret_ref = 0;
25853 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25854 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25855 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25856 ret_ref = (uintptr_t)ret_var.inner;
25857 if (ret_var.is_owned) {
25858         ret_ref |= 1;
25859 }
25860         return ret_ref;
25861 }
25862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25863         LDKChannelHandshakeConfig arg_conv;
25864         arg_conv.inner = (void*)(arg & (~1));
25865         arg_conv.is_owned = false;
25866         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25867         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
25868         return ret_conv;
25869 }
25870
25871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25872         LDKChannelHandshakeConfig orig_conv;
25873         orig_conv.inner = (void*)(orig & (~1));
25874         orig_conv.is_owned = false;
25875         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25876         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
25877         int64_t ret_ref = 0;
25878         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25879         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25881         ret_ref = (uintptr_t)ret_var.inner;
25882         if (ret_var.is_owned) {
25883                 ret_ref |= 1;
25884         }
25885         return ret_ref;
25886 }
25887
25888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
25889         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
25890         int64_t ret_ref = 0;
25891         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25892         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25894         ret_ref = (uintptr_t)ret_var.inner;
25895         if (ret_var.is_owned) {
25896                 ret_ref |= 1;
25897         }
25898         return ret_ref;
25899 }
25900
25901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25902         LDKChannelHandshakeLimits this_obj_conv;
25903         this_obj_conv.inner = (void*)(this_obj & (~1));
25904         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25906         ChannelHandshakeLimits_free(this_obj_conv);
25907 }
25908
25909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25910         LDKChannelHandshakeLimits this_ptr_conv;
25911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25912         this_ptr_conv.is_owned = false;
25913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25914         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
25915         return ret_conv;
25916 }
25917
25918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25919         LDKChannelHandshakeLimits this_ptr_conv;
25920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25921         this_ptr_conv.is_owned = false;
25922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25923         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
25924 }
25925
25926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25927         LDKChannelHandshakeLimits this_ptr_conv;
25928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25929         this_ptr_conv.is_owned = false;
25930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25931         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
25932         return ret_conv;
25933 }
25934
25935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25936         LDKChannelHandshakeLimits this_ptr_conv;
25937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25938         this_ptr_conv.is_owned = false;
25939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25940         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
25941 }
25942
25943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25944         LDKChannelHandshakeLimits this_ptr_conv;
25945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25946         this_ptr_conv.is_owned = false;
25947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25948         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
25949         return ret_conv;
25950 }
25951
25952 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) {
25953         LDKChannelHandshakeLimits this_ptr_conv;
25954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25955         this_ptr_conv.is_owned = false;
25956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25957         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
25958 }
25959
25960 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) {
25961         LDKChannelHandshakeLimits this_ptr_conv;
25962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25963         this_ptr_conv.is_owned = false;
25964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25965         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
25966         return ret_conv;
25967 }
25968
25969 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) {
25970         LDKChannelHandshakeLimits this_ptr_conv;
25971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25972         this_ptr_conv.is_owned = false;
25973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25974         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
25975 }
25976
25977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25978         LDKChannelHandshakeLimits this_ptr_conv;
25979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25980         this_ptr_conv.is_owned = false;
25981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25982         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
25983         return ret_conv;
25984 }
25985
25986 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) {
25987         LDKChannelHandshakeLimits this_ptr_conv;
25988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25989         this_ptr_conv.is_owned = false;
25990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25991         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
25992 }
25993
25994 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
25995         LDKChannelHandshakeLimits this_ptr_conv;
25996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25997         this_ptr_conv.is_owned = false;
25998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25999         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
26000         return ret_conv;
26001 }
26002
26003 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) {
26004         LDKChannelHandshakeLimits this_ptr_conv;
26005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26006         this_ptr_conv.is_owned = false;
26007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26008         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
26009 }
26010
26011 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
26012         LDKChannelHandshakeLimits this_ptr_conv;
26013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26014         this_ptr_conv.is_owned = false;
26015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26016         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
26017         return ret_conv;
26018 }
26019
26020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26021         LDKChannelHandshakeLimits this_ptr_conv;
26022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26023         this_ptr_conv.is_owned = false;
26024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26025         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
26026 }
26027
26028 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr) {
26029         LDKChannelHandshakeLimits this_ptr_conv;
26030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26031         this_ptr_conv.is_owned = false;
26032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26033         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
26034         return ret_conv;
26035 }
26036
26037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26038         LDKChannelHandshakeLimits this_ptr_conv;
26039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26040         this_ptr_conv.is_owned = false;
26041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26042         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
26043 }
26044
26045 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
26046         LDKChannelHandshakeLimits this_ptr_conv;
26047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26048         this_ptr_conv.is_owned = false;
26049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26050         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
26051         return ret_conv;
26052 }
26053
26054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26055         LDKChannelHandshakeLimits this_ptr_conv;
26056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26057         this_ptr_conv.is_owned = false;
26058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26059         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
26060 }
26061
26062 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26063         LDKChannelHandshakeLimits this_ptr_conv;
26064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26065         this_ptr_conv.is_owned = false;
26066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26067         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
26068         return ret_conv;
26069 }
26070
26071 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) {
26072         LDKChannelHandshakeLimits this_ptr_conv;
26073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26074         this_ptr_conv.is_owned = false;
26075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26076         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
26077 }
26078
26079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(JNIEnv *env, jclass clz, int64_t min_funding_satoshis_arg, int64_t max_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int32_t max_minimum_depth_arg, jboolean trust_own_funding_0conf_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
26080         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, trust_own_funding_0conf_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
26081         int64_t ret_ref = 0;
26082         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26083         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26085         ret_ref = (uintptr_t)ret_var.inner;
26086         if (ret_var.is_owned) {
26087                 ret_ref |= 1;
26088         }
26089         return ret_ref;
26090 }
26091
26092 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
26093         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
26094 int64_t ret_ref = 0;
26095 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26096 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26097 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26098 ret_ref = (uintptr_t)ret_var.inner;
26099 if (ret_var.is_owned) {
26100         ret_ref |= 1;
26101 }
26102         return ret_ref;
26103 }
26104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26105         LDKChannelHandshakeLimits arg_conv;
26106         arg_conv.inner = (void*)(arg & (~1));
26107         arg_conv.is_owned = false;
26108         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26109         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
26110         return ret_conv;
26111 }
26112
26113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26114         LDKChannelHandshakeLimits orig_conv;
26115         orig_conv.inner = (void*)(orig & (~1));
26116         orig_conv.is_owned = false;
26117         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26118         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
26119         int64_t ret_ref = 0;
26120         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26121         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26123         ret_ref = (uintptr_t)ret_var.inner;
26124         if (ret_var.is_owned) {
26125                 ret_ref |= 1;
26126         }
26127         return ret_ref;
26128 }
26129
26130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
26131         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
26132         int64_t ret_ref = 0;
26133         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26134         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26136         ret_ref = (uintptr_t)ret_var.inner;
26137         if (ret_var.is_owned) {
26138                 ret_ref |= 1;
26139         }
26140         return ret_ref;
26141 }
26142
26143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26144         LDKChannelConfig this_obj_conv;
26145         this_obj_conv.inner = (void*)(this_obj & (~1));
26146         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26148         ChannelConfig_free(this_obj_conv);
26149 }
26150
26151 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
26152         LDKChannelConfig this_ptr_conv;
26153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26154         this_ptr_conv.is_owned = false;
26155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26156         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
26157         return ret_conv;
26158 }
26159
26160 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) {
26161         LDKChannelConfig this_ptr_conv;
26162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26163         this_ptr_conv.is_owned = false;
26164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26165         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
26166 }
26167
26168 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26169         LDKChannelConfig this_ptr_conv;
26170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26171         this_ptr_conv.is_owned = false;
26172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26173         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
26174         return ret_conv;
26175 }
26176
26177 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) {
26178         LDKChannelConfig this_ptr_conv;
26179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26180         this_ptr_conv.is_owned = false;
26181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26182         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
26183 }
26184
26185 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
26186         LDKChannelConfig this_ptr_conv;
26187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26188         this_ptr_conv.is_owned = false;
26189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26190         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
26191         return ret_conv;
26192 }
26193
26194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26195         LDKChannelConfig this_ptr_conv;
26196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26197         this_ptr_conv.is_owned = false;
26198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26199         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
26200 }
26201
26202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26203         LDKChannelConfig this_ptr_conv;
26204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26205         this_ptr_conv.is_owned = false;
26206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26207         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
26208         return ret_conv;
26209 }
26210
26211 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) {
26212         LDKChannelConfig this_ptr_conv;
26213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26214         this_ptr_conv.is_owned = false;
26215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26216         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
26217 }
26218
26219 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) {
26220         LDKChannelConfig this_ptr_conv;
26221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26222         this_ptr_conv.is_owned = false;
26223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26224         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
26225         return ret_conv;
26226 }
26227
26228 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) {
26229         LDKChannelConfig this_ptr_conv;
26230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26231         this_ptr_conv.is_owned = false;
26232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26233         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
26234 }
26235
26236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
26237         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
26238         int64_t ret_ref = 0;
26239         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26240         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26242         ret_ref = (uintptr_t)ret_var.inner;
26243         if (ret_var.is_owned) {
26244                 ret_ref |= 1;
26245         }
26246         return ret_ref;
26247 }
26248
26249 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
26250         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
26251 int64_t ret_ref = 0;
26252 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26253 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26254 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26255 ret_ref = (uintptr_t)ret_var.inner;
26256 if (ret_var.is_owned) {
26257         ret_ref |= 1;
26258 }
26259         return ret_ref;
26260 }
26261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26262         LDKChannelConfig arg_conv;
26263         arg_conv.inner = (void*)(arg & (~1));
26264         arg_conv.is_owned = false;
26265         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26266         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
26267         return ret_conv;
26268 }
26269
26270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26271         LDKChannelConfig orig_conv;
26272         orig_conv.inner = (void*)(orig & (~1));
26273         orig_conv.is_owned = false;
26274         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26275         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
26276         int64_t ret_ref = 0;
26277         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26278         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26280         ret_ref = (uintptr_t)ret_var.inner;
26281         if (ret_var.is_owned) {
26282                 ret_ref |= 1;
26283         }
26284         return ret_ref;
26285 }
26286
26287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
26288         LDKChannelConfig ret_var = ChannelConfig_default();
26289         int64_t ret_ref = 0;
26290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26293         ret_ref = (uintptr_t)ret_var.inner;
26294         if (ret_var.is_owned) {
26295                 ret_ref |= 1;
26296         }
26297         return ret_ref;
26298 }
26299
26300 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
26301         LDKChannelConfig obj_conv;
26302         obj_conv.inner = (void*)(obj & (~1));
26303         obj_conv.is_owned = false;
26304         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26305         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
26306         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26307         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26308         CVec_u8Z_free(ret_var);
26309         return ret_arr;
26310 }
26311
26312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26313         LDKu8slice ser_ref;
26314         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26315         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26316         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
26317         *ret_conv = ChannelConfig_read(ser_ref);
26318         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26319         return (int64_t)ret_conv;
26320 }
26321
26322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26323         LDKUserConfig this_obj_conv;
26324         this_obj_conv.inner = (void*)(this_obj & (~1));
26325         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26327         UserConfig_free(this_obj_conv);
26328 }
26329
26330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
26331         LDKUserConfig this_ptr_conv;
26332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26333         this_ptr_conv.is_owned = false;
26334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26335         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
26336         int64_t ret_ref = 0;
26337         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26338         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26339         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26340         ret_ref = (uintptr_t)ret_var.inner;
26341         if (ret_var.is_owned) {
26342                 ret_ref |= 1;
26343         }
26344         return ret_ref;
26345 }
26346
26347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26348         LDKUserConfig this_ptr_conv;
26349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26350         this_ptr_conv.is_owned = false;
26351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26352         LDKChannelHandshakeConfig val_conv;
26353         val_conv.inner = (void*)(val & (~1));
26354         val_conv.is_owned = (val & 1) || (val == 0);
26355         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26356         val_conv = ChannelHandshakeConfig_clone(&val_conv);
26357         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
26358 }
26359
26360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
26361         LDKUserConfig this_ptr_conv;
26362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26363         this_ptr_conv.is_owned = false;
26364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26365         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
26366         int64_t ret_ref = 0;
26367         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26368         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26370         ret_ref = (uintptr_t)ret_var.inner;
26371         if (ret_var.is_owned) {
26372                 ret_ref |= 1;
26373         }
26374         return ret_ref;
26375 }
26376
26377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26378         LDKUserConfig this_ptr_conv;
26379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26380         this_ptr_conv.is_owned = false;
26381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26382         LDKChannelHandshakeLimits val_conv;
26383         val_conv.inner = (void*)(val & (~1));
26384         val_conv.is_owned = (val & 1) || (val == 0);
26385         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26386         val_conv = ChannelHandshakeLimits_clone(&val_conv);
26387         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
26388 }
26389
26390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
26391         LDKUserConfig this_ptr_conv;
26392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26393         this_ptr_conv.is_owned = false;
26394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26395         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
26396         int64_t ret_ref = 0;
26397         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26398         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26400         ret_ref = (uintptr_t)ret_var.inner;
26401         if (ret_var.is_owned) {
26402                 ret_ref |= 1;
26403         }
26404         return ret_ref;
26405 }
26406
26407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26408         LDKUserConfig this_ptr_conv;
26409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26410         this_ptr_conv.is_owned = false;
26411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26412         LDKChannelConfig val_conv;
26413         val_conv.inner = (void*)(val & (~1));
26414         val_conv.is_owned = (val & 1) || (val == 0);
26415         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26416         val_conv = ChannelConfig_clone(&val_conv);
26417         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
26418 }
26419
26420 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
26421         LDKUserConfig this_ptr_conv;
26422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26423         this_ptr_conv.is_owned = false;
26424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26425         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
26426         return ret_conv;
26427 }
26428
26429 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) {
26430         LDKUserConfig this_ptr_conv;
26431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26432         this_ptr_conv.is_owned = false;
26433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26434         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
26435 }
26436
26437 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
26438         LDKUserConfig this_ptr_conv;
26439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26440         this_ptr_conv.is_owned = false;
26441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26442         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
26443         return ret_conv;
26444 }
26445
26446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26447         LDKUserConfig 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         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
26452 }
26453
26454 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
26455         LDKUserConfig this_ptr_conv;
26456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26457         this_ptr_conv.is_owned = false;
26458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26459         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
26460         return ret_conv;
26461 }
26462
26463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26464         LDKUserConfig this_ptr_conv;
26465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26466         this_ptr_conv.is_owned = false;
26467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26468         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
26469 }
26470
26471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t channel_handshake_config_arg, int64_t channel_handshake_limits_arg, int64_t channel_config_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg, jboolean manually_accept_inbound_channels_arg) {
26472         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
26473         channel_handshake_config_arg_conv.inner = (void*)(channel_handshake_config_arg & (~1));
26474         channel_handshake_config_arg_conv.is_owned = (channel_handshake_config_arg & 1) || (channel_handshake_config_arg == 0);
26475         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
26476         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
26477         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
26478         channel_handshake_limits_arg_conv.inner = (void*)(channel_handshake_limits_arg & (~1));
26479         channel_handshake_limits_arg_conv.is_owned = (channel_handshake_limits_arg & 1) || (channel_handshake_limits_arg == 0);
26480         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
26481         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
26482         LDKChannelConfig channel_config_arg_conv;
26483         channel_config_arg_conv.inner = (void*)(channel_config_arg & (~1));
26484         channel_config_arg_conv.is_owned = (channel_config_arg & 1) || (channel_config_arg == 0);
26485         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
26486         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
26487         LDKUserConfig ret_var = UserConfig_new(channel_handshake_config_arg_conv, channel_handshake_limits_arg_conv, channel_config_arg_conv, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg);
26488         int64_t ret_ref = 0;
26489         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26490         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26492         ret_ref = (uintptr_t)ret_var.inner;
26493         if (ret_var.is_owned) {
26494                 ret_ref |= 1;
26495         }
26496         return ret_ref;
26497 }
26498
26499 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
26500         LDKUserConfig ret_var = UserConfig_clone(arg);
26501 int64_t ret_ref = 0;
26502 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26503 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26504 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26505 ret_ref = (uintptr_t)ret_var.inner;
26506 if (ret_var.is_owned) {
26507         ret_ref |= 1;
26508 }
26509         return ret_ref;
26510 }
26511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26512         LDKUserConfig arg_conv;
26513         arg_conv.inner = (void*)(arg & (~1));
26514         arg_conv.is_owned = false;
26515         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26516         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
26517         return ret_conv;
26518 }
26519
26520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26521         LDKUserConfig orig_conv;
26522         orig_conv.inner = (void*)(orig & (~1));
26523         orig_conv.is_owned = false;
26524         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26525         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
26526         int64_t ret_ref = 0;
26527         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26528         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26530         ret_ref = (uintptr_t)ret_var.inner;
26531         if (ret_var.is_owned) {
26532                 ret_ref |= 1;
26533         }
26534         return ret_ref;
26535 }
26536
26537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
26538         LDKUserConfig ret_var = UserConfig_default();
26539         int64_t ret_ref = 0;
26540         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26541         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26543         ret_ref = (uintptr_t)ret_var.inner;
26544         if (ret_var.is_owned) {
26545                 ret_ref |= 1;
26546         }
26547         return ret_ref;
26548 }
26549
26550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26551         LDKBestBlock this_obj_conv;
26552         this_obj_conv.inner = (void*)(this_obj & (~1));
26553         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26555         BestBlock_free(this_obj_conv);
26556 }
26557
26558 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
26559         LDKBestBlock ret_var = BestBlock_clone(arg);
26560 int64_t ret_ref = 0;
26561 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26562 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26563 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26564 ret_ref = (uintptr_t)ret_var.inner;
26565 if (ret_var.is_owned) {
26566         ret_ref |= 1;
26567 }
26568         return ret_ref;
26569 }
26570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26571         LDKBestBlock arg_conv;
26572         arg_conv.inner = (void*)(arg & (~1));
26573         arg_conv.is_owned = false;
26574         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26575         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
26576         return ret_conv;
26577 }
26578
26579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26580         LDKBestBlock orig_conv;
26581         orig_conv.inner = (void*)(orig & (~1));
26582         orig_conv.is_owned = false;
26583         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26584         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
26585         int64_t ret_ref = 0;
26586         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26587         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26589         ret_ref = (uintptr_t)ret_var.inner;
26590         if (ret_var.is_owned) {
26591                 ret_ref |= 1;
26592         }
26593         return ret_ref;
26594 }
26595
26596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
26597         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
26598         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
26599         int64_t ret_ref = 0;
26600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26603         ret_ref = (uintptr_t)ret_var.inner;
26604         if (ret_var.is_owned) {
26605                 ret_ref |= 1;
26606         }
26607         return ret_ref;
26608 }
26609
26610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
26611         LDKThirtyTwoBytes block_hash_ref;
26612         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
26613         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
26614         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
26615         int64_t ret_ref = 0;
26616         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26617         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26619         ret_ref = (uintptr_t)ret_var.inner;
26620         if (ret_var.is_owned) {
26621                 ret_ref |= 1;
26622         }
26623         return ret_ref;
26624 }
26625
26626 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
26627         LDKBestBlock this_arg_conv;
26628         this_arg_conv.inner = (void*)(this_arg & (~1));
26629         this_arg_conv.is_owned = false;
26630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26631         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26632         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
26633         return ret_arr;
26634 }
26635
26636 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
26637         LDKBestBlock this_arg_conv;
26638         this_arg_conv.inner = (void*)(this_arg & (~1));
26639         this_arg_conv.is_owned = false;
26640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26641         int32_t ret_conv = BestBlock_height(&this_arg_conv);
26642         return ret_conv;
26643 }
26644
26645 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26646         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
26647         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
26648         return ret_conv;
26649 }
26650
26651 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
26652         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
26653         return ret_conv;
26654 }
26655
26656 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
26657         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
26658         return ret_conv;
26659 }
26660
26661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26662         if ((this_ptr & 1) != 0) return;
26663         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26664         CHECK_ACCESS(this_ptr_ptr);
26665         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
26666         FREE((void*)this_ptr);
26667         Access_free(this_ptr_conv);
26668 }
26669
26670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26671         if ((this_ptr & 1) != 0) return;
26672         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26673         CHECK_ACCESS(this_ptr_ptr);
26674         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
26675         FREE((void*)this_ptr);
26676         Listen_free(this_ptr_conv);
26677 }
26678
26679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26680         if ((this_ptr & 1) != 0) return;
26681         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26682         CHECK_ACCESS(this_ptr_ptr);
26683         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
26684         FREE((void*)this_ptr);
26685         Confirm_free(this_ptr_conv);
26686 }
26687
26688 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26689         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
26690         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
26691         return ret_conv;
26692 }
26693
26694 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
26695         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
26696         return ret_conv;
26697 }
26698
26699 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
26700         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
26701         return ret_conv;
26702 }
26703
26704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26705         if ((this_ptr & 1) != 0) return;
26706         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26707         CHECK_ACCESS(this_ptr_ptr);
26708         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
26709         FREE((void*)this_ptr);
26710         Watch_free(this_ptr_conv);
26711 }
26712
26713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26714         if ((this_ptr & 1) != 0) return;
26715         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26716         CHECK_ACCESS(this_ptr_ptr);
26717         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
26718         FREE((void*)this_ptr);
26719         Filter_free(this_ptr_conv);
26720 }
26721
26722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26723         LDKWatchedOutput this_obj_conv;
26724         this_obj_conv.inner = (void*)(this_obj & (~1));
26725         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26727         WatchedOutput_free(this_obj_conv);
26728 }
26729
26730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
26731         LDKWatchedOutput this_ptr_conv;
26732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26733         this_ptr_conv.is_owned = false;
26734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26735         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26736         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
26737         return ret_arr;
26738 }
26739
26740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26741         LDKWatchedOutput this_ptr_conv;
26742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26743         this_ptr_conv.is_owned = false;
26744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26745         LDKThirtyTwoBytes val_ref;
26746         CHECK((*env)->GetArrayLength(env, val) == 32);
26747         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26748         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
26749 }
26750
26751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26752         LDKWatchedOutput this_ptr_conv;
26753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26754         this_ptr_conv.is_owned = false;
26755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26756         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
26757         int64_t ret_ref = 0;
26758         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26759         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26761         ret_ref = (uintptr_t)ret_var.inner;
26762         if (ret_var.is_owned) {
26763                 ret_ref |= 1;
26764         }
26765         return ret_ref;
26766 }
26767
26768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26769         LDKWatchedOutput this_ptr_conv;
26770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26771         this_ptr_conv.is_owned = false;
26772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26773         LDKOutPoint val_conv;
26774         val_conv.inner = (void*)(val & (~1));
26775         val_conv.is_owned = (val & 1) || (val == 0);
26776         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26777         val_conv = OutPoint_clone(&val_conv);
26778         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
26779 }
26780
26781 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26782         LDKWatchedOutput this_ptr_conv;
26783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26784         this_ptr_conv.is_owned = false;
26785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26786         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
26787         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26788         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26789         return ret_arr;
26790 }
26791
26792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26793         LDKWatchedOutput this_ptr_conv;
26794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26795         this_ptr_conv.is_owned = false;
26796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26797         LDKCVec_u8Z val_ref;
26798         val_ref.datalen = (*env)->GetArrayLength(env, val);
26799         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
26800         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
26801         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
26802 }
26803
26804 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) {
26805         LDKThirtyTwoBytes block_hash_arg_ref;
26806         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
26807         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
26808         LDKOutPoint outpoint_arg_conv;
26809         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
26810         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
26811         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
26812         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
26813         LDKCVec_u8Z script_pubkey_arg_ref;
26814         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
26815         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
26816         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
26817         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
26818         int64_t ret_ref = 0;
26819         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26820         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26822         ret_ref = (uintptr_t)ret_var.inner;
26823         if (ret_var.is_owned) {
26824                 ret_ref |= 1;
26825         }
26826         return ret_ref;
26827 }
26828
26829 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
26830         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
26831 int64_t ret_ref = 0;
26832 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26833 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26834 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26835 ret_ref = (uintptr_t)ret_var.inner;
26836 if (ret_var.is_owned) {
26837         ret_ref |= 1;
26838 }
26839         return ret_ref;
26840 }
26841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26842         LDKWatchedOutput arg_conv;
26843         arg_conv.inner = (void*)(arg & (~1));
26844         arg_conv.is_owned = false;
26845         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26846         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
26847         return ret_conv;
26848 }
26849
26850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26851         LDKWatchedOutput orig_conv;
26852         orig_conv.inner = (void*)(orig & (~1));
26853         orig_conv.is_owned = false;
26854         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26855         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
26856         int64_t ret_ref = 0;
26857         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26858         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26860         ret_ref = (uintptr_t)ret_var.inner;
26861         if (ret_var.is_owned) {
26862                 ret_ref |= 1;
26863         }
26864         return ret_ref;
26865 }
26866
26867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
26868         LDKWatchedOutput o_conv;
26869         o_conv.inner = (void*)(o & (~1));
26870         o_conv.is_owned = false;
26871         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26872         int64_t ret_conv = WatchedOutput_hash(&o_conv);
26873         return ret_conv;
26874 }
26875
26876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26877         if ((this_ptr & 1) != 0) return;
26878         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26879         CHECK_ACCESS(this_ptr_ptr);
26880         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
26881         FREE((void*)this_ptr);
26882         BroadcasterInterface_free(this_ptr_conv);
26883 }
26884
26885 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26886         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
26887         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
26888         return ret_conv;
26889 }
26890
26891 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
26892         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
26893         return ret_conv;
26894 }
26895
26896 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
26897         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
26898         return ret_conv;
26899 }
26900
26901 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
26902         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
26903         return ret_conv;
26904 }
26905
26906 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26907         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
26908         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
26909         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
26910         return ret_conv;
26911 }
26912
26913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26914         if ((this_ptr & 1) != 0) return;
26915         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26916         CHECK_ACCESS(this_ptr_ptr);
26917         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
26918         FREE((void*)this_ptr);
26919         FeeEstimator_free(this_ptr_conv);
26920 }
26921
26922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26923         LDKMonitorUpdateId this_obj_conv;
26924         this_obj_conv.inner = (void*)(this_obj & (~1));
26925         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26927         MonitorUpdateId_free(this_obj_conv);
26928 }
26929
26930 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
26931         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
26932 int64_t ret_ref = 0;
26933 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26934 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26935 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26936 ret_ref = (uintptr_t)ret_var.inner;
26937 if (ret_var.is_owned) {
26938         ret_ref |= 1;
26939 }
26940         return ret_ref;
26941 }
26942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26943         LDKMonitorUpdateId arg_conv;
26944         arg_conv.inner = (void*)(arg & (~1));
26945         arg_conv.is_owned = false;
26946         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26947         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
26948         return ret_conv;
26949 }
26950
26951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26952         LDKMonitorUpdateId orig_conv;
26953         orig_conv.inner = (void*)(orig & (~1));
26954         orig_conv.is_owned = false;
26955         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26956         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
26957         int64_t ret_ref = 0;
26958         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26959         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26961         ret_ref = (uintptr_t)ret_var.inner;
26962         if (ret_var.is_owned) {
26963                 ret_ref |= 1;
26964         }
26965         return ret_ref;
26966 }
26967
26968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
26969         LDKMonitorUpdateId o_conv;
26970         o_conv.inner = (void*)(o & (~1));
26971         o_conv.is_owned = false;
26972         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26973         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
26974         return ret_conv;
26975 }
26976
26977 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26978         LDKMonitorUpdateId a_conv;
26979         a_conv.inner = (void*)(a & (~1));
26980         a_conv.is_owned = false;
26981         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26982         LDKMonitorUpdateId b_conv;
26983         b_conv.inner = (void*)(b & (~1));
26984         b_conv.is_owned = false;
26985         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
26986         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
26987         return ret_conv;
26988 }
26989
26990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26991         if ((this_ptr & 1) != 0) return;
26992         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26993         CHECK_ACCESS(this_ptr_ptr);
26994         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
26995         FREE((void*)this_ptr);
26996         Persist_free(this_ptr_conv);
26997 }
26998
26999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27000         LDKLockedChannelMonitor this_obj_conv;
27001         this_obj_conv.inner = (void*)(this_obj & (~1));
27002         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27004         LockedChannelMonitor_free(this_obj_conv);
27005 }
27006
27007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27008         LDKChainMonitor this_obj_conv;
27009         this_obj_conv.inner = (void*)(this_obj & (~1));
27010         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27012         ChainMonitor_free(this_obj_conv);
27013 }
27014
27015 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) {
27016         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
27017         CHECK_ACCESS(chain_source_ptr);
27018         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
27019         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
27020         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
27021                 // Manually implement clone for Java trait instances
27022                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
27023                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27024                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
27025                 }
27026         }
27027         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27028         CHECK_ACCESS(broadcaster_ptr);
27029         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27030         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27031                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27032                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27033         }
27034         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27035         CHECK_ACCESS(logger_ptr);
27036         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27037         if (logger_conv.free == LDKLogger_JCalls_free) {
27038                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27039                 LDKLogger_JCalls_cloned(&logger_conv);
27040         }
27041         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
27042         CHECK_ACCESS(feeest_ptr);
27043         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
27044         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
27045                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27046                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
27047         }
27048         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
27049         CHECK_ACCESS(persister_ptr);
27050         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
27051         if (persister_conv.free == LDKPersist_JCalls_free) {
27052                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27053                 LDKPersist_JCalls_cloned(&persister_conv);
27054         }
27055         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
27056         int64_t ret_ref = 0;
27057         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27058         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27060         ret_ref = (uintptr_t)ret_var.inner;
27061         if (ret_var.is_owned) {
27062                 ret_ref |= 1;
27063         }
27064         return ret_ref;
27065 }
27066
27067 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) {
27068         LDKChainMonitor this_arg_conv;
27069         this_arg_conv.inner = (void*)(this_arg & (~1));
27070         this_arg_conv.is_owned = false;
27071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27072         LDKCVec_ChannelDetailsZ ignored_channels_constr;
27073         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
27074         if (ignored_channels_constr.datalen > 0)
27075                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
27076         else
27077                 ignored_channels_constr.data = NULL;
27078         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
27079         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
27080                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
27081                 LDKChannelDetails ignored_channels_conv_16_conv;
27082                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
27083                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
27084                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
27085                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
27086                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
27087         }
27088         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
27089         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
27090         int64_tArray ret_arr = NULL;
27091         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27092         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27093         for (size_t j = 0; j < ret_var.datalen; j++) {
27094                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27095                 *ret_conv_9_copy = ret_var.data[j];
27096                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
27097                 ret_arr_ptr[j] = ret_conv_9_ref;
27098         }
27099         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27100         FREE(ret_var.data);
27101         return ret_arr;
27102 }
27103
27104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
27105         LDKChainMonitor this_arg_conv;
27106         this_arg_conv.inner = (void*)(this_arg & (~1));
27107         this_arg_conv.is_owned = false;
27108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27109         LDKOutPoint funding_txo_conv;
27110         funding_txo_conv.inner = (void*)(funding_txo & (~1));
27111         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
27112         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
27113         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
27114         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
27115         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
27116         return (int64_t)ret_conv;
27117 }
27118
27119 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
27120         LDKChainMonitor this_arg_conv;
27121         this_arg_conv.inner = (void*)(this_arg & (~1));
27122         this_arg_conv.is_owned = false;
27123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27124         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
27125         int64_tArray ret_arr = NULL;
27126         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27127         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27128         for (size_t k = 0; k < ret_var.datalen; k++) {
27129                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
27130                 int64_t ret_conv_10_ref = 0;
27131                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27132                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27133                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
27134                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
27135                 if (ret_conv_10_var.is_owned) {
27136                         ret_conv_10_ref |= 1;
27137                 }
27138                 ret_arr_ptr[k] = ret_conv_10_ref;
27139         }
27140         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27141         FREE(ret_var.data);
27142         return ret_arr;
27143 }
27144
27145 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) {
27146         LDKChainMonitor this_arg_conv;
27147         this_arg_conv.inner = (void*)(this_arg & (~1));
27148         this_arg_conv.is_owned = false;
27149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27150         LDKOutPoint funding_txo_conv;
27151         funding_txo_conv.inner = (void*)(funding_txo & (~1));
27152         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
27153         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
27154         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
27155         LDKMonitorUpdateId completed_update_id_conv;
27156         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
27157         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
27158         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
27159         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
27160         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27161         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
27162         return (int64_t)ret_conv;
27163 }
27164
27165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
27166         LDKChainMonitor this_arg_conv;
27167         this_arg_conv.inner = (void*)(this_arg & (~1));
27168         this_arg_conv.is_owned = false;
27169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27170         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
27171         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
27172         return (int64_t)ret_ret;
27173 }
27174
27175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
27176         LDKChainMonitor this_arg_conv;
27177         this_arg_conv.inner = (void*)(this_arg & (~1));
27178         this_arg_conv.is_owned = false;
27179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27180         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
27181         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
27182         return (int64_t)ret_ret;
27183 }
27184
27185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
27186         LDKChainMonitor this_arg_conv;
27187         this_arg_conv.inner = (void*)(this_arg & (~1));
27188         this_arg_conv.is_owned = false;
27189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27190         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
27191         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
27192         return (int64_t)ret_ret;
27193 }
27194
27195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
27196         LDKChainMonitor this_arg_conv;
27197         this_arg_conv.inner = (void*)(this_arg & (~1));
27198         this_arg_conv.is_owned = false;
27199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27200         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
27201         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
27202         return (int64_t)ret_ret;
27203 }
27204
27205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27206         LDKChannelMonitorUpdate this_obj_conv;
27207         this_obj_conv.inner = (void*)(this_obj & (~1));
27208         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27210         ChannelMonitorUpdate_free(this_obj_conv);
27211 }
27212
27213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27214         LDKChannelMonitorUpdate this_ptr_conv;
27215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27216         this_ptr_conv.is_owned = false;
27217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27218         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
27219         return ret_conv;
27220 }
27221
27222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27223         LDKChannelMonitorUpdate this_ptr_conv;
27224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27225         this_ptr_conv.is_owned = false;
27226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27227         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
27228 }
27229
27230 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
27231         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
27232 int64_t ret_ref = 0;
27233 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27234 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27235 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27236 ret_ref = (uintptr_t)ret_var.inner;
27237 if (ret_var.is_owned) {
27238         ret_ref |= 1;
27239 }
27240         return ret_ref;
27241 }
27242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27243         LDKChannelMonitorUpdate arg_conv;
27244         arg_conv.inner = (void*)(arg & (~1));
27245         arg_conv.is_owned = false;
27246         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27247         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
27248         return ret_conv;
27249 }
27250
27251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27252         LDKChannelMonitorUpdate orig_conv;
27253         orig_conv.inner = (void*)(orig & (~1));
27254         orig_conv.is_owned = false;
27255         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27256         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
27257         int64_t ret_ref = 0;
27258         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27259         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27261         ret_ref = (uintptr_t)ret_var.inner;
27262         if (ret_var.is_owned) {
27263                 ret_ref |= 1;
27264         }
27265         return ret_ref;
27266 }
27267
27268 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
27269         LDKChannelMonitorUpdate obj_conv;
27270         obj_conv.inner = (void*)(obj & (~1));
27271         obj_conv.is_owned = false;
27272         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27273         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
27274         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27275         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27276         CVec_u8Z_free(ret_var);
27277         return ret_arr;
27278 }
27279
27280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27281         LDKu8slice ser_ref;
27282         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27283         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27284         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
27285         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
27286         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27287         return (int64_t)ret_conv;
27288 }
27289
27290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27291         if ((this_ptr & 1) != 0) return;
27292         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27293         CHECK_ACCESS(this_ptr_ptr);
27294         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
27295         FREE((void*)this_ptr);
27296         MonitorEvent_free(this_ptr_conv);
27297 }
27298
27299 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
27300         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27301         *ret_copy = MonitorEvent_clone(arg);
27302 int64_t ret_ref = (uintptr_t)ret_copy;
27303         return ret_ref;
27304 }
27305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27306         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
27307         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
27308         return ret_conv;
27309 }
27310
27311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27312         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
27313         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27314         *ret_copy = MonitorEvent_clone(orig_conv);
27315         int64_t ret_ref = (uintptr_t)ret_copy;
27316         return ret_ref;
27317 }
27318
27319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
27320         LDKHTLCUpdate a_conv;
27321         a_conv.inner = (void*)(a & (~1));
27322         a_conv.is_owned = (a & 1) || (a == 0);
27323         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27324         a_conv = HTLCUpdate_clone(&a_conv);
27325         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27326         *ret_copy = MonitorEvent_htlcevent(a_conv);
27327         int64_t ret_ref = (uintptr_t)ret_copy;
27328         return ret_ref;
27329 }
27330
27331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
27332         LDKOutPoint a_conv;
27333         a_conv.inner = (void*)(a & (~1));
27334         a_conv.is_owned = (a & 1) || (a == 0);
27335         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27336         a_conv = OutPoint_clone(&a_conv);
27337         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27338         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
27339         int64_t ret_ref = (uintptr_t)ret_copy;
27340         return ret_ref;
27341 }
27342
27343 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) {
27344         LDKOutPoint funding_txo_conv;
27345         funding_txo_conv.inner = (void*)(funding_txo & (~1));
27346         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
27347         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
27348         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
27349         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27350         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
27351         int64_t ret_ref = (uintptr_t)ret_copy;
27352         return ret_ref;
27353 }
27354
27355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
27356         LDKOutPoint a_conv;
27357         a_conv.inner = (void*)(a & (~1));
27358         a_conv.is_owned = (a & 1) || (a == 0);
27359         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27360         a_conv = OutPoint_clone(&a_conv);
27361         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27362         *ret_copy = MonitorEvent_update_failed(a_conv);
27363         int64_t ret_ref = (uintptr_t)ret_copy;
27364         return ret_ref;
27365 }
27366
27367 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
27368         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
27369         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
27370         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27371         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27372         CVec_u8Z_free(ret_var);
27373         return ret_arr;
27374 }
27375
27376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27377         LDKu8slice ser_ref;
27378         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27379         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27380         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
27381         *ret_conv = MonitorEvent_read(ser_ref);
27382         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27383         return (int64_t)ret_conv;
27384 }
27385
27386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27387         LDKHTLCUpdate this_obj_conv;
27388         this_obj_conv.inner = (void*)(this_obj & (~1));
27389         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27391         HTLCUpdate_free(this_obj_conv);
27392 }
27393
27394 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
27395         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
27396 int64_t ret_ref = 0;
27397 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27398 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27399 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27400 ret_ref = (uintptr_t)ret_var.inner;
27401 if (ret_var.is_owned) {
27402         ret_ref |= 1;
27403 }
27404         return ret_ref;
27405 }
27406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27407         LDKHTLCUpdate arg_conv;
27408         arg_conv.inner = (void*)(arg & (~1));
27409         arg_conv.is_owned = false;
27410         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27411         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
27412         return ret_conv;
27413 }
27414
27415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27416         LDKHTLCUpdate orig_conv;
27417         orig_conv.inner = (void*)(orig & (~1));
27418         orig_conv.is_owned = false;
27419         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27420         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
27421         int64_t ret_ref = 0;
27422         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27423         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27425         ret_ref = (uintptr_t)ret_var.inner;
27426         if (ret_var.is_owned) {
27427                 ret_ref |= 1;
27428         }
27429         return ret_ref;
27430 }
27431
27432 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
27433         LDKHTLCUpdate obj_conv;
27434         obj_conv.inner = (void*)(obj & (~1));
27435         obj_conv.is_owned = false;
27436         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27437         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
27438         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27439         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27440         CVec_u8Z_free(ret_var);
27441         return ret_arr;
27442 }
27443
27444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27445         LDKu8slice ser_ref;
27446         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27447         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27448         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
27449         *ret_conv = HTLCUpdate_read(ser_ref);
27450         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27451         return (int64_t)ret_conv;
27452 }
27453
27454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27455         if ((this_ptr & 1) != 0) return;
27456         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27457         CHECK_ACCESS(this_ptr_ptr);
27458         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
27459         FREE((void*)this_ptr);
27460         Balance_free(this_ptr_conv);
27461 }
27462
27463 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
27464         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27465         *ret_copy = Balance_clone(arg);
27466 int64_t ret_ref = (uintptr_t)ret_copy;
27467         return ret_ref;
27468 }
27469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27470         LDKBalance* arg_conv = (LDKBalance*)arg;
27471         int64_t ret_conv = Balance_clone_ptr(arg_conv);
27472         return ret_conv;
27473 }
27474
27475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27476         LDKBalance* orig_conv = (LDKBalance*)orig;
27477         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27478         *ret_copy = Balance_clone(orig_conv);
27479         int64_t ret_ref = (uintptr_t)ret_copy;
27480         return ret_ref;
27481 }
27482
27483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
27484         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27485         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
27486         int64_t ret_ref = (uintptr_t)ret_copy;
27487         return ret_ref;
27488 }
27489
27490 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) {
27491         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27492         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
27493         int64_t ret_ref = (uintptr_t)ret_copy;
27494         return ret_ref;
27495 }
27496
27497 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) {
27498         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27499         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
27500         int64_t ret_ref = (uintptr_t)ret_copy;
27501         return ret_ref;
27502 }
27503
27504 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) {
27505         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27506         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
27507         int64_t ret_ref = (uintptr_t)ret_copy;
27508         return ret_ref;
27509 }
27510
27511 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27512         LDKBalance* a_conv = (LDKBalance*)a;
27513         LDKBalance* b_conv = (LDKBalance*)b;
27514         jboolean ret_conv = Balance_eq(a_conv, b_conv);
27515         return ret_conv;
27516 }
27517
27518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27519         LDKChannelMonitor this_obj_conv;
27520         this_obj_conv.inner = (void*)(this_obj & (~1));
27521         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27523         ChannelMonitor_free(this_obj_conv);
27524 }
27525
27526 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
27527         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
27528 int64_t ret_ref = 0;
27529 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27530 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27531 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27532 ret_ref = (uintptr_t)ret_var.inner;
27533 if (ret_var.is_owned) {
27534         ret_ref |= 1;
27535 }
27536         return ret_ref;
27537 }
27538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27539         LDKChannelMonitor arg_conv;
27540         arg_conv.inner = (void*)(arg & (~1));
27541         arg_conv.is_owned = false;
27542         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27543         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
27544         return ret_conv;
27545 }
27546
27547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27548         LDKChannelMonitor orig_conv;
27549         orig_conv.inner = (void*)(orig & (~1));
27550         orig_conv.is_owned = false;
27551         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27552         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
27553         int64_t ret_ref = 0;
27554         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27555         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27557         ret_ref = (uintptr_t)ret_var.inner;
27558         if (ret_var.is_owned) {
27559                 ret_ref |= 1;
27560         }
27561         return ret_ref;
27562 }
27563
27564 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27565         LDKChannelMonitor obj_conv;
27566         obj_conv.inner = (void*)(obj & (~1));
27567         obj_conv.is_owned = false;
27568         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27569         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
27570         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27571         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27572         CVec_u8Z_free(ret_var);
27573         return ret_arr;
27574 }
27575
27576 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) {
27577         LDKChannelMonitor this_arg_conv;
27578         this_arg_conv.inner = (void*)(this_arg & (~1));
27579         this_arg_conv.is_owned = false;
27580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27581         LDKChannelMonitorUpdate updates_conv;
27582         updates_conv.inner = (void*)(updates & (~1));
27583         updates_conv.is_owned = false;
27584         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
27585         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27586         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
27587         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
27588         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27589         CHECK_ACCESS(fee_estimator_ptr);
27590         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27591         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27592                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27593                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27594         }
27595         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27596         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
27597         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
27598         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
27599         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
27600         return (int64_t)ret_conv;
27601 }
27602
27603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
27604         LDKChannelMonitor this_arg_conv;
27605         this_arg_conv.inner = (void*)(this_arg & (~1));
27606         this_arg_conv.is_owned = false;
27607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27608         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
27609         return ret_conv;
27610 }
27611
27612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
27613         LDKChannelMonitor this_arg_conv;
27614         this_arg_conv.inner = (void*)(this_arg & (~1));
27615         this_arg_conv.is_owned = false;
27616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27617         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
27618         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
27619         return ((int64_t)ret_conv);
27620 }
27621
27622 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
27623         LDKChannelMonitor this_arg_conv;
27624         this_arg_conv.inner = (void*)(this_arg & (~1));
27625         this_arg_conv.is_owned = false;
27626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27627         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
27628         int64_tArray ret_arr = NULL;
27629         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27630         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27631         for (size_t o = 0; o < ret_var.datalen; o++) {
27632                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
27633                 *ret_conv_40_conv = ret_var.data[o];
27634                 ret_arr_ptr[o] = ((int64_t)ret_conv_40_conv);
27635         }
27636         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27637         FREE(ret_var.data);
27638         return ret_arr;
27639 }
27640
27641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
27642         LDKChannelMonitor this_arg_conv;
27643         this_arg_conv.inner = (void*)(this_arg & (~1));
27644         this_arg_conv.is_owned = false;
27645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27646         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
27647         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
27648         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
27649         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
27650 }
27651
27652 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
27653         LDKChannelMonitor this_arg_conv;
27654         this_arg_conv.inner = (void*)(this_arg & (~1));
27655         this_arg_conv.is_owned = false;
27656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27657         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
27658         int64_tArray ret_arr = NULL;
27659         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27660         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27661         for (size_t o = 0; o < ret_var.datalen; o++) {
27662                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27663                 *ret_conv_14_copy = ret_var.data[o];
27664                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
27665                 ret_arr_ptr[o] = ret_conv_14_ref;
27666         }
27667         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27668         FREE(ret_var.data);
27669         return ret_arr;
27670 }
27671
27672 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
27673         LDKChannelMonitor this_arg_conv;
27674         this_arg_conv.inner = (void*)(this_arg & (~1));
27675         this_arg_conv.is_owned = false;
27676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27677         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
27678         int64_tArray ret_arr = NULL;
27679         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27680         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27681         for (size_t h = 0; h < ret_var.datalen; h++) {
27682                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
27683                 *ret_conv_7_copy = ret_var.data[h];
27684                 int64_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
27685                 ret_arr_ptr[h] = ret_conv_7_ref;
27686         }
27687         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27688         FREE(ret_var.data);
27689         return ret_arr;
27690 }
27691
27692 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1counterparty_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
27693         LDKChannelMonitor this_arg_conv;
27694         this_arg_conv.inner = (void*)(this_arg & (~1));
27695         this_arg_conv.is_owned = false;
27696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27697         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27698         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form);
27699         return ret_arr;
27700 }
27701
27702 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) {
27703         LDKChannelMonitor this_arg_conv;
27704         this_arg_conv.inner = (void*)(this_arg & (~1));
27705         this_arg_conv.is_owned = false;
27706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27707         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27708         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
27709         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
27710         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
27711         jobjectArray ret_arr = NULL;
27712         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
27713         ;
27714         for (size_t i = 0; i < ret_var.datalen; i++) {
27715                 LDKTransaction ret_conv_8_var = ret_var.data[i];
27716                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
27717                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
27718                 Transaction_free(ret_conv_8_var);
27719                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
27720         }
27721         
27722         FREE(ret_var.data);
27723         return ret_arr;
27724 }
27725
27726 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) {
27727         LDKChannelMonitor this_arg_conv;
27728         this_arg_conv.inner = (void*)(this_arg & (~1));
27729         this_arg_conv.is_owned = false;
27730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27731         unsigned char header_arr[80];
27732         CHECK((*env)->GetArrayLength(env, header) == 80);
27733         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27734         unsigned char (*header_ref)[80] = &header_arr;
27735         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
27736         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
27737         if (txdata_constr.datalen > 0)
27738                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
27739         else
27740                 txdata_constr.data = NULL;
27741         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
27742         for (size_t c = 0; c < txdata_constr.datalen; c++) {
27743                 int64_t txdata_conv_28 = txdata_vals[c];
27744                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
27745                 CHECK_ACCESS(txdata_conv_28_ptr);
27746                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
27747                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
27748                 txdata_constr.data[c] = txdata_conv_28_conv;
27749         }
27750         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
27751         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27752         CHECK_ACCESS(broadcaster_ptr);
27753         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27754         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27755                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27756                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27757         }
27758         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27759         CHECK_ACCESS(fee_estimator_ptr);
27760         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27761         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27762                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27763                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27764         }
27765         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27766         CHECK_ACCESS(logger_ptr);
27767         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27768         if (logger_conv.free == LDKLogger_JCalls_free) {
27769                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27770                 LDKLogger_JCalls_cloned(&logger_conv);
27771         }
27772         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);
27773         int64_tArray ret_arr = NULL;
27774         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27775         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27776         for (size_t n = 0; n < ret_var.datalen; n++) {
27777                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
27778                 *ret_conv_39_conv = ret_var.data[n];
27779                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
27780         }
27781         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27782         FREE(ret_var.data);
27783         return ret_arr;
27784 }
27785
27786 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) {
27787         LDKChannelMonitor this_arg_conv;
27788         this_arg_conv.inner = (void*)(this_arg & (~1));
27789         this_arg_conv.is_owned = false;
27790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27791         unsigned char header_arr[80];
27792         CHECK((*env)->GetArrayLength(env, header) == 80);
27793         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27794         unsigned char (*header_ref)[80] = &header_arr;
27795         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27796         CHECK_ACCESS(broadcaster_ptr);
27797         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27798         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27799                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27800                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27801         }
27802         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27803         CHECK_ACCESS(fee_estimator_ptr);
27804         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27805         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27806                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27807                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27808         }
27809         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27810         CHECK_ACCESS(logger_ptr);
27811         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27812         if (logger_conv.free == LDKLogger_JCalls_free) {
27813                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27814                 LDKLogger_JCalls_cloned(&logger_conv);
27815         }
27816         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
27817 }
27818
27819 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) {
27820         LDKChannelMonitor this_arg_conv;
27821         this_arg_conv.inner = (void*)(this_arg & (~1));
27822         this_arg_conv.is_owned = false;
27823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27824         unsigned char header_arr[80];
27825         CHECK((*env)->GetArrayLength(env, header) == 80);
27826         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27827         unsigned char (*header_ref)[80] = &header_arr;
27828         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
27829         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
27830         if (txdata_constr.datalen > 0)
27831                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
27832         else
27833                 txdata_constr.data = NULL;
27834         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
27835         for (size_t c = 0; c < txdata_constr.datalen; c++) {
27836                 int64_t txdata_conv_28 = txdata_vals[c];
27837                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
27838                 CHECK_ACCESS(txdata_conv_28_ptr);
27839                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
27840                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
27841                 txdata_constr.data[c] = txdata_conv_28_conv;
27842         }
27843         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
27844         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27845         CHECK_ACCESS(broadcaster_ptr);
27846         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27847         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27848                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27849                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27850         }
27851         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27852         CHECK_ACCESS(fee_estimator_ptr);
27853         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27854         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27855                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27856                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27857         }
27858         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27859         CHECK_ACCESS(logger_ptr);
27860         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27861         if (logger_conv.free == LDKLogger_JCalls_free) {
27862                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27863                 LDKLogger_JCalls_cloned(&logger_conv);
27864         }
27865         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);
27866         int64_tArray ret_arr = NULL;
27867         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27868         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27869         for (size_t n = 0; n < ret_var.datalen; n++) {
27870                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
27871                 *ret_conv_39_conv = ret_var.data[n];
27872                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
27873         }
27874         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27875         FREE(ret_var.data);
27876         return ret_arr;
27877 }
27878
27879 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) {
27880         LDKChannelMonitor this_arg_conv;
27881         this_arg_conv.inner = (void*)(this_arg & (~1));
27882         this_arg_conv.is_owned = false;
27883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27884         unsigned char txid_arr[32];
27885         CHECK((*env)->GetArrayLength(env, txid) == 32);
27886         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
27887         unsigned char (*txid_ref)[32] = &txid_arr;
27888         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27889         CHECK_ACCESS(broadcaster_ptr);
27890         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27891         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27892                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27893                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27894         }
27895         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27896         CHECK_ACCESS(fee_estimator_ptr);
27897         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27898         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27899                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27900                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27901         }
27902         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27903         CHECK_ACCESS(logger_ptr);
27904         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27905         if (logger_conv.free == LDKLogger_JCalls_free) {
27906                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27907                 LDKLogger_JCalls_cloned(&logger_conv);
27908         }
27909         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
27910 }
27911
27912 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) {
27913         LDKChannelMonitor this_arg_conv;
27914         this_arg_conv.inner = (void*)(this_arg & (~1));
27915         this_arg_conv.is_owned = false;
27916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27917         unsigned char header_arr[80];
27918         CHECK((*env)->GetArrayLength(env, header) == 80);
27919         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27920         unsigned char (*header_ref)[80] = &header_arr;
27921         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27922         CHECK_ACCESS(broadcaster_ptr);
27923         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27924         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27925                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27926                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27927         }
27928         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27929         CHECK_ACCESS(fee_estimator_ptr);
27930         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27931         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27932                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27933                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27934         }
27935         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27936         CHECK_ACCESS(logger_ptr);
27937         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27938         if (logger_conv.free == LDKLogger_JCalls_free) {
27939                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27940                 LDKLogger_JCalls_cloned(&logger_conv);
27941         }
27942         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
27943         int64_tArray ret_arr = NULL;
27944         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27945         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27946         for (size_t n = 0; n < ret_var.datalen; n++) {
27947                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
27948                 *ret_conv_39_conv = ret_var.data[n];
27949                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
27950         }
27951         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27952         FREE(ret_var.data);
27953         return ret_arr;
27954 }
27955
27956 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
27957         LDKChannelMonitor this_arg_conv;
27958         this_arg_conv.inner = (void*)(this_arg & (~1));
27959         this_arg_conv.is_owned = false;
27960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27961         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
27962         jobjectArray ret_arr = NULL;
27963         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
27964         ;
27965         for (size_t i = 0; i < ret_var.datalen; i++) {
27966                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
27967                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
27968                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
27969         }
27970         
27971         FREE(ret_var.data);
27972         return ret_arr;
27973 }
27974
27975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
27976         LDKChannelMonitor this_arg_conv;
27977         this_arg_conv.inner = (void*)(this_arg & (~1));
27978         this_arg_conv.is_owned = false;
27979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27980         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
27981         int64_t ret_ref = 0;
27982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27985         ret_ref = (uintptr_t)ret_var.inner;
27986         if (ret_var.is_owned) {
27987                 ret_ref |= 1;
27988         }
27989         return ret_ref;
27990 }
27991
27992 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
27993         LDKChannelMonitor this_arg_conv;
27994         this_arg_conv.inner = (void*)(this_arg & (~1));
27995         this_arg_conv.is_owned = false;
27996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27997         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
27998         int64_tArray ret_arr = NULL;
27999         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28000         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28001         for (size_t j = 0; j < ret_var.datalen; j++) {
28002                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28003                 *ret_conv_9_copy = ret_var.data[j];
28004                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
28005                 ret_arr_ptr[j] = ret_conv_9_ref;
28006         }
28007         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28008         FREE(ret_var.data);
28009         return ret_arr;
28010 }
28011
28012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
28013         LDKu8slice ser_ref;
28014         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28015         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28016         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
28017         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
28018         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
28019         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
28020         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
28021         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28022         return (int64_t)ret_conv;
28023 }
28024
28025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28026         LDKOutPoint this_obj_conv;
28027         this_obj_conv.inner = (void*)(this_obj & (~1));
28028         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28030         OutPoint_free(this_obj_conv);
28031 }
28032
28033 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
28034         LDKOutPoint this_ptr_conv;
28035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28036         this_ptr_conv.is_owned = false;
28037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28038         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28039         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
28040         return ret_arr;
28041 }
28042
28043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28044         LDKOutPoint this_ptr_conv;
28045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28046         this_ptr_conv.is_owned = false;
28047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28048         LDKThirtyTwoBytes val_ref;
28049         CHECK((*env)->GetArrayLength(env, val) == 32);
28050         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28051         OutPoint_set_txid(&this_ptr_conv, val_ref);
28052 }
28053
28054 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
28055         LDKOutPoint this_ptr_conv;
28056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28057         this_ptr_conv.is_owned = false;
28058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28059         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
28060         return ret_conv;
28061 }
28062
28063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28064         LDKOutPoint this_ptr_conv;
28065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28066         this_ptr_conv.is_owned = false;
28067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28068         OutPoint_set_index(&this_ptr_conv, val);
28069 }
28070
28071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
28072         LDKThirtyTwoBytes txid_arg_ref;
28073         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
28074         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
28075         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
28076         int64_t ret_ref = 0;
28077         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28078         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28080         ret_ref = (uintptr_t)ret_var.inner;
28081         if (ret_var.is_owned) {
28082                 ret_ref |= 1;
28083         }
28084         return ret_ref;
28085 }
28086
28087 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
28088         LDKOutPoint ret_var = OutPoint_clone(arg);
28089 int64_t ret_ref = 0;
28090 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28091 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28092 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28093 ret_ref = (uintptr_t)ret_var.inner;
28094 if (ret_var.is_owned) {
28095         ret_ref |= 1;
28096 }
28097         return ret_ref;
28098 }
28099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28100         LDKOutPoint arg_conv;
28101         arg_conv.inner = (void*)(arg & (~1));
28102         arg_conv.is_owned = false;
28103         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28104         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
28105         return ret_conv;
28106 }
28107
28108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28109         LDKOutPoint orig_conv;
28110         orig_conv.inner = (void*)(orig & (~1));
28111         orig_conv.is_owned = false;
28112         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28113         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
28114         int64_t ret_ref = 0;
28115         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28116         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28118         ret_ref = (uintptr_t)ret_var.inner;
28119         if (ret_var.is_owned) {
28120                 ret_ref |= 1;
28121         }
28122         return ret_ref;
28123 }
28124
28125 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28126         LDKOutPoint a_conv;
28127         a_conv.inner = (void*)(a & (~1));
28128         a_conv.is_owned = false;
28129         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28130         LDKOutPoint b_conv;
28131         b_conv.inner = (void*)(b & (~1));
28132         b_conv.is_owned = false;
28133         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28134         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
28135         return ret_conv;
28136 }
28137
28138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
28139         LDKOutPoint o_conv;
28140         o_conv.inner = (void*)(o & (~1));
28141         o_conv.is_owned = false;
28142         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28143         int64_t ret_conv = OutPoint_hash(&o_conv);
28144         return ret_conv;
28145 }
28146
28147 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
28148         LDKOutPoint this_arg_conv;
28149         this_arg_conv.inner = (void*)(this_arg & (~1));
28150         this_arg_conv.is_owned = false;
28151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28152         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28153         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
28154         return ret_arr;
28155 }
28156
28157 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
28158         LDKOutPoint obj_conv;
28159         obj_conv.inner = (void*)(obj & (~1));
28160         obj_conv.is_owned = false;
28161         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28162         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
28163         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28164         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28165         CVec_u8Z_free(ret_var);
28166         return ret_arr;
28167 }
28168
28169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28170         LDKu8slice ser_ref;
28171         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28172         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28173         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
28174         *ret_conv = OutPoint_read(ser_ref);
28175         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28176         return (int64_t)ret_conv;
28177 }
28178
28179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28180         LDKDelayedPaymentOutputDescriptor this_obj_conv;
28181         this_obj_conv.inner = (void*)(this_obj & (~1));
28182         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28184         DelayedPaymentOutputDescriptor_free(this_obj_conv);
28185 }
28186
28187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28188         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28190         this_ptr_conv.is_owned = false;
28191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28192         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
28193         int64_t ret_ref = 0;
28194         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28195         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28197         ret_ref = (uintptr_t)ret_var.inner;
28198         if (ret_var.is_owned) {
28199                 ret_ref |= 1;
28200         }
28201         return ret_ref;
28202 }
28203
28204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28205         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28207         this_ptr_conv.is_owned = false;
28208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28209         LDKOutPoint val_conv;
28210         val_conv.inner = (void*)(val & (~1));
28211         val_conv.is_owned = (val & 1) || (val == 0);
28212         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28213         val_conv = OutPoint_clone(&val_conv);
28214         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
28215 }
28216
28217 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
28218         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28220         this_ptr_conv.is_owned = false;
28221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28222         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28223         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
28224         return ret_arr;
28225 }
28226
28227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28228         LDKDelayedPaymentOutputDescriptor 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         LDKPublicKey val_ref;
28233         CHECK((*env)->GetArrayLength(env, val) == 33);
28234         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28235         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
28236 }
28237
28238 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
28239         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28241         this_ptr_conv.is_owned = false;
28242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28243         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
28244         return ret_conv;
28245 }
28246
28247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28248         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28250         this_ptr_conv.is_owned = false;
28251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28252         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
28253 }
28254
28255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28256         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28258         this_ptr_conv.is_owned = false;
28259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28260         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28261         CHECK_ACCESS(val_ptr);
28262         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
28263         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
28264         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
28265 }
28266
28267 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28268         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28270         this_ptr_conv.is_owned = false;
28271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28272         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28273         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
28274         return ret_arr;
28275 }
28276
28277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28278         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28280         this_ptr_conv.is_owned = false;
28281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28282         LDKPublicKey val_ref;
28283         CHECK((*env)->GetArrayLength(env, val) == 33);
28284         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28285         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
28286 }
28287
28288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28289         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28291         this_ptr_conv.is_owned = false;
28292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28293         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28294         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
28295         return ret_arr;
28296 }
28297
28298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28299         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28301         this_ptr_conv.is_owned = false;
28302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28303         LDKThirtyTwoBytes val_ref;
28304         CHECK((*env)->GetArrayLength(env, val) == 32);
28305         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28306         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
28307 }
28308
28309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28310         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28312         this_ptr_conv.is_owned = false;
28313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28314         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
28315         return ret_conv;
28316 }
28317
28318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28319         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28321         this_ptr_conv.is_owned = false;
28322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28323         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
28324 }
28325
28326 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) {
28327         LDKOutPoint outpoint_arg_conv;
28328         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
28329         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
28330         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
28331         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
28332         LDKPublicKey per_commitment_point_arg_ref;
28333         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
28334         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
28335         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
28336         CHECK_ACCESS(output_arg_ptr);
28337         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
28338         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
28339         LDKPublicKey revocation_pubkey_arg_ref;
28340         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
28341         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
28342         LDKThirtyTwoBytes channel_keys_id_arg_ref;
28343         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
28344         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
28345         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);
28346         int64_t ret_ref = 0;
28347         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28348         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28350         ret_ref = (uintptr_t)ret_var.inner;
28351         if (ret_var.is_owned) {
28352                 ret_ref |= 1;
28353         }
28354         return ret_ref;
28355 }
28356
28357 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
28358         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
28359 int64_t ret_ref = 0;
28360 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28361 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28362 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28363 ret_ref = (uintptr_t)ret_var.inner;
28364 if (ret_var.is_owned) {
28365         ret_ref |= 1;
28366 }
28367         return ret_ref;
28368 }
28369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28370         LDKDelayedPaymentOutputDescriptor arg_conv;
28371         arg_conv.inner = (void*)(arg & (~1));
28372         arg_conv.is_owned = false;
28373         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28374         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
28375         return ret_conv;
28376 }
28377
28378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28379         LDKDelayedPaymentOutputDescriptor orig_conv;
28380         orig_conv.inner = (void*)(orig & (~1));
28381         orig_conv.is_owned = false;
28382         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28383         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
28384         int64_t ret_ref = 0;
28385         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28386         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28388         ret_ref = (uintptr_t)ret_var.inner;
28389         if (ret_var.is_owned) {
28390                 ret_ref |= 1;
28391         }
28392         return ret_ref;
28393 }
28394
28395 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
28396         LDKDelayedPaymentOutputDescriptor obj_conv;
28397         obj_conv.inner = (void*)(obj & (~1));
28398         obj_conv.is_owned = false;
28399         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28400         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
28401         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28402         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28403         CVec_u8Z_free(ret_var);
28404         return ret_arr;
28405 }
28406
28407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28408         LDKu8slice ser_ref;
28409         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28410         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28411         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
28412         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
28413         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28414         return (int64_t)ret_conv;
28415 }
28416
28417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28418         LDKStaticPaymentOutputDescriptor this_obj_conv;
28419         this_obj_conv.inner = (void*)(this_obj & (~1));
28420         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28422         StaticPaymentOutputDescriptor_free(this_obj_conv);
28423 }
28424
28425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28426         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28428         this_ptr_conv.is_owned = false;
28429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28430         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
28431         int64_t ret_ref = 0;
28432         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28433         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28435         ret_ref = (uintptr_t)ret_var.inner;
28436         if (ret_var.is_owned) {
28437                 ret_ref |= 1;
28438         }
28439         return ret_ref;
28440 }
28441
28442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28443         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28445         this_ptr_conv.is_owned = false;
28446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28447         LDKOutPoint val_conv;
28448         val_conv.inner = (void*)(val & (~1));
28449         val_conv.is_owned = (val & 1) || (val == 0);
28450         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28451         val_conv = OutPoint_clone(&val_conv);
28452         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
28453 }
28454
28455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28456         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28458         this_ptr_conv.is_owned = false;
28459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28460         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28461         CHECK_ACCESS(val_ptr);
28462         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
28463         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
28464         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
28465 }
28466
28467 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28468         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28470         this_ptr_conv.is_owned = false;
28471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28472         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28473         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
28474         return ret_arr;
28475 }
28476
28477 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28478         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28480         this_ptr_conv.is_owned = false;
28481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28482         LDKThirtyTwoBytes val_ref;
28483         CHECK((*env)->GetArrayLength(env, val) == 32);
28484         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28485         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
28486 }
28487
28488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28489         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28491         this_ptr_conv.is_owned = false;
28492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28493         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
28494         return ret_conv;
28495 }
28496
28497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28498         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28500         this_ptr_conv.is_owned = false;
28501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28502         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
28503 }
28504
28505 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) {
28506         LDKOutPoint outpoint_arg_conv;
28507         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
28508         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
28509         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
28510         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
28511         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
28512         CHECK_ACCESS(output_arg_ptr);
28513         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
28514         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
28515         LDKThirtyTwoBytes channel_keys_id_arg_ref;
28516         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
28517         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
28518         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
28519         int64_t ret_ref = 0;
28520         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28521         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28522         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28523         ret_ref = (uintptr_t)ret_var.inner;
28524         if (ret_var.is_owned) {
28525                 ret_ref |= 1;
28526         }
28527         return ret_ref;
28528 }
28529
28530 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
28531         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
28532 int64_t ret_ref = 0;
28533 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28534 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28535 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28536 ret_ref = (uintptr_t)ret_var.inner;
28537 if (ret_var.is_owned) {
28538         ret_ref |= 1;
28539 }
28540         return ret_ref;
28541 }
28542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28543         LDKStaticPaymentOutputDescriptor arg_conv;
28544         arg_conv.inner = (void*)(arg & (~1));
28545         arg_conv.is_owned = false;
28546         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28547         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
28548         return ret_conv;
28549 }
28550
28551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28552         LDKStaticPaymentOutputDescriptor orig_conv;
28553         orig_conv.inner = (void*)(orig & (~1));
28554         orig_conv.is_owned = false;
28555         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28556         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
28557         int64_t ret_ref = 0;
28558         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28559         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28561         ret_ref = (uintptr_t)ret_var.inner;
28562         if (ret_var.is_owned) {
28563                 ret_ref |= 1;
28564         }
28565         return ret_ref;
28566 }
28567
28568 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
28569         LDKStaticPaymentOutputDescriptor obj_conv;
28570         obj_conv.inner = (void*)(obj & (~1));
28571         obj_conv.is_owned = false;
28572         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28573         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
28574         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28575         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28576         CVec_u8Z_free(ret_var);
28577         return ret_arr;
28578 }
28579
28580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28581         LDKu8slice ser_ref;
28582         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28583         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28584         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
28585         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
28586         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28587         return (int64_t)ret_conv;
28588 }
28589
28590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28591         if ((this_ptr & 1) != 0) return;
28592         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28593         CHECK_ACCESS(this_ptr_ptr);
28594         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
28595         FREE((void*)this_ptr);
28596         SpendableOutputDescriptor_free(this_ptr_conv);
28597 }
28598
28599 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
28600         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28601         *ret_copy = SpendableOutputDescriptor_clone(arg);
28602 int64_t ret_ref = (uintptr_t)ret_copy;
28603         return ret_ref;
28604 }
28605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28606         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
28607         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
28608         return ret_conv;
28609 }
28610
28611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28612         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
28613         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28614         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
28615         int64_t ret_ref = (uintptr_t)ret_copy;
28616         return ret_ref;
28617 }
28618
28619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
28620         LDKOutPoint outpoint_conv;
28621         outpoint_conv.inner = (void*)(outpoint & (~1));
28622         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
28623         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
28624         outpoint_conv = OutPoint_clone(&outpoint_conv);
28625         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
28626         CHECK_ACCESS(output_ptr);
28627         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
28628         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
28629         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28630         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
28631         int64_t ret_ref = (uintptr_t)ret_copy;
28632         return ret_ref;
28633 }
28634
28635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
28636         LDKDelayedPaymentOutputDescriptor a_conv;
28637         a_conv.inner = (void*)(a & (~1));
28638         a_conv.is_owned = (a & 1) || (a == 0);
28639         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28640         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
28641         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28642         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
28643         int64_t ret_ref = (uintptr_t)ret_copy;
28644         return ret_ref;
28645 }
28646
28647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
28648         LDKStaticPaymentOutputDescriptor a_conv;
28649         a_conv.inner = (void*)(a & (~1));
28650         a_conv.is_owned = (a & 1) || (a == 0);
28651         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28652         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
28653         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
28654         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
28655         int64_t ret_ref = (uintptr_t)ret_copy;
28656         return ret_ref;
28657 }
28658
28659 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
28660         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
28661         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
28662         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28663         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28664         CVec_u8Z_free(ret_var);
28665         return ret_arr;
28666 }
28667
28668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28669         LDKu8slice ser_ref;
28670         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28671         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28672         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
28673         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
28674         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28675         return (int64_t)ret_conv;
28676 }
28677
28678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28679         if ((this_ptr & 1) != 0) return;
28680         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28681         CHECK_ACCESS(this_ptr_ptr);
28682         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
28683         FREE((void*)this_ptr);
28684         BaseSign_free(this_ptr_conv);
28685 }
28686
28687 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
28688         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
28689         *ret_ret = Sign_clone(arg);
28690         return (int64_t)ret_ret;
28691 }
28692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28693         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
28694         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
28695         LDKSign* arg_conv = (LDKSign*)arg_ptr;
28696         int64_t ret_conv = Sign_clone_ptr(arg_conv);
28697         return ret_conv;
28698 }
28699
28700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28701         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
28702         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
28703         LDKSign* orig_conv = (LDKSign*)orig_ptr;
28704         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
28705         *ret_ret = Sign_clone(orig_conv);
28706         return (int64_t)ret_ret;
28707 }
28708
28709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28710         if ((this_ptr & 1) != 0) return;
28711         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28712         CHECK_ACCESS(this_ptr_ptr);
28713         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
28714         FREE((void*)this_ptr);
28715         Sign_free(this_ptr_conv);
28716 }
28717
28718 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28719         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
28720         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
28721         return ret_conv;
28722 }
28723
28724 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
28725         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
28726         return ret_conv;
28727 }
28728
28729 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
28730         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
28731         return ret_conv;
28732 }
28733
28734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28735         if ((this_ptr & 1) != 0) return;
28736         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28737         CHECK_ACCESS(this_ptr_ptr);
28738         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
28739         FREE((void*)this_ptr);
28740         KeysInterface_free(this_ptr_conv);
28741 }
28742
28743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28744         LDKInMemorySigner this_obj_conv;
28745         this_obj_conv.inner = (void*)(this_obj & (~1));
28746         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28748         InMemorySigner_free(this_obj_conv);
28749 }
28750
28751 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28752         LDKInMemorySigner this_ptr_conv;
28753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28754         this_ptr_conv.is_owned = false;
28755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28756         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28757         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
28758         return ret_arr;
28759 }
28760
28761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28762         LDKInMemorySigner this_ptr_conv;
28763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28764         this_ptr_conv.is_owned = false;
28765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28766         LDKSecretKey val_ref;
28767         CHECK((*env)->GetArrayLength(env, val) == 32);
28768         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28769         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
28770 }
28771
28772 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28773         LDKInMemorySigner this_ptr_conv;
28774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28775         this_ptr_conv.is_owned = false;
28776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28777         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28778         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
28779         return ret_arr;
28780 }
28781
28782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28783         LDKInMemorySigner this_ptr_conv;
28784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28785         this_ptr_conv.is_owned = false;
28786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28787         LDKSecretKey val_ref;
28788         CHECK((*env)->GetArrayLength(env, val) == 32);
28789         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28790         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
28791 }
28792
28793 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28794         LDKInMemorySigner this_ptr_conv;
28795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28796         this_ptr_conv.is_owned = false;
28797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28798         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28799         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
28800         return ret_arr;
28801 }
28802
28803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28804         LDKInMemorySigner this_ptr_conv;
28805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28806         this_ptr_conv.is_owned = false;
28807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28808         LDKSecretKey val_ref;
28809         CHECK((*env)->GetArrayLength(env, val) == 32);
28810         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28811         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
28812 }
28813
28814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28815         LDKInMemorySigner this_ptr_conv;
28816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28817         this_ptr_conv.is_owned = false;
28818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28819         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28820         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
28821         return ret_arr;
28822 }
28823
28824 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) {
28825         LDKInMemorySigner this_ptr_conv;
28826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28827         this_ptr_conv.is_owned = false;
28828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28829         LDKSecretKey val_ref;
28830         CHECK((*env)->GetArrayLength(env, val) == 32);
28831         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28832         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
28833 }
28834
28835 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28836         LDKInMemorySigner this_ptr_conv;
28837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28838         this_ptr_conv.is_owned = false;
28839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28840         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28841         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
28842         return ret_arr;
28843 }
28844
28845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28846         LDKInMemorySigner this_ptr_conv;
28847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28848         this_ptr_conv.is_owned = false;
28849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28850         LDKSecretKey val_ref;
28851         CHECK((*env)->GetArrayLength(env, val) == 32);
28852         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28853         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
28854 }
28855
28856 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
28857         LDKInMemorySigner this_ptr_conv;
28858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28859         this_ptr_conv.is_owned = false;
28860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28861         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28862         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
28863         return ret_arr;
28864 }
28865
28866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28867         LDKInMemorySigner this_ptr_conv;
28868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28869         this_ptr_conv.is_owned = false;
28870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28871         LDKThirtyTwoBytes val_ref;
28872         CHECK((*env)->GetArrayLength(env, val) == 32);
28873         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28874         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
28875 }
28876
28877 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
28878         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
28879 int64_t ret_ref = 0;
28880 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28881 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28882 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28883 ret_ref = (uintptr_t)ret_var.inner;
28884 if (ret_var.is_owned) {
28885         ret_ref |= 1;
28886 }
28887         return ret_ref;
28888 }
28889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28890         LDKInMemorySigner arg_conv;
28891         arg_conv.inner = (void*)(arg & (~1));
28892         arg_conv.is_owned = false;
28893         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28894         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
28895         return ret_conv;
28896 }
28897
28898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28899         LDKInMemorySigner orig_conv;
28900         orig_conv.inner = (void*)(orig & (~1));
28901         orig_conv.is_owned = false;
28902         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28903         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
28904         int64_t ret_ref = 0;
28905         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28906         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28908         ret_ref = (uintptr_t)ret_var.inner;
28909         if (ret_var.is_owned) {
28910                 ret_ref |= 1;
28911         }
28912         return ret_ref;
28913 }
28914
28915 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) {
28916         LDKSecretKey node_secret_ref;
28917         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
28918         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
28919         LDKSecretKey funding_key_ref;
28920         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
28921         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
28922         LDKSecretKey revocation_base_key_ref;
28923         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
28924         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
28925         LDKSecretKey payment_key_ref;
28926         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
28927         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
28928         LDKSecretKey delayed_payment_base_key_ref;
28929         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
28930         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
28931         LDKSecretKey htlc_base_key_ref;
28932         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
28933         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
28934         LDKThirtyTwoBytes commitment_seed_ref;
28935         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
28936         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
28937         LDKThirtyTwoBytes channel_keys_id_ref;
28938         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
28939         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
28940         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);
28941         int64_t ret_ref = 0;
28942         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28943         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28945         ret_ref = (uintptr_t)ret_var.inner;
28946         if (ret_var.is_owned) {
28947                 ret_ref |= 1;
28948         }
28949         return ret_ref;
28950 }
28951
28952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
28953         LDKInMemorySigner this_arg_conv;
28954         this_arg_conv.inner = (void*)(this_arg & (~1));
28955         this_arg_conv.is_owned = false;
28956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28957         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
28958         int64_t ret_ref = 0;
28959         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28960         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28961         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28962         ret_ref = (uintptr_t)ret_var.inner;
28963         if (ret_var.is_owned) {
28964                 ret_ref |= 1;
28965         }
28966         return ret_ref;
28967 }
28968
28969 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
28970         LDKInMemorySigner this_arg_conv;
28971         this_arg_conv.inner = (void*)(this_arg & (~1));
28972         this_arg_conv.is_owned = false;
28973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28974         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
28975         return ret_conv;
28976 }
28977
28978 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
28979         LDKInMemorySigner this_arg_conv;
28980         this_arg_conv.inner = (void*)(this_arg & (~1));
28981         this_arg_conv.is_owned = false;
28982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28983         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
28984         return ret_conv;
28985 }
28986
28987 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
28988         LDKInMemorySigner this_arg_conv;
28989         this_arg_conv.inner = (void*)(this_arg & (~1));
28990         this_arg_conv.is_owned = false;
28991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28992         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
28993         return ret_conv;
28994 }
28995
28996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
28997         LDKInMemorySigner this_arg_conv;
28998         this_arg_conv.inner = (void*)(this_arg & (~1));
28999         this_arg_conv.is_owned = false;
29000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29001         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
29002         int64_t ret_ref = 0;
29003         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29004         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29006         ret_ref = (uintptr_t)ret_var.inner;
29007         if (ret_var.is_owned) {
29008                 ret_ref |= 1;
29009         }
29010         return ret_ref;
29011 }
29012
29013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
29014         LDKInMemorySigner this_arg_conv;
29015         this_arg_conv.inner = (void*)(this_arg & (~1));
29016         this_arg_conv.is_owned = false;
29017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29018         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
29019         int64_t ret_ref = 0;
29020         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29021         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29023         ret_ref = (uintptr_t)ret_var.inner;
29024         if (ret_var.is_owned) {
29025                 ret_ref |= 1;
29026         }
29027         return ret_ref;
29028 }
29029
29030 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
29031         LDKInMemorySigner this_arg_conv;
29032         this_arg_conv.inner = (void*)(this_arg & (~1));
29033         this_arg_conv.is_owned = false;
29034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29035         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
29036         return ret_conv;
29037 }
29038
29039 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) {
29040         LDKInMemorySigner this_arg_conv;
29041         this_arg_conv.inner = (void*)(this_arg & (~1));
29042         this_arg_conv.is_owned = false;
29043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29044         LDKTransaction spend_tx_ref;
29045         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
29046         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
29047         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
29048         spend_tx_ref.data_is_owned = true;
29049         LDKStaticPaymentOutputDescriptor descriptor_conv;
29050         descriptor_conv.inner = (void*)(descriptor & (~1));
29051         descriptor_conv.is_owned = false;
29052         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
29053         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
29054         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
29055         return (int64_t)ret_conv;
29056 }
29057
29058 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) {
29059         LDKInMemorySigner this_arg_conv;
29060         this_arg_conv.inner = (void*)(this_arg & (~1));
29061         this_arg_conv.is_owned = false;
29062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29063         LDKTransaction spend_tx_ref;
29064         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
29065         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
29066         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
29067         spend_tx_ref.data_is_owned = true;
29068         LDKDelayedPaymentOutputDescriptor descriptor_conv;
29069         descriptor_conv.inner = (void*)(descriptor & (~1));
29070         descriptor_conv.is_owned = false;
29071         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
29072         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
29073         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
29074         return (int64_t)ret_conv;
29075 }
29076
29077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
29078         LDKInMemorySigner this_arg_conv;
29079         this_arg_conv.inner = (void*)(this_arg & (~1));
29080         this_arg_conv.is_owned = false;
29081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29082         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
29083         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
29084         return (int64_t)ret_ret;
29085 }
29086
29087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
29088         LDKInMemorySigner this_arg_conv;
29089         this_arg_conv.inner = (void*)(this_arg & (~1));
29090         this_arg_conv.is_owned = false;
29091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29092         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
29093         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
29094         return (int64_t)ret_ret;
29095 }
29096
29097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
29098         LDKInMemorySigner obj_conv;
29099         obj_conv.inner = (void*)(obj & (~1));
29100         obj_conv.is_owned = false;
29101         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29102         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
29103         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29104         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29105         CVec_u8Z_free(ret_var);
29106         return ret_arr;
29107 }
29108
29109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
29110         LDKu8slice ser_ref;
29111         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29112         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29113         LDKSecretKey arg_ref;
29114         CHECK((*env)->GetArrayLength(env, arg) == 32);
29115         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
29116         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
29117         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
29118         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29119         return (int64_t)ret_conv;
29120 }
29121
29122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29123         LDKKeysManager this_obj_conv;
29124         this_obj_conv.inner = (void*)(this_obj & (~1));
29125         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29127         KeysManager_free(this_obj_conv);
29128 }
29129
29130 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) {
29131         unsigned char seed_arr[32];
29132         CHECK((*env)->GetArrayLength(env, seed) == 32);
29133         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
29134         unsigned char (*seed_ref)[32] = &seed_arr;
29135         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
29136         int64_t ret_ref = 0;
29137         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29138         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29139         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29140         ret_ref = (uintptr_t)ret_var.inner;
29141         if (ret_var.is_owned) {
29142                 ret_ref |= 1;
29143         }
29144         return ret_ref;
29145 }
29146
29147 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) {
29148         LDKKeysManager this_arg_conv;
29149         this_arg_conv.inner = (void*)(this_arg & (~1));
29150         this_arg_conv.is_owned = false;
29151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29152         unsigned char params_arr[32];
29153         CHECK((*env)->GetArrayLength(env, params) == 32);
29154         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
29155         unsigned char (*params_ref)[32] = &params_arr;
29156         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
29157         int64_t ret_ref = 0;
29158         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29159         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29161         ret_ref = (uintptr_t)ret_var.inner;
29162         if (ret_var.is_owned) {
29163                 ret_ref |= 1;
29164         }
29165         return ret_ref;
29166 }
29167
29168 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) {
29169         LDKKeysManager this_arg_conv;
29170         this_arg_conv.inner = (void*)(this_arg & (~1));
29171         this_arg_conv.is_owned = false;
29172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29173         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
29174         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
29175         if (descriptors_constr.datalen > 0)
29176                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
29177         else
29178                 descriptors_constr.data = NULL;
29179         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
29180         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
29181                 int64_t descriptors_conv_27 = descriptors_vals[b];
29182                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
29183                 CHECK_ACCESS(descriptors_conv_27_ptr);
29184                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
29185                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
29186                 descriptors_constr.data[b] = descriptors_conv_27_conv;
29187         }
29188         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
29189         LDKCVec_TxOutZ outputs_constr;
29190         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
29191         if (outputs_constr.datalen > 0)
29192                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
29193         else
29194                 outputs_constr.data = NULL;
29195         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
29196         for (size_t h = 0; h < outputs_constr.datalen; h++) {
29197                 int64_t outputs_conv_7 = outputs_vals[h];
29198                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
29199                 CHECK_ACCESS(outputs_conv_7_ptr);
29200                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
29201                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
29202                 outputs_constr.data[h] = outputs_conv_7_conv;
29203         }
29204         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
29205         LDKCVec_u8Z change_destination_script_ref;
29206         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
29207         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
29208         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
29209         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
29210         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
29211         return (int64_t)ret_conv;
29212 }
29213
29214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
29215         LDKKeysManager this_arg_conv;
29216         this_arg_conv.inner = (void*)(this_arg & (~1));
29217         this_arg_conv.is_owned = false;
29218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29219         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
29220         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
29221         return (int64_t)ret_ret;
29222 }
29223
29224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29225         LDKPhantomKeysManager this_obj_conv;
29226         this_obj_conv.inner = (void*)(this_obj & (~1));
29227         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29229         PhantomKeysManager_free(this_obj_conv);
29230 }
29231
29232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
29233         LDKPhantomKeysManager this_arg_conv;
29234         this_arg_conv.inner = (void*)(this_arg & (~1));
29235         this_arg_conv.is_owned = false;
29236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29237         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
29238         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
29239         return (int64_t)ret_ret;
29240 }
29241
29242 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) {
29243         unsigned char seed_arr[32];
29244         CHECK((*env)->GetArrayLength(env, seed) == 32);
29245         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
29246         unsigned char (*seed_ref)[32] = &seed_arr;
29247         unsigned char cross_node_seed_arr[32];
29248         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
29249         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
29250         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
29251         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
29252         int64_t ret_ref = 0;
29253         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29254         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29256         ret_ref = (uintptr_t)ret_var.inner;
29257         if (ret_var.is_owned) {
29258                 ret_ref |= 1;
29259         }
29260         return ret_ref;
29261 }
29262
29263 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) {
29264         LDKPhantomKeysManager this_arg_conv;
29265         this_arg_conv.inner = (void*)(this_arg & (~1));
29266         this_arg_conv.is_owned = false;
29267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29268         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
29269         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
29270         if (descriptors_constr.datalen > 0)
29271                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
29272         else
29273                 descriptors_constr.data = NULL;
29274         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
29275         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
29276                 int64_t descriptors_conv_27 = descriptors_vals[b];
29277                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
29278                 CHECK_ACCESS(descriptors_conv_27_ptr);
29279                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
29280                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
29281                 descriptors_constr.data[b] = descriptors_conv_27_conv;
29282         }
29283         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
29284         LDKCVec_TxOutZ outputs_constr;
29285         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
29286         if (outputs_constr.datalen > 0)
29287                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
29288         else
29289                 outputs_constr.data = NULL;
29290         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
29291         for (size_t h = 0; h < outputs_constr.datalen; h++) {
29292                 int64_t outputs_conv_7 = outputs_vals[h];
29293                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
29294                 CHECK_ACCESS(outputs_conv_7_ptr);
29295                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
29296                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
29297                 outputs_constr.data[h] = outputs_conv_7_conv;
29298         }
29299         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
29300         LDKCVec_u8Z change_destination_script_ref;
29301         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
29302         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
29303         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
29304         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
29305         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
29306         return (int64_t)ret_conv;
29307 }
29308
29309 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) {
29310         LDKPhantomKeysManager this_arg_conv;
29311         this_arg_conv.inner = (void*)(this_arg & (~1));
29312         this_arg_conv.is_owned = false;
29313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29314         unsigned char params_arr[32];
29315         CHECK((*env)->GetArrayLength(env, params) == 32);
29316         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
29317         unsigned char (*params_ref)[32] = &params_arr;
29318         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
29319         int64_t ret_ref = 0;
29320         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29321         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29323         ret_ref = (uintptr_t)ret_var.inner;
29324         if (ret_var.is_owned) {
29325                 ret_ref |= 1;
29326         }
29327         return ret_ref;
29328 }
29329
29330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29331         LDKChannelManager this_obj_conv;
29332         this_obj_conv.inner = (void*)(this_obj & (~1));
29333         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29335         ChannelManager_free(this_obj_conv);
29336 }
29337
29338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29339         LDKChainParameters this_obj_conv;
29340         this_obj_conv.inner = (void*)(this_obj & (~1));
29341         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29343         ChainParameters_free(this_obj_conv);
29344 }
29345
29346 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
29347         LDKChainParameters this_ptr_conv;
29348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29349         this_ptr_conv.is_owned = false;
29350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29351         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
29352         return ret_conv;
29353 }
29354
29355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
29356         LDKChainParameters this_ptr_conv;
29357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29358         this_ptr_conv.is_owned = false;
29359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29360         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
29361         ChainParameters_set_network(&this_ptr_conv, val_conv);
29362 }
29363
29364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
29365         LDKChainParameters this_ptr_conv;
29366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29367         this_ptr_conv.is_owned = false;
29368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29369         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
29370         int64_t ret_ref = 0;
29371         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29372         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29374         ret_ref = (uintptr_t)ret_var.inner;
29375         if (ret_var.is_owned) {
29376                 ret_ref |= 1;
29377         }
29378         return ret_ref;
29379 }
29380
29381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29382         LDKChainParameters this_ptr_conv;
29383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29384         this_ptr_conv.is_owned = false;
29385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29386         LDKBestBlock val_conv;
29387         val_conv.inner = (void*)(val & (~1));
29388         val_conv.is_owned = (val & 1) || (val == 0);
29389         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29390         val_conv = BestBlock_clone(&val_conv);
29391         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
29392 }
29393
29394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
29395         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
29396         LDKBestBlock best_block_arg_conv;
29397         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
29398         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
29399         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
29400         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
29401         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
29402         int64_t ret_ref = 0;
29403         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29404         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29406         ret_ref = (uintptr_t)ret_var.inner;
29407         if (ret_var.is_owned) {
29408                 ret_ref |= 1;
29409         }
29410         return ret_ref;
29411 }
29412
29413 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
29414         LDKChainParameters ret_var = ChainParameters_clone(arg);
29415 int64_t ret_ref = 0;
29416 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29417 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29418 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29419 ret_ref = (uintptr_t)ret_var.inner;
29420 if (ret_var.is_owned) {
29421         ret_ref |= 1;
29422 }
29423         return ret_ref;
29424 }
29425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29426         LDKChainParameters arg_conv;
29427         arg_conv.inner = (void*)(arg & (~1));
29428         arg_conv.is_owned = false;
29429         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29430         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
29431         return ret_conv;
29432 }
29433
29434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29435         LDKChainParameters orig_conv;
29436         orig_conv.inner = (void*)(orig & (~1));
29437         orig_conv.is_owned = false;
29438         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29439         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
29440         int64_t ret_ref = 0;
29441         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29442         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29444         ret_ref = (uintptr_t)ret_var.inner;
29445         if (ret_var.is_owned) {
29446                 ret_ref |= 1;
29447         }
29448         return ret_ref;
29449 }
29450
29451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29452         LDKCounterpartyForwardingInfo this_obj_conv;
29453         this_obj_conv.inner = (void*)(this_obj & (~1));
29454         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29456         CounterpartyForwardingInfo_free(this_obj_conv);
29457 }
29458
29459 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29460         LDKCounterpartyForwardingInfo this_ptr_conv;
29461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29462         this_ptr_conv.is_owned = false;
29463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29464         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
29465         return ret_conv;
29466 }
29467
29468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29469         LDKCounterpartyForwardingInfo this_ptr_conv;
29470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29471         this_ptr_conv.is_owned = false;
29472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29473         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
29474 }
29475
29476 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
29477         LDKCounterpartyForwardingInfo this_ptr_conv;
29478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29479         this_ptr_conv.is_owned = false;
29480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29481         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
29482         return ret_conv;
29483 }
29484
29485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29486         LDKCounterpartyForwardingInfo this_ptr_conv;
29487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29488         this_ptr_conv.is_owned = false;
29489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29490         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
29491 }
29492
29493 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
29494         LDKCounterpartyForwardingInfo this_ptr_conv;
29495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29496         this_ptr_conv.is_owned = false;
29497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29498         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
29499         return ret_conv;
29500 }
29501
29502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29503         LDKCounterpartyForwardingInfo this_ptr_conv;
29504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29505         this_ptr_conv.is_owned = false;
29506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29507         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
29508 }
29509
29510 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) {
29511         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
29512         int64_t ret_ref = 0;
29513         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29514         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29516         ret_ref = (uintptr_t)ret_var.inner;
29517         if (ret_var.is_owned) {
29518                 ret_ref |= 1;
29519         }
29520         return ret_ref;
29521 }
29522
29523 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
29524         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
29525 int64_t ret_ref = 0;
29526 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29527 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29528 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29529 ret_ref = (uintptr_t)ret_var.inner;
29530 if (ret_var.is_owned) {
29531         ret_ref |= 1;
29532 }
29533         return ret_ref;
29534 }
29535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29536         LDKCounterpartyForwardingInfo arg_conv;
29537         arg_conv.inner = (void*)(arg & (~1));
29538         arg_conv.is_owned = false;
29539         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29540         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
29541         return ret_conv;
29542 }
29543
29544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29545         LDKCounterpartyForwardingInfo orig_conv;
29546         orig_conv.inner = (void*)(orig & (~1));
29547         orig_conv.is_owned = false;
29548         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29549         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
29550         int64_t ret_ref = 0;
29551         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29552         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29554         ret_ref = (uintptr_t)ret_var.inner;
29555         if (ret_var.is_owned) {
29556                 ret_ref |= 1;
29557         }
29558         return ret_ref;
29559 }
29560
29561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29562         LDKChannelCounterparty this_obj_conv;
29563         this_obj_conv.inner = (void*)(this_obj & (~1));
29564         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29566         ChannelCounterparty_free(this_obj_conv);
29567 }
29568
29569 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29570         LDKChannelCounterparty this_ptr_conv;
29571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29572         this_ptr_conv.is_owned = false;
29573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29574         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29575         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
29576         return ret_arr;
29577 }
29578
29579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29580         LDKChannelCounterparty 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         LDKPublicKey val_ref;
29585         CHECK((*env)->GetArrayLength(env, val) == 33);
29586         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29587         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
29588 }
29589
29590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
29591         LDKChannelCounterparty this_ptr_conv;
29592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29593         this_ptr_conv.is_owned = false;
29594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29595         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
29596         int64_t ret_ref = 0;
29597         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29598         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29600         ret_ref = (uintptr_t)ret_var.inner;
29601         if (ret_var.is_owned) {
29602                 ret_ref |= 1;
29603         }
29604         return ret_ref;
29605 }
29606
29607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29608         LDKChannelCounterparty this_ptr_conv;
29609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29610         this_ptr_conv.is_owned = false;
29611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29612         LDKInitFeatures val_conv;
29613         val_conv.inner = (void*)(val & (~1));
29614         val_conv.is_owned = (val & 1) || (val == 0);
29615         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29616         val_conv = InitFeatures_clone(&val_conv);
29617         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
29618 }
29619
29620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
29621         LDKChannelCounterparty this_ptr_conv;
29622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29623         this_ptr_conv.is_owned = false;
29624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29625         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
29626         return ret_conv;
29627 }
29628
29629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29630         LDKChannelCounterparty 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         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
29635 }
29636
29637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
29638         LDKChannelCounterparty this_ptr_conv;
29639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29640         this_ptr_conv.is_owned = false;
29641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29642         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
29643         int64_t ret_ref = 0;
29644         if ((uintptr_t)ret_var.inner > 4096) {
29645                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29646                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29648                 ret_ref = (uintptr_t)ret_var.inner;
29649                 if (ret_var.is_owned) {
29650                         ret_ref |= 1;
29651                 }
29652         }
29653         return ret_ref;
29654 }
29655
29656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29657         LDKChannelCounterparty this_ptr_conv;
29658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29659         this_ptr_conv.is_owned = false;
29660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29661         LDKCounterpartyForwardingInfo val_conv;
29662         val_conv.inner = (void*)(val & (~1));
29663         val_conv.is_owned = (val & 1) || (val == 0);
29664         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29665         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
29666         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
29667 }
29668
29669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29670         LDKChannelCounterparty this_ptr_conv;
29671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29672         this_ptr_conv.is_owned = false;
29673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29674         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29675         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
29676         int64_t ret_ref = (uintptr_t)ret_copy;
29677         return ret_ref;
29678 }
29679
29680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29681         LDKChannelCounterparty this_ptr_conv;
29682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29683         this_ptr_conv.is_owned = false;
29684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29685         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29686         CHECK_ACCESS(val_ptr);
29687         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29688         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29689         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
29690 }
29691
29692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29693         LDKChannelCounterparty this_ptr_conv;
29694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29695         this_ptr_conv.is_owned = false;
29696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29697         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29698         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
29699         int64_t ret_ref = (uintptr_t)ret_copy;
29700         return ret_ref;
29701 }
29702
29703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29704         LDKChannelCounterparty this_ptr_conv;
29705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29706         this_ptr_conv.is_owned = false;
29707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29708         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29709         CHECK_ACCESS(val_ptr);
29710         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29711         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29712         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
29713 }
29714
29715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1new(JNIEnv *env, jclass clz, int8_tArray node_id_arg, int64_t features_arg, int64_t unspendable_punishment_reserve_arg, int64_t forwarding_info_arg, int64_t outbound_htlc_minimum_msat_arg, int64_t outbound_htlc_maximum_msat_arg) {
29716         LDKPublicKey node_id_arg_ref;
29717         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
29718         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
29719         LDKInitFeatures features_arg_conv;
29720         features_arg_conv.inner = (void*)(features_arg & (~1));
29721         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
29722         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
29723         features_arg_conv = InitFeatures_clone(&features_arg_conv);
29724         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
29725         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
29726         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
29727         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
29728         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
29729         void* outbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1);
29730         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
29731         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
29732         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1));
29733         void* outbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1);
29734         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
29735         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
29736         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1));
29737         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv, outbound_htlc_minimum_msat_arg_conv, outbound_htlc_maximum_msat_arg_conv);
29738         int64_t ret_ref = 0;
29739         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29740         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29742         ret_ref = (uintptr_t)ret_var.inner;
29743         if (ret_var.is_owned) {
29744                 ret_ref |= 1;
29745         }
29746         return ret_ref;
29747 }
29748
29749 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
29750         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
29751 int64_t ret_ref = 0;
29752 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29753 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29754 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29755 ret_ref = (uintptr_t)ret_var.inner;
29756 if (ret_var.is_owned) {
29757         ret_ref |= 1;
29758 }
29759         return ret_ref;
29760 }
29761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29762         LDKChannelCounterparty arg_conv;
29763         arg_conv.inner = (void*)(arg & (~1));
29764         arg_conv.is_owned = false;
29765         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29766         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
29767         return ret_conv;
29768 }
29769
29770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29771         LDKChannelCounterparty orig_conv;
29772         orig_conv.inner = (void*)(orig & (~1));
29773         orig_conv.is_owned = false;
29774         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29775         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
29776         int64_t ret_ref = 0;
29777         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29778         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29779         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29780         ret_ref = (uintptr_t)ret_var.inner;
29781         if (ret_var.is_owned) {
29782                 ret_ref |= 1;
29783         }
29784         return ret_ref;
29785 }
29786
29787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29788         LDKChannelDetails this_obj_conv;
29789         this_obj_conv.inner = (void*)(this_obj & (~1));
29790         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29792         ChannelDetails_free(this_obj_conv);
29793 }
29794
29795 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29796         LDKChannelDetails this_ptr_conv;
29797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29798         this_ptr_conv.is_owned = false;
29799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29800         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29801         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
29802         return ret_arr;
29803 }
29804
29805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29806         LDKChannelDetails this_ptr_conv;
29807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29808         this_ptr_conv.is_owned = false;
29809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29810         LDKThirtyTwoBytes val_ref;
29811         CHECK((*env)->GetArrayLength(env, val) == 32);
29812         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29813         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
29814 }
29815
29816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
29817         LDKChannelDetails this_ptr_conv;
29818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29819         this_ptr_conv.is_owned = false;
29820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29821         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
29822         int64_t ret_ref = 0;
29823         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29824         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29826         ret_ref = (uintptr_t)ret_var.inner;
29827         if (ret_var.is_owned) {
29828                 ret_ref |= 1;
29829         }
29830         return ret_ref;
29831 }
29832
29833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29834         LDKChannelDetails this_ptr_conv;
29835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29836         this_ptr_conv.is_owned = false;
29837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29838         LDKChannelCounterparty val_conv;
29839         val_conv.inner = (void*)(val & (~1));
29840         val_conv.is_owned = (val & 1) || (val == 0);
29841         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29842         val_conv = ChannelCounterparty_clone(&val_conv);
29843         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
29844 }
29845
29846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
29847         LDKChannelDetails this_ptr_conv;
29848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29849         this_ptr_conv.is_owned = false;
29850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29851         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
29852         int64_t ret_ref = 0;
29853         if ((uintptr_t)ret_var.inner > 4096) {
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         }
29862         return ret_ref;
29863 }
29864
29865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29866         LDKChannelDetails this_ptr_conv;
29867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29868         this_ptr_conv.is_owned = false;
29869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29870         LDKOutPoint val_conv;
29871         val_conv.inner = (void*)(val & (~1));
29872         val_conv.is_owned = (val & 1) || (val == 0);
29873         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29874         val_conv = OutPoint_clone(&val_conv);
29875         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
29876 }
29877
29878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
29879         LDKChannelDetails this_ptr_conv;
29880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29881         this_ptr_conv.is_owned = false;
29882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29883         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
29884         int64_t ret_ref = 0;
29885         if ((uintptr_t)ret_var.inner > 4096) {
29886                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29887                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29889                 ret_ref = (uintptr_t)ret_var.inner;
29890                 if (ret_var.is_owned) {
29891                         ret_ref |= 1;
29892                 }
29893         }
29894         return ret_ref;
29895 }
29896
29897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29898         LDKChannelDetails this_ptr_conv;
29899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29900         this_ptr_conv.is_owned = false;
29901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29902         LDKChannelTypeFeatures val_conv;
29903         val_conv.inner = (void*)(val & (~1));
29904         val_conv.is_owned = (val & 1) || (val == 0);
29905         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29906         val_conv = ChannelTypeFeatures_clone(&val_conv);
29907         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
29908 }
29909
29910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29911         LDKChannelDetails this_ptr_conv;
29912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29913         this_ptr_conv.is_owned = false;
29914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29915         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29916         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
29917         int64_t ret_ref = (uintptr_t)ret_copy;
29918         return ret_ref;
29919 }
29920
29921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29922         LDKChannelDetails this_ptr_conv;
29923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29924         this_ptr_conv.is_owned = false;
29925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29926         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29927         CHECK_ACCESS(val_ptr);
29928         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29929         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29930         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
29931 }
29932
29933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
29934         LDKChannelDetails this_ptr_conv;
29935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29936         this_ptr_conv.is_owned = false;
29937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29938         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29939         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
29940         int64_t ret_ref = (uintptr_t)ret_copy;
29941         return ret_ref;
29942 }
29943
29944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29945         LDKChannelDetails this_ptr_conv;
29946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29947         this_ptr_conv.is_owned = false;
29948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29949         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29950         CHECK_ACCESS(val_ptr);
29951         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29952         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29953         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
29954 }
29955
29956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
29957         LDKChannelDetails this_ptr_conv;
29958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29959         this_ptr_conv.is_owned = false;
29960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29961         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29962         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
29963         int64_t ret_ref = (uintptr_t)ret_copy;
29964         return ret_ref;
29965 }
29966
29967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29968         LDKChannelDetails this_ptr_conv;
29969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29970         this_ptr_conv.is_owned = false;
29971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29972         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29973         CHECK_ACCESS(val_ptr);
29974         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29975         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29976         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
29977 }
29978
29979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29980         LDKChannelDetails this_ptr_conv;
29981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29982         this_ptr_conv.is_owned = false;
29983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29984         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
29985         return ret_conv;
29986 }
29987
29988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29989         LDKChannelDetails this_ptr_conv;
29990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29991         this_ptr_conv.is_owned = false;
29992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29993         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
29994 }
29995
29996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
29997         LDKChannelDetails this_ptr_conv;
29998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29999         this_ptr_conv.is_owned = false;
30000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30001         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30002         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
30003         int64_t ret_ref = (uintptr_t)ret_copy;
30004         return ret_ref;
30005 }
30006
30007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30008         LDKChannelDetails this_ptr_conv;
30009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30010         this_ptr_conv.is_owned = false;
30011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30012         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30013         CHECK_ACCESS(val_ptr);
30014         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30015         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
30016         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
30017 }
30018
30019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30020         LDKChannelDetails this_ptr_conv;
30021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30022         this_ptr_conv.is_owned = false;
30023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30024         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
30025         return ret_conv;
30026 }
30027
30028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30029         LDKChannelDetails this_ptr_conv;
30030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30031         this_ptr_conv.is_owned = false;
30032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30033         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
30034 }
30035
30036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30037         LDKChannelDetails this_ptr_conv;
30038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30039         this_ptr_conv.is_owned = false;
30040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30041         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
30042         return ret_conv;
30043 }
30044
30045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30046         LDKChannelDetails this_ptr_conv;
30047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30048         this_ptr_conv.is_owned = false;
30049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30050         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
30051 }
30052
30053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30054         LDKChannelDetails this_ptr_conv;
30055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30056         this_ptr_conv.is_owned = false;
30057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30058         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
30059         return ret_conv;
30060 }
30061
30062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30063         LDKChannelDetails this_ptr_conv;
30064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30065         this_ptr_conv.is_owned = false;
30066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30067         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
30068 }
30069
30070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30071         LDKChannelDetails this_ptr_conv;
30072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30073         this_ptr_conv.is_owned = false;
30074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30075         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
30076         return ret_conv;
30077 }
30078
30079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30080         LDKChannelDetails this_ptr_conv;
30081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30082         this_ptr_conv.is_owned = false;
30083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30084         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
30085 }
30086
30087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30088         LDKChannelDetails this_ptr_conv;
30089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30090         this_ptr_conv.is_owned = false;
30091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30092         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
30093         return ret_conv;
30094 }
30095
30096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30097         LDKChannelDetails 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         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
30102 }
30103
30104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
30105         LDKChannelDetails this_ptr_conv;
30106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30107         this_ptr_conv.is_owned = false;
30108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30109         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
30110         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
30111         int64_t ret_ref = (uintptr_t)ret_copy;
30112         return ret_ref;
30113 }
30114
30115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30116         LDKChannelDetails this_ptr_conv;
30117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30118         this_ptr_conv.is_owned = false;
30119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30120         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30121         CHECK_ACCESS(val_ptr);
30122         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
30123         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
30124         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
30125 }
30126
30127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30128         LDKChannelDetails this_ptr_conv;
30129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30130         this_ptr_conv.is_owned = false;
30131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30132         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
30133         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
30134         int64_t ret_ref = (uintptr_t)ret_copy;
30135         return ret_ref;
30136 }
30137
30138 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) {
30139         LDKChannelDetails this_ptr_conv;
30140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30141         this_ptr_conv.is_owned = false;
30142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30143         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30144         CHECK_ACCESS(val_ptr);
30145         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
30146         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
30147         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
30148 }
30149
30150 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
30151         LDKChannelDetails this_ptr_conv;
30152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30153         this_ptr_conv.is_owned = false;
30154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30155         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
30156         return ret_conv;
30157 }
30158
30159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30160         LDKChannelDetails this_ptr_conv;
30161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30162         this_ptr_conv.is_owned = false;
30163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30164         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
30165 }
30166
30167 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
30168         LDKChannelDetails this_ptr_conv;
30169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30170         this_ptr_conv.is_owned = false;
30171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30172         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
30173         return ret_conv;
30174 }
30175
30176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30177         LDKChannelDetails this_ptr_conv;
30178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30179         this_ptr_conv.is_owned = false;
30180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30181         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
30182 }
30183
30184 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
30185         LDKChannelDetails this_ptr_conv;
30186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30187         this_ptr_conv.is_owned = false;
30188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30189         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
30190         return ret_conv;
30191 }
30192
30193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30194         LDKChannelDetails this_ptr_conv;
30195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30196         this_ptr_conv.is_owned = false;
30197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30198         ChannelDetails_set_is_usable(&this_ptr_conv, val);
30199 }
30200
30201 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
30202         LDKChannelDetails this_ptr_conv;
30203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30204         this_ptr_conv.is_owned = false;
30205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30206         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
30207         return ret_conv;
30208 }
30209
30210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30211         LDKChannelDetails this_ptr_conv;
30212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30213         this_ptr_conv.is_owned = false;
30214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30215         ChannelDetails_set_is_public(&this_ptr_conv, val);
30216 }
30217
30218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30219         LDKChannelDetails this_ptr_conv;
30220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30221         this_ptr_conv.is_owned = false;
30222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30223         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30224         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
30225         int64_t ret_ref = (uintptr_t)ret_copy;
30226         return ret_ref;
30227 }
30228
30229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30230         LDKChannelDetails this_ptr_conv;
30231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30232         this_ptr_conv.is_owned = false;
30233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30234         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30235         CHECK_ACCESS(val_ptr);
30236         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30237         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
30238         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
30239 }
30240
30241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30242         LDKChannelDetails this_ptr_conv;
30243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30244         this_ptr_conv.is_owned = false;
30245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30246         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30247         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
30248         int64_t ret_ref = (uintptr_t)ret_copy;
30249         return ret_ref;
30250 }
30251
30252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30253         LDKChannelDetails this_ptr_conv;
30254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30255         this_ptr_conv.is_owned = false;
30256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30257         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30258         CHECK_ACCESS(val_ptr);
30259         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30260         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
30261         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
30262 }
30263
30264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
30265         LDKChannelDetails this_ptr_conv;
30266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30267         this_ptr_conv.is_owned = false;
30268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30269         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
30270         int64_t ret_ref = 0;
30271         if ((uintptr_t)ret_var.inner > 4096) {
30272                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30273                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30275                 ret_ref = (uintptr_t)ret_var.inner;
30276                 if (ret_var.is_owned) {
30277                         ret_ref |= 1;
30278                 }
30279         }
30280         return ret_ref;
30281 }
30282
30283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30284         LDKChannelDetails this_ptr_conv;
30285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30286         this_ptr_conv.is_owned = false;
30287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30288         LDKChannelConfig val_conv;
30289         val_conv.inner = (void*)(val & (~1));
30290         val_conv.is_owned = (val & 1) || (val == 0);
30291         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30292         val_conv = ChannelConfig_clone(&val_conv);
30293         ChannelDetails_set_config(&this_ptr_conv, val_conv);
30294 }
30295
30296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t channel_type_arg, int64_t short_channel_id_arg, int64_t outbound_scid_alias_arg, int64_t inbound_scid_alias_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t balance_msat_arg, int64_t outbound_capacity_msat_arg, int64_t next_outbound_htlc_limit_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_channel_ready_arg, jboolean is_usable_arg, jboolean is_public_arg, int64_t inbound_htlc_minimum_msat_arg, int64_t inbound_htlc_maximum_msat_arg, int64_t config_arg) {
30297         LDKThirtyTwoBytes channel_id_arg_ref;
30298         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30299         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30300         LDKChannelCounterparty counterparty_arg_conv;
30301         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
30302         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
30303         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
30304         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
30305         LDKOutPoint funding_txo_arg_conv;
30306         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
30307         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
30308         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
30309         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
30310         LDKChannelTypeFeatures channel_type_arg_conv;
30311         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
30312         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
30313         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
30314         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
30315         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
30316         CHECK_ACCESS(short_channel_id_arg_ptr);
30317         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
30318         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
30319         void* outbound_scid_alias_arg_ptr = (void*)(((uintptr_t)outbound_scid_alias_arg) & ~1);
30320         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
30321         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
30322         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_scid_alias_arg) & ~1));
30323         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
30324         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
30325         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
30326         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
30327         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
30328         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
30329         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
30330         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
30331         CHECK_ACCESS(confirmations_required_arg_ptr);
30332         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
30333         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
30334         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
30335         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
30336         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
30337         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
30338         void* inbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1);
30339         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
30340         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
30341         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1));
30342         void* inbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1);
30343         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
30344         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
30345         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1));
30346         LDKChannelConfig config_arg_conv;
30347         config_arg_conv.inner = (void*)(config_arg & (~1));
30348         config_arg_conv.is_owned = (config_arg & 1) || (config_arg == 0);
30349         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
30350         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
30351         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, channel_type_arg_conv, short_channel_id_arg_conv, outbound_scid_alias_arg_conv, inbound_scid_alias_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, balance_msat_arg, outbound_capacity_msat_arg, next_outbound_htlc_limit_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_channel_ready_arg, is_usable_arg, is_public_arg, inbound_htlc_minimum_msat_arg_conv, inbound_htlc_maximum_msat_arg_conv, config_arg_conv);
30352         int64_t ret_ref = 0;
30353         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30354         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30356         ret_ref = (uintptr_t)ret_var.inner;
30357         if (ret_var.is_owned) {
30358                 ret_ref |= 1;
30359         }
30360         return ret_ref;
30361 }
30362
30363 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
30364         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
30365 int64_t ret_ref = 0;
30366 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30367 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30368 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30369 ret_ref = (uintptr_t)ret_var.inner;
30370 if (ret_var.is_owned) {
30371         ret_ref |= 1;
30372 }
30373         return ret_ref;
30374 }
30375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30376         LDKChannelDetails arg_conv;
30377         arg_conv.inner = (void*)(arg & (~1));
30378         arg_conv.is_owned = false;
30379         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30380         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
30381         return ret_conv;
30382 }
30383
30384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30385         LDKChannelDetails orig_conv;
30386         orig_conv.inner = (void*)(orig & (~1));
30387         orig_conv.is_owned = false;
30388         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30389         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
30390         int64_t ret_ref = 0;
30391         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30392         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30394         ret_ref = (uintptr_t)ret_var.inner;
30395         if (ret_var.is_owned) {
30396                 ret_ref |= 1;
30397         }
30398         return ret_ref;
30399 }
30400
30401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
30402         LDKChannelDetails this_arg_conv;
30403         this_arg_conv.inner = (void*)(this_arg & (~1));
30404         this_arg_conv.is_owned = false;
30405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30406         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30407         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
30408         int64_t ret_ref = (uintptr_t)ret_copy;
30409         return ret_ref;
30410 }
30411
30412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
30413         LDKChannelDetails this_arg_conv;
30414         this_arg_conv.inner = (void*)(this_arg & (~1));
30415         this_arg_conv.is_owned = false;
30416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30417         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30418         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
30419         int64_t ret_ref = (uintptr_t)ret_copy;
30420         return ret_ref;
30421 }
30422
30423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30424         if ((this_ptr & 1) != 0) return;
30425         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
30426         CHECK_ACCESS(this_ptr_ptr);
30427         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
30428         FREE((void*)this_ptr);
30429         PaymentSendFailure_free(this_ptr_conv);
30430 }
30431
30432 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
30433         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30434         *ret_copy = PaymentSendFailure_clone(arg);
30435 int64_t ret_ref = (uintptr_t)ret_copy;
30436         return ret_ref;
30437 }
30438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30439         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
30440         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
30441         return ret_conv;
30442 }
30443
30444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30445         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
30446         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30447         *ret_copy = PaymentSendFailure_clone(orig_conv);
30448         int64_t ret_ref = (uintptr_t)ret_copy;
30449         return ret_ref;
30450 }
30451
30452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
30453         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
30454         CHECK_ACCESS(a_ptr);
30455         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
30456         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
30457         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30458         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
30459         int64_t ret_ref = (uintptr_t)ret_copy;
30460         return ret_ref;
30461 }
30462
30463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
30464         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
30465         a_constr.datalen = (*env)->GetArrayLength(env, a);
30466         if (a_constr.datalen > 0)
30467                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
30468         else
30469                 a_constr.data = NULL;
30470         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
30471         for (size_t w = 0; w < a_constr.datalen; w++) {
30472                 int64_t a_conv_22 = a_vals[w];
30473                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
30474                 CHECK_ACCESS(a_conv_22_ptr);
30475                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
30476                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
30477                 a_constr.data[w] = a_conv_22_conv;
30478         }
30479         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
30480         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30481         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
30482         int64_t ret_ref = (uintptr_t)ret_copy;
30483         return ret_ref;
30484 }
30485
30486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
30487         LDKCVec_APIErrorZ a_constr;
30488         a_constr.datalen = (*env)->GetArrayLength(env, a);
30489         if (a_constr.datalen > 0)
30490                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
30491         else
30492                 a_constr.data = NULL;
30493         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
30494         for (size_t k = 0; k < a_constr.datalen; k++) {
30495                 int64_t a_conv_10 = a_vals[k];
30496                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
30497                 CHECK_ACCESS(a_conv_10_ptr);
30498                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
30499                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
30500                 a_constr.data[k] = a_conv_10_conv;
30501         }
30502         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
30503         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30504         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
30505         int64_t ret_ref = (uintptr_t)ret_copy;
30506         return ret_ref;
30507 }
30508
30509 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) {
30510         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
30511         results_constr.datalen = (*env)->GetArrayLength(env, results);
30512         if (results_constr.datalen > 0)
30513                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
30514         else
30515                 results_constr.data = NULL;
30516         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
30517         for (size_t w = 0; w < results_constr.datalen; w++) {
30518                 int64_t results_conv_22 = results_vals[w];
30519                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
30520                 CHECK_ACCESS(results_conv_22_ptr);
30521                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
30522                 results_constr.data[w] = results_conv_22_conv;
30523         }
30524         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
30525         LDKRouteParameters failed_paths_retry_conv;
30526         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
30527         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
30528         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
30529         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
30530         LDKThirtyTwoBytes payment_id_ref;
30531         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
30532         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
30533         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30534         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
30535         int64_t ret_ref = (uintptr_t)ret_copy;
30536         return ret_ref;
30537 }
30538
30539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30540         LDKPhantomRouteHints this_obj_conv;
30541         this_obj_conv.inner = (void*)(this_obj & (~1));
30542         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30544         PhantomRouteHints_free(this_obj_conv);
30545 }
30546
30547 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
30548         LDKPhantomRouteHints 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         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
30553         int64_tArray ret_arr = NULL;
30554         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30555         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30556         for (size_t q = 0; q < ret_var.datalen; q++) {
30557                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
30558                 int64_t ret_conv_16_ref = 0;
30559                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30560                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30561                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30562                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30563                 if (ret_conv_16_var.is_owned) {
30564                         ret_conv_16_ref |= 1;
30565                 }
30566                 ret_arr_ptr[q] = ret_conv_16_ref;
30567         }
30568         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30569         FREE(ret_var.data);
30570         return ret_arr;
30571 }
30572
30573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
30574         LDKPhantomRouteHints this_ptr_conv;
30575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30576         this_ptr_conv.is_owned = false;
30577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30578         LDKCVec_ChannelDetailsZ val_constr;
30579         val_constr.datalen = (*env)->GetArrayLength(env, val);
30580         if (val_constr.datalen > 0)
30581                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
30582         else
30583                 val_constr.data = NULL;
30584         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
30585         for (size_t q = 0; q < val_constr.datalen; q++) {
30586                 int64_t val_conv_16 = val_vals[q];
30587                 LDKChannelDetails val_conv_16_conv;
30588                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
30589                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
30590                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
30591                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
30592                 val_constr.data[q] = val_conv_16_conv;
30593         }
30594         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
30595         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
30596 }
30597
30598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
30599         LDKPhantomRouteHints this_ptr_conv;
30600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30601         this_ptr_conv.is_owned = false;
30602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30603         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
30604         return ret_conv;
30605 }
30606
30607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30608         LDKPhantomRouteHints this_ptr_conv;
30609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30610         this_ptr_conv.is_owned = false;
30611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30612         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
30613 }
30614
30615 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30616         LDKPhantomRouteHints this_ptr_conv;
30617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30618         this_ptr_conv.is_owned = false;
30619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30620         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30621         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
30622         return ret_arr;
30623 }
30624
30625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30626         LDKPhantomRouteHints this_ptr_conv;
30627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30628         this_ptr_conv.is_owned = false;
30629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30630         LDKPublicKey val_ref;
30631         CHECK((*env)->GetArrayLength(env, val) == 33);
30632         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30633         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
30634 }
30635
30636 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) {
30637         LDKCVec_ChannelDetailsZ channels_arg_constr;
30638         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
30639         if (channels_arg_constr.datalen > 0)
30640                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
30641         else
30642                 channels_arg_constr.data = NULL;
30643         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
30644         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
30645                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
30646                 LDKChannelDetails channels_arg_conv_16_conv;
30647                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
30648                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
30649                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
30650                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
30651                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
30652         }
30653         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
30654         LDKPublicKey real_node_pubkey_arg_ref;
30655         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
30656         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
30657         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
30658         int64_t ret_ref = 0;
30659         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30660         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30661         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30662         ret_ref = (uintptr_t)ret_var.inner;
30663         if (ret_var.is_owned) {
30664                 ret_ref |= 1;
30665         }
30666         return ret_ref;
30667 }
30668
30669 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
30670         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
30671 int64_t ret_ref = 0;
30672 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30673 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30674 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30675 ret_ref = (uintptr_t)ret_var.inner;
30676 if (ret_var.is_owned) {
30677         ret_ref |= 1;
30678 }
30679         return ret_ref;
30680 }
30681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30682         LDKPhantomRouteHints arg_conv;
30683         arg_conv.inner = (void*)(arg & (~1));
30684         arg_conv.is_owned = false;
30685         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30686         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
30687         return ret_conv;
30688 }
30689
30690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30691         LDKPhantomRouteHints orig_conv;
30692         orig_conv.inner = (void*)(orig & (~1));
30693         orig_conv.is_owned = false;
30694         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30695         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
30696         int64_t ret_ref = 0;
30697         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30698         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30700         ret_ref = (uintptr_t)ret_var.inner;
30701         if (ret_var.is_owned) {
30702                 ret_ref |= 1;
30703         }
30704         return ret_ref;
30705 }
30706
30707 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) {
30708         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
30709         CHECK_ACCESS(fee_est_ptr);
30710         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
30711         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
30712                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30713                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
30714         }
30715         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
30716         CHECK_ACCESS(chain_monitor_ptr);
30717         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
30718         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
30719                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30720                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
30721         }
30722         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
30723         CHECK_ACCESS(tx_broadcaster_ptr);
30724         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
30725         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30726                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30727                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
30728         }
30729         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
30730         CHECK_ACCESS(logger_ptr);
30731         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30732         if (logger_conv.free == LDKLogger_JCalls_free) {
30733                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30734                 LDKLogger_JCalls_cloned(&logger_conv);
30735         }
30736         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
30737         CHECK_ACCESS(keys_manager_ptr);
30738         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
30739         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
30740                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30741                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
30742         }
30743         LDKUserConfig config_conv;
30744         config_conv.inner = (void*)(config & (~1));
30745         config_conv.is_owned = (config & 1) || (config == 0);
30746         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
30747         config_conv = UserConfig_clone(&config_conv);
30748         LDKChainParameters params_conv;
30749         params_conv.inner = (void*)(params & (~1));
30750         params_conv.is_owned = (params & 1) || (params == 0);
30751         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
30752         params_conv = ChainParameters_clone(&params_conv);
30753         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
30754         int64_t ret_ref = 0;
30755         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30756         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30758         ret_ref = (uintptr_t)ret_var.inner;
30759         if (ret_var.is_owned) {
30760                 ret_ref |= 1;
30761         }
30762         return ret_ref;
30763 }
30764
30765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
30766         LDKChannelManager this_arg_conv;
30767         this_arg_conv.inner = (void*)(this_arg & (~1));
30768         this_arg_conv.is_owned = false;
30769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30770         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
30771         int64_t ret_ref = 0;
30772         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30773         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30775         ret_ref = (uintptr_t)ret_var.inner;
30776         if (ret_var.is_owned) {
30777                 ret_ref |= 1;
30778         }
30779         return ret_ref;
30780 }
30781
30782 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) {
30783         LDKChannelManager this_arg_conv;
30784         this_arg_conv.inner = (void*)(this_arg & (~1));
30785         this_arg_conv.is_owned = false;
30786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30787         LDKPublicKey their_network_key_ref;
30788         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
30789         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
30790         LDKUserConfig override_config_conv;
30791         override_config_conv.inner = (void*)(override_config & (~1));
30792         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
30793         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
30794         override_config_conv = UserConfig_clone(&override_config_conv);
30795         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
30796         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
30797         return (int64_t)ret_conv;
30798 }
30799
30800 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
30801         LDKChannelManager this_arg_conv;
30802         this_arg_conv.inner = (void*)(this_arg & (~1));
30803         this_arg_conv.is_owned = false;
30804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30805         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
30806         int64_tArray ret_arr = NULL;
30807         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30808         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30809         for (size_t q = 0; q < ret_var.datalen; q++) {
30810                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
30811                 int64_t ret_conv_16_ref = 0;
30812                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30813                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30814                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30815                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30816                 if (ret_conv_16_var.is_owned) {
30817                         ret_conv_16_ref |= 1;
30818                 }
30819                 ret_arr_ptr[q] = ret_conv_16_ref;
30820         }
30821         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30822         FREE(ret_var.data);
30823         return ret_arr;
30824 }
30825
30826 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
30827         LDKChannelManager this_arg_conv;
30828         this_arg_conv.inner = (void*)(this_arg & (~1));
30829         this_arg_conv.is_owned = false;
30830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30831         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
30832         int64_tArray ret_arr = NULL;
30833         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30834         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30835         for (size_t q = 0; q < ret_var.datalen; q++) {
30836                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
30837                 int64_t ret_conv_16_ref = 0;
30838                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30839                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30840                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30841                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30842                 if (ret_conv_16_var.is_owned) {
30843                         ret_conv_16_ref |= 1;
30844                 }
30845                 ret_arr_ptr[q] = ret_conv_16_ref;
30846         }
30847         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30848         FREE(ret_var.data);
30849         return ret_arr;
30850 }
30851
30852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
30853         LDKChannelManager this_arg_conv;
30854         this_arg_conv.inner = (void*)(this_arg & (~1));
30855         this_arg_conv.is_owned = false;
30856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30857         unsigned char channel_id_arr[32];
30858         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30859         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30860         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30861         LDKPublicKey counterparty_node_id_ref;
30862         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30863         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30864         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30865         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30866         return (int64_t)ret_conv;
30867 }
30868
30869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel_1with_1target_1feerate(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id, int32_t target_feerate_sats_per_1000_weight) {
30870         LDKChannelManager this_arg_conv;
30871         this_arg_conv.inner = (void*)(this_arg & (~1));
30872         this_arg_conv.is_owned = false;
30873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30874         unsigned char channel_id_arr[32];
30875         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30876         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30877         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30878         LDKPublicKey counterparty_node_id_ref;
30879         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30880         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30881         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30882         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
30883         return (int64_t)ret_conv;
30884 }
30885
30886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
30887         LDKChannelManager this_arg_conv;
30888         this_arg_conv.inner = (void*)(this_arg & (~1));
30889         this_arg_conv.is_owned = false;
30890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30891         unsigned char channel_id_arr[32];
30892         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30893         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30894         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30895         LDKPublicKey counterparty_node_id_ref;
30896         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30897         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30898         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30899         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30900         return (int64_t)ret_conv;
30901 }
30902
30903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
30904         LDKChannelManager this_arg_conv;
30905         this_arg_conv.inner = (void*)(this_arg & (~1));
30906         this_arg_conv.is_owned = false;
30907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30908         unsigned char channel_id_arr[32];
30909         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30910         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30911         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30912         LDKPublicKey counterparty_node_id_ref;
30913         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30914         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30915         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30916         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30917         return (int64_t)ret_conv;
30918 }
30919
30920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
30921         LDKChannelManager this_arg_conv;
30922         this_arg_conv.inner = (void*)(this_arg & (~1));
30923         this_arg_conv.is_owned = false;
30924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30925         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
30926 }
30927
30928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
30929         LDKChannelManager this_arg_conv;
30930         this_arg_conv.inner = (void*)(this_arg & (~1));
30931         this_arg_conv.is_owned = false;
30932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30933         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
30934 }
30935
30936 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) {
30937         LDKChannelManager this_arg_conv;
30938         this_arg_conv.inner = (void*)(this_arg & (~1));
30939         this_arg_conv.is_owned = false;
30940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30941         LDKRoute route_conv;
30942         route_conv.inner = (void*)(route & (~1));
30943         route_conv.is_owned = false;
30944         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
30945         LDKThirtyTwoBytes payment_hash_ref;
30946         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30947         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
30948         LDKThirtyTwoBytes payment_secret_ref;
30949         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
30950         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
30951         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
30952         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
30953         return (int64_t)ret_conv;
30954 }
30955
30956 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) {
30957         LDKChannelManager this_arg_conv;
30958         this_arg_conv.inner = (void*)(this_arg & (~1));
30959         this_arg_conv.is_owned = false;
30960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30961         LDKRoute route_conv;
30962         route_conv.inner = (void*)(route & (~1));
30963         route_conv.is_owned = false;
30964         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
30965         LDKThirtyTwoBytes payment_id_ref;
30966         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
30967         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
30968         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
30969         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
30970         return (int64_t)ret_conv;
30971 }
30972
30973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
30974         LDKChannelManager this_arg_conv;
30975         this_arg_conv.inner = (void*)(this_arg & (~1));
30976         this_arg_conv.is_owned = false;
30977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30978         LDKThirtyTwoBytes payment_id_ref;
30979         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
30980         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
30981         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
30982 }
30983
30984 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) {
30985         LDKChannelManager this_arg_conv;
30986         this_arg_conv.inner = (void*)(this_arg & (~1));
30987         this_arg_conv.is_owned = false;
30988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30989         LDKRoute route_conv;
30990         route_conv.inner = (void*)(route & (~1));
30991         route_conv.is_owned = false;
30992         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
30993         LDKThirtyTwoBytes payment_preimage_ref;
30994         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
30995         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
30996         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
30997         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
30998         return (int64_t)ret_conv;
30999 }
31000
31001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1probe(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray hops) {
31002         LDKChannelManager this_arg_conv;
31003         this_arg_conv.inner = (void*)(this_arg & (~1));
31004         this_arg_conv.is_owned = false;
31005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31006         LDKCVec_RouteHopZ hops_constr;
31007         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
31008         if (hops_constr.datalen > 0)
31009                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
31010         else
31011                 hops_constr.data = NULL;
31012         int64_t* hops_vals = (*env)->GetLongArrayElements (env, hops, NULL);
31013         for (size_t k = 0; k < hops_constr.datalen; k++) {
31014                 int64_t hops_conv_10 = hops_vals[k];
31015                 LDKRouteHop hops_conv_10_conv;
31016                 hops_conv_10_conv.inner = (void*)(hops_conv_10 & (~1));
31017                 hops_conv_10_conv.is_owned = (hops_conv_10 & 1) || (hops_conv_10 == 0);
31018                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv_10_conv);
31019                 hops_conv_10_conv = RouteHop_clone(&hops_conv_10_conv);
31020                 hops_constr.data[k] = hops_conv_10_conv;
31021         }
31022         (*env)->ReleaseLongArrayElements(env, hops, hops_vals, 0);
31023         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
31024         *ret_conv = ChannelManager_send_probe(&this_arg_conv, hops_constr);
31025         return (int64_t)ret_conv;
31026 }
31027
31028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1funding_1transaction_1generated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int8_tArray funding_transaction) {
31029         LDKChannelManager this_arg_conv;
31030         this_arg_conv.inner = (void*)(this_arg & (~1));
31031         this_arg_conv.is_owned = false;
31032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31033         unsigned char temporary_channel_id_arr[32];
31034         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
31035         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
31036         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
31037         LDKPublicKey counterparty_node_id_ref;
31038         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31039         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31040         LDKTransaction funding_transaction_ref;
31041         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
31042         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
31043         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
31044         funding_transaction_ref.data_is_owned = true;
31045         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31046         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
31047         return (int64_t)ret_conv;
31048 }
31049
31050 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) {
31051         LDKChannelManager this_arg_conv;
31052         this_arg_conv.inner = (void*)(this_arg & (~1));
31053         this_arg_conv.is_owned = false;
31054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31055         LDKThreeBytes rgb_ref;
31056         CHECK((*env)->GetArrayLength(env, rgb) == 3);
31057         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
31058         LDKThirtyTwoBytes alias_ref;
31059         CHECK((*env)->GetArrayLength(env, alias) == 32);
31060         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
31061         LDKCVec_NetAddressZ addresses_constr;
31062         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
31063         if (addresses_constr.datalen > 0)
31064                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
31065         else
31066                 addresses_constr.data = NULL;
31067         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
31068         for (size_t m = 0; m < addresses_constr.datalen; m++) {
31069                 int64_t addresses_conv_12 = addresses_vals[m];
31070                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
31071                 CHECK_ACCESS(addresses_conv_12_ptr);
31072                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
31073                 addresses_constr.data[m] = addresses_conv_12_conv;
31074         }
31075         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
31076         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
31077 }
31078
31079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1update_1channel_1config(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray counterparty_node_id, jobjectArray channel_ids, int64_t config) {
31080         LDKChannelManager this_arg_conv;
31081         this_arg_conv.inner = (void*)(this_arg & (~1));
31082         this_arg_conv.is_owned = false;
31083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31084         LDKPublicKey counterparty_node_id_ref;
31085         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31086         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31087         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
31088         channel_ids_constr.datalen = (*env)->GetArrayLength(env, channel_ids);
31089         if (channel_ids_constr.datalen > 0)
31090                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
31091         else
31092                 channel_ids_constr.data = NULL;
31093         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
31094                 int8_tArray channel_ids_conv_8 = (*env)->GetObjectArrayElement(env, channel_ids, i);
31095                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
31096                 CHECK((*env)->GetArrayLength(env, channel_ids_conv_8) == 32);
31097                 (*env)->GetByteArrayRegion(env, channel_ids_conv_8, 0, 32, channel_ids_conv_8_ref.data);
31098                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
31099         }
31100         LDKChannelConfig config_conv;
31101         config_conv.inner = (void*)(config & (~1));
31102         config_conv.is_owned = false;
31103         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
31104         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31105         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
31106         return (int64_t)ret_conv;
31107 }
31108
31109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
31110         LDKChannelManager this_arg_conv;
31111         this_arg_conv.inner = (void*)(this_arg & (~1));
31112         this_arg_conv.is_owned = false;
31113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31114         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
31115 }
31116
31117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
31118         LDKChannelManager this_arg_conv;
31119         this_arg_conv.inner = (void*)(this_arg & (~1));
31120         this_arg_conv.is_owned = false;
31121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31122         ChannelManager_timer_tick_occurred(&this_arg_conv);
31123 }
31124
31125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
31126         LDKChannelManager this_arg_conv;
31127         this_arg_conv.inner = (void*)(this_arg & (~1));
31128         this_arg_conv.is_owned = false;
31129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31130         unsigned char payment_hash_arr[32];
31131         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31132         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
31133         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
31134         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
31135 }
31136
31137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
31138         LDKChannelManager this_arg_conv;
31139         this_arg_conv.inner = (void*)(this_arg & (~1));
31140         this_arg_conv.is_owned = false;
31141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31142         LDKThirtyTwoBytes payment_preimage_ref;
31143         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
31144         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
31145         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
31146 }
31147
31148 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
31149         LDKChannelManager this_arg_conv;
31150         this_arg_conv.inner = (void*)(this_arg & (~1));
31151         this_arg_conv.is_owned = false;
31152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31153         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31154         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
31155         return ret_arr;
31156 }
31157
31158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1accept_1inbound_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
31159         LDKChannelManager this_arg_conv;
31160         this_arg_conv.inner = (void*)(this_arg & (~1));
31161         this_arg_conv.is_owned = false;
31162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31163         unsigned char temporary_channel_id_arr[32];
31164         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
31165         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
31166         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
31167         LDKPublicKey counterparty_node_id_ref;
31168         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31169         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31170         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31171         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
31172         return (int64_t)ret_conv;
31173 }
31174
31175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1accept_1inbound_1channel_1from_1trusted_1peer_10conf(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
31176         LDKChannelManager this_arg_conv;
31177         this_arg_conv.inner = (void*)(this_arg & (~1));
31178         this_arg_conv.is_owned = false;
31179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31180         unsigned char temporary_channel_id_arr[32];
31181         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
31182         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
31183         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
31184         LDKPublicKey counterparty_node_id_ref;
31185         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31186         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31187         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31188         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
31189         return (int64_t)ret_conv;
31190 }
31191
31192 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) {
31193         LDKChannelManager this_arg_conv;
31194         this_arg_conv.inner = (void*)(this_arg & (~1));
31195         this_arg_conv.is_owned = false;
31196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31197         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31198         CHECK_ACCESS(min_value_msat_ptr);
31199         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31200         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31201         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
31202         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
31203         return (int64_t)ret_conv;
31204 }
31205
31206 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) {
31207         LDKChannelManager this_arg_conv;
31208         this_arg_conv.inner = (void*)(this_arg & (~1));
31209         this_arg_conv.is_owned = false;
31210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31211         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31212         CHECK_ACCESS(min_value_msat_ptr);
31213         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31214         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31215         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
31216         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
31217         return (int64_t)ret_conv;
31218 }
31219
31220 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) {
31221         LDKChannelManager this_arg_conv;
31222         this_arg_conv.inner = (void*)(this_arg & (~1));
31223         this_arg_conv.is_owned = false;
31224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31225         LDKThirtyTwoBytes payment_hash_ref;
31226         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31227         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31228         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31229         CHECK_ACCESS(min_value_msat_ptr);
31230         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31231         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31232         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
31233         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
31234         return (int64_t)ret_conv;
31235 }
31236
31237 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) {
31238         LDKChannelManager this_arg_conv;
31239         this_arg_conv.inner = (void*)(this_arg & (~1));
31240         this_arg_conv.is_owned = false;
31241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31242         LDKThirtyTwoBytes payment_hash_ref;
31243         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31244         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31245         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31246         CHECK_ACCESS(min_value_msat_ptr);
31247         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31248         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31249         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
31250         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
31251         return (int64_t)ret_conv;
31252 }
31253
31254 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) {
31255         LDKChannelManager this_arg_conv;
31256         this_arg_conv.inner = (void*)(this_arg & (~1));
31257         this_arg_conv.is_owned = false;
31258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31259         LDKThirtyTwoBytes payment_hash_ref;
31260         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31261         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31262         LDKThirtyTwoBytes payment_secret_ref;
31263         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
31264         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
31265         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
31266         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
31267         return (int64_t)ret_conv;
31268 }
31269
31270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
31271         LDKChannelManager this_arg_conv;
31272         this_arg_conv.inner = (void*)(this_arg & (~1));
31273         this_arg_conv.is_owned = false;
31274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31275         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
31276         return ret_conv;
31277 }
31278
31279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
31280         LDKChannelManager this_arg_conv;
31281         this_arg_conv.inner = (void*)(this_arg & (~1));
31282         this_arg_conv.is_owned = false;
31283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31284         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
31285         int64_t ret_ref = 0;
31286         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31287         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31289         ret_ref = (uintptr_t)ret_var.inner;
31290         if (ret_var.is_owned) {
31291                 ret_ref |= 1;
31292         }
31293         return ret_ref;
31294 }
31295
31296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31297         LDKChannelManager this_arg_conv;
31298         this_arg_conv.inner = (void*)(this_arg & (~1));
31299         this_arg_conv.is_owned = false;
31300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31301         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
31302         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
31303         return (int64_t)ret_ret;
31304 }
31305
31306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31307         LDKChannelManager this_arg_conv;
31308         this_arg_conv.inner = (void*)(this_arg & (~1));
31309         this_arg_conv.is_owned = false;
31310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31311         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
31312         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
31313         return (int64_t)ret_ret;
31314 }
31315
31316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
31317         LDKChannelManager this_arg_conv;
31318         this_arg_conv.inner = (void*)(this_arg & (~1));
31319         this_arg_conv.is_owned = false;
31320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31321         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
31322         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
31323         return (int64_t)ret_ret;
31324 }
31325
31326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
31327         LDKChannelManager this_arg_conv;
31328         this_arg_conv.inner = (void*)(this_arg & (~1));
31329         this_arg_conv.is_owned = false;
31330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31331         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
31332         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
31333         return (int64_t)ret_ret;
31334 }
31335
31336 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) {
31337         LDKChannelManager this_arg_conv;
31338         this_arg_conv.inner = (void*)(this_arg & (~1));
31339         this_arg_conv.is_owned = false;
31340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31341         jboolean ret_conv = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
31342         return ret_conv;
31343 }
31344
31345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
31346         LDKChannelManager this_arg_conv;
31347         this_arg_conv.inner = (void*)(this_arg & (~1));
31348         this_arg_conv.is_owned = false;
31349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31350         ChannelManager_await_persistable_update(&this_arg_conv);
31351 }
31352
31353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
31354         LDKChannelManager this_arg_conv;
31355         this_arg_conv.inner = (void*)(this_arg & (~1));
31356         this_arg_conv.is_owned = false;
31357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31358         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
31359         int64_t ret_ref = 0;
31360         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31361         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31363         ret_ref = (uintptr_t)ret_var.inner;
31364         if (ret_var.is_owned) {
31365                 ret_ref |= 1;
31366         }
31367         return ret_ref;
31368 }
31369
31370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
31371         LDKChannelManager this_arg_conv;
31372         this_arg_conv.inner = (void*)(this_arg & (~1));
31373         this_arg_conv.is_owned = false;
31374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31375         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
31376         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
31377         return (int64_t)ret_ret;
31378 }
31379
31380 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
31381         LDKCounterpartyForwardingInfo obj_conv;
31382         obj_conv.inner = (void*)(obj & (~1));
31383         obj_conv.is_owned = false;
31384         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31385         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
31386         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31387         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31388         CVec_u8Z_free(ret_var);
31389         return ret_arr;
31390 }
31391
31392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31393         LDKu8slice ser_ref;
31394         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31395         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31396         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
31397         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
31398         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31399         return (int64_t)ret_conv;
31400 }
31401
31402 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
31403         LDKChannelCounterparty obj_conv;
31404         obj_conv.inner = (void*)(obj & (~1));
31405         obj_conv.is_owned = false;
31406         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31407         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
31408         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31409         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31410         CVec_u8Z_free(ret_var);
31411         return ret_arr;
31412 }
31413
31414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31415         LDKu8slice ser_ref;
31416         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31417         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31418         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
31419         *ret_conv = ChannelCounterparty_read(ser_ref);
31420         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31421         return (int64_t)ret_conv;
31422 }
31423
31424 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
31425         LDKChannelDetails obj_conv;
31426         obj_conv.inner = (void*)(obj & (~1));
31427         obj_conv.is_owned = false;
31428         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31429         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
31430         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31431         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31432         CVec_u8Z_free(ret_var);
31433         return ret_arr;
31434 }
31435
31436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31437         LDKu8slice ser_ref;
31438         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31439         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31440         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
31441         *ret_conv = ChannelDetails_read(ser_ref);
31442         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31443         return (int64_t)ret_conv;
31444 }
31445
31446 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
31447         LDKPhantomRouteHints obj_conv;
31448         obj_conv.inner = (void*)(obj & (~1));
31449         obj_conv.is_owned = false;
31450         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31451         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
31452         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31453         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31454         CVec_u8Z_free(ret_var);
31455         return ret_arr;
31456 }
31457
31458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31459         LDKu8slice ser_ref;
31460         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31461         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31462         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
31463         *ret_conv = PhantomRouteHints_read(ser_ref);
31464         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31465         return (int64_t)ret_conv;
31466 }
31467
31468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
31469         LDKChannelManager obj_conv;
31470         obj_conv.inner = (void*)(obj & (~1));
31471         obj_conv.is_owned = false;
31472         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31473         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
31474         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31475         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31476         CVec_u8Z_free(ret_var);
31477         return ret_arr;
31478 }
31479
31480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31481         LDKChannelManagerReadArgs this_obj_conv;
31482         this_obj_conv.inner = (void*)(this_obj & (~1));
31483         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31485         ChannelManagerReadArgs_free(this_obj_conv);
31486 }
31487
31488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
31489         LDKChannelManagerReadArgs this_ptr_conv;
31490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31491         this_ptr_conv.is_owned = false;
31492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31493         // WARNING: This object doesn't live past this scope, needs clone!
31494         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
31495         return ret_ret;
31496 }
31497
31498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31499         LDKChannelManagerReadArgs this_ptr_conv;
31500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31501         this_ptr_conv.is_owned = false;
31502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31503         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31504         CHECK_ACCESS(val_ptr);
31505         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
31506         if (val_conv.free == LDKKeysInterface_JCalls_free) {
31507                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31508                 LDKKeysInterface_JCalls_cloned(&val_conv);
31509         }
31510         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
31511 }
31512
31513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
31514         LDKChannelManagerReadArgs this_ptr_conv;
31515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31516         this_ptr_conv.is_owned = false;
31517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31518         // WARNING: This object doesn't live past this scope, needs clone!
31519         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
31520         return ret_ret;
31521 }
31522
31523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31524         LDKChannelManagerReadArgs this_ptr_conv;
31525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31526         this_ptr_conv.is_owned = false;
31527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31528         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31529         CHECK_ACCESS(val_ptr);
31530         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
31531         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
31532                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31533                 LDKFeeEstimator_JCalls_cloned(&val_conv);
31534         }
31535         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
31536 }
31537
31538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
31539         LDKChannelManagerReadArgs this_ptr_conv;
31540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31541         this_ptr_conv.is_owned = false;
31542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31543         // WARNING: This object doesn't live past this scope, needs clone!
31544         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
31545         return ret_ret;
31546 }
31547
31548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31549         LDKChannelManagerReadArgs this_ptr_conv;
31550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31551         this_ptr_conv.is_owned = false;
31552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31553         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31554         CHECK_ACCESS(val_ptr);
31555         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
31556         if (val_conv.free == LDKWatch_JCalls_free) {
31557                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31558                 LDKWatch_JCalls_cloned(&val_conv);
31559         }
31560         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
31561 }
31562
31563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
31564         LDKChannelManagerReadArgs this_ptr_conv;
31565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31566         this_ptr_conv.is_owned = false;
31567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31568         // WARNING: This object doesn't live past this scope, needs clone!
31569         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
31570         return ret_ret;
31571 }
31572
31573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31574         LDKChannelManagerReadArgs this_ptr_conv;
31575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31576         this_ptr_conv.is_owned = false;
31577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31578         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31579         CHECK_ACCESS(val_ptr);
31580         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
31581         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
31582                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31583                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
31584         }
31585         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
31586 }
31587
31588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
31589         LDKChannelManagerReadArgs this_ptr_conv;
31590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31591         this_ptr_conv.is_owned = false;
31592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31593         // WARNING: This object doesn't live past this scope, needs clone!
31594         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
31595         return ret_ret;
31596 }
31597
31598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31599         LDKChannelManagerReadArgs this_ptr_conv;
31600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31601         this_ptr_conv.is_owned = false;
31602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31603         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31604         CHECK_ACCESS(val_ptr);
31605         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
31606         if (val_conv.free == LDKLogger_JCalls_free) {
31607                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31608                 LDKLogger_JCalls_cloned(&val_conv);
31609         }
31610         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
31611 }
31612
31613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
31614         LDKChannelManagerReadArgs this_ptr_conv;
31615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31616         this_ptr_conv.is_owned = false;
31617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31618         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
31619         int64_t ret_ref = 0;
31620         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31621         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31623         ret_ref = (uintptr_t)ret_var.inner;
31624         if (ret_var.is_owned) {
31625                 ret_ref |= 1;
31626         }
31627         return ret_ref;
31628 }
31629
31630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31631         LDKChannelManagerReadArgs this_ptr_conv;
31632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31633         this_ptr_conv.is_owned = false;
31634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31635         LDKUserConfig val_conv;
31636         val_conv.inner = (void*)(val & (~1));
31637         val_conv.is_owned = (val & 1) || (val == 0);
31638         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31639         val_conv = UserConfig_clone(&val_conv);
31640         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
31641 }
31642
31643 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) {
31644         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
31645         CHECK_ACCESS(keys_manager_ptr);
31646         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
31647         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
31648                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31649                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
31650         }
31651         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
31652         CHECK_ACCESS(fee_estimator_ptr);
31653         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
31654         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
31655                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31656                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
31657         }
31658         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
31659         CHECK_ACCESS(chain_monitor_ptr);
31660         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
31661         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
31662                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31663                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
31664         }
31665         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
31666         CHECK_ACCESS(tx_broadcaster_ptr);
31667         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
31668         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
31669                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31670                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
31671         }
31672         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
31673         CHECK_ACCESS(logger_ptr);
31674         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
31675         if (logger_conv.free == LDKLogger_JCalls_free) {
31676                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31677                 LDKLogger_JCalls_cloned(&logger_conv);
31678         }
31679         LDKUserConfig default_config_conv;
31680         default_config_conv.inner = (void*)(default_config & (~1));
31681         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
31682         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
31683         default_config_conv = UserConfig_clone(&default_config_conv);
31684         LDKCVec_ChannelMonitorZ channel_monitors_constr;
31685         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
31686         if (channel_monitors_constr.datalen > 0)
31687                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
31688         else
31689                 channel_monitors_constr.data = NULL;
31690         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
31691         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
31692                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
31693                 LDKChannelMonitor channel_monitors_conv_16_conv;
31694                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
31695                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
31696                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
31697                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
31698         }
31699         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
31700         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);
31701         int64_t ret_ref = 0;
31702         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31703         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31705         ret_ref = (uintptr_t)ret_var.inner;
31706         if (ret_var.is_owned) {
31707                 ret_ref |= 1;
31708         }
31709         return ret_ref;
31710 }
31711
31712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
31713         LDKu8slice ser_ref;
31714         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31715         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31716         LDKChannelManagerReadArgs arg_conv;
31717         arg_conv.inner = (void*)(arg & (~1));
31718         arg_conv.is_owned = (arg & 1) || (arg == 0);
31719         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31720         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
31721         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
31722         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
31723         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31724         return (int64_t)ret_conv;
31725 }
31726
31727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31728         LDKExpandedKey this_obj_conv;
31729         this_obj_conv.inner = (void*)(this_obj & (~1));
31730         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31732         ExpandedKey_free(this_obj_conv);
31733 }
31734
31735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
31736         unsigned char key_material_arr[32];
31737         CHECK((*env)->GetArrayLength(env, key_material) == 32);
31738         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
31739         unsigned char (*key_material_ref)[32] = &key_material_arr;
31740         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
31741         int64_t ret_ref = 0;
31742         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31743         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31745         ret_ref = (uintptr_t)ret_var.inner;
31746         if (ret_var.is_owned) {
31747                 ret_ref |= 1;
31748         }
31749         return ret_ref;
31750 }
31751
31752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create(JNIEnv *env, jclass clz, int64_t keys, int64_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t keys_manager, int64_t current_time) {
31753         LDKExpandedKey keys_conv;
31754         keys_conv.inner = (void*)(keys & (~1));
31755         keys_conv.is_owned = false;
31756         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
31757         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31758         CHECK_ACCESS(min_value_msat_ptr);
31759         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31760         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31761         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
31762         if (!(keys_manager & 1)) { CHECK_ACCESS(keys_manager_ptr); }
31763         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
31764         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
31765         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
31766         return (int64_t)ret_conv;
31767 }
31768
31769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1from_1hash(JNIEnv *env, jclass clz, int64_t keys, int64_t min_value_msat, int8_tArray payment_hash, int32_t invoice_expiry_delta_secs, int64_t current_time) {
31770         LDKExpandedKey keys_conv;
31771         keys_conv.inner = (void*)(keys & (~1));
31772         keys_conv.is_owned = false;
31773         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
31774         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31775         CHECK_ACCESS(min_value_msat_ptr);
31776         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31777         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31778         LDKThirtyTwoBytes payment_hash_ref;
31779         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31780         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31781         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
31782         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
31783         return (int64_t)ret_conv;
31784 }
31785
31786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31787         LDKDecodeError this_obj_conv;
31788         this_obj_conv.inner = (void*)(this_obj & (~1));
31789         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31791         DecodeError_free(this_obj_conv);
31792 }
31793
31794 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
31795         LDKDecodeError ret_var = DecodeError_clone(arg);
31796 int64_t ret_ref = 0;
31797 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31798 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31799 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31800 ret_ref = (uintptr_t)ret_var.inner;
31801 if (ret_var.is_owned) {
31802         ret_ref |= 1;
31803 }
31804         return ret_ref;
31805 }
31806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31807         LDKDecodeError arg_conv;
31808         arg_conv.inner = (void*)(arg & (~1));
31809         arg_conv.is_owned = false;
31810         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31811         int64_t ret_conv = DecodeError_clone_ptr(&arg_conv);
31812         return ret_conv;
31813 }
31814
31815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31816         LDKDecodeError orig_conv;
31817         orig_conv.inner = (void*)(orig & (~1));
31818         orig_conv.is_owned = false;
31819         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31820         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
31821         int64_t ret_ref = 0;
31822         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31823         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31825         ret_ref = (uintptr_t)ret_var.inner;
31826         if (ret_var.is_owned) {
31827                 ret_ref |= 1;
31828         }
31829         return ret_ref;
31830 }
31831
31832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31833         LDKInit this_obj_conv;
31834         this_obj_conv.inner = (void*)(this_obj & (~1));
31835         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31837         Init_free(this_obj_conv);
31838 }
31839
31840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
31841         LDKInit this_ptr_conv;
31842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31843         this_ptr_conv.is_owned = false;
31844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31845         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
31846         int64_t ret_ref = 0;
31847         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31848         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31850         ret_ref = (uintptr_t)ret_var.inner;
31851         if (ret_var.is_owned) {
31852                 ret_ref |= 1;
31853         }
31854         return ret_ref;
31855 }
31856
31857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31858         LDKInit this_ptr_conv;
31859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31860         this_ptr_conv.is_owned = false;
31861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31862         LDKInitFeatures val_conv;
31863         val_conv.inner = (void*)(val & (~1));
31864         val_conv.is_owned = (val & 1) || (val == 0);
31865         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31866         val_conv = InitFeatures_clone(&val_conv);
31867         Init_set_features(&this_ptr_conv, val_conv);
31868 }
31869
31870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
31871         LDKInit this_ptr_conv;
31872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31873         this_ptr_conv.is_owned = false;
31874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31875         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
31876         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
31877         int64_t ret_ref = (uintptr_t)ret_copy;
31878         return ret_ref;
31879 }
31880
31881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31882         LDKInit this_ptr_conv;
31883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31884         this_ptr_conv.is_owned = false;
31885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31886         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31887         CHECK_ACCESS(val_ptr);
31888         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
31889         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
31890         Init_set_remote_network_address(&this_ptr_conv, val_conv);
31891 }
31892
31893 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) {
31894         LDKInitFeatures features_arg_conv;
31895         features_arg_conv.inner = (void*)(features_arg & (~1));
31896         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
31897         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
31898         features_arg_conv = InitFeatures_clone(&features_arg_conv);
31899         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
31900         CHECK_ACCESS(remote_network_address_arg_ptr);
31901         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
31902         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
31903         int64_t ret_ref = 0;
31904         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31905         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31907         ret_ref = (uintptr_t)ret_var.inner;
31908         if (ret_var.is_owned) {
31909                 ret_ref |= 1;
31910         }
31911         return ret_ref;
31912 }
31913
31914 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
31915         LDKInit ret_var = Init_clone(arg);
31916 int64_t ret_ref = 0;
31917 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31918 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31919 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31920 ret_ref = (uintptr_t)ret_var.inner;
31921 if (ret_var.is_owned) {
31922         ret_ref |= 1;
31923 }
31924         return ret_ref;
31925 }
31926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31927         LDKInit arg_conv;
31928         arg_conv.inner = (void*)(arg & (~1));
31929         arg_conv.is_owned = false;
31930         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31931         int64_t ret_conv = Init_clone_ptr(&arg_conv);
31932         return ret_conv;
31933 }
31934
31935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31936         LDKInit orig_conv;
31937         orig_conv.inner = (void*)(orig & (~1));
31938         orig_conv.is_owned = false;
31939         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31940         LDKInit ret_var = Init_clone(&orig_conv);
31941         int64_t ret_ref = 0;
31942         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31943         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31945         ret_ref = (uintptr_t)ret_var.inner;
31946         if (ret_var.is_owned) {
31947                 ret_ref |= 1;
31948         }
31949         return ret_ref;
31950 }
31951
31952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31953         LDKErrorMessage this_obj_conv;
31954         this_obj_conv.inner = (void*)(this_obj & (~1));
31955         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31957         ErrorMessage_free(this_obj_conv);
31958 }
31959
31960 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31961         LDKErrorMessage this_ptr_conv;
31962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31963         this_ptr_conv.is_owned = false;
31964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31965         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31966         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
31967         return ret_arr;
31968 }
31969
31970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31971         LDKErrorMessage this_ptr_conv;
31972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31973         this_ptr_conv.is_owned = false;
31974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31975         LDKThirtyTwoBytes val_ref;
31976         CHECK((*env)->GetArrayLength(env, val) == 32);
31977         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31978         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
31979 }
31980
31981 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
31982         LDKErrorMessage this_ptr_conv;
31983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31984         this_ptr_conv.is_owned = false;
31985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31986         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
31987         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
31988         Str_free(ret_str);
31989         return ret_conv;
31990 }
31991
31992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
31993         LDKErrorMessage this_ptr_conv;
31994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31995         this_ptr_conv.is_owned = false;
31996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31997         LDKStr val_conv = java_to_owned_str(env, val);
31998         ErrorMessage_set_data(&this_ptr_conv, val_conv);
31999 }
32000
32001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
32002         LDKThirtyTwoBytes channel_id_arg_ref;
32003         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32004         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32005         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
32006         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
32007         int64_t ret_ref = 0;
32008         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32009         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32011         ret_ref = (uintptr_t)ret_var.inner;
32012         if (ret_var.is_owned) {
32013                 ret_ref |= 1;
32014         }
32015         return ret_ref;
32016 }
32017
32018 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
32019         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
32020 int64_t ret_ref = 0;
32021 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32022 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32023 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32024 ret_ref = (uintptr_t)ret_var.inner;
32025 if (ret_var.is_owned) {
32026         ret_ref |= 1;
32027 }
32028         return ret_ref;
32029 }
32030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32031         LDKErrorMessage arg_conv;
32032         arg_conv.inner = (void*)(arg & (~1));
32033         arg_conv.is_owned = false;
32034         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32035         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
32036         return ret_conv;
32037 }
32038
32039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32040         LDKErrorMessage orig_conv;
32041         orig_conv.inner = (void*)(orig & (~1));
32042         orig_conv.is_owned = false;
32043         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32044         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
32045         int64_t ret_ref = 0;
32046         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32047         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32049         ret_ref = (uintptr_t)ret_var.inner;
32050         if (ret_var.is_owned) {
32051                 ret_ref |= 1;
32052         }
32053         return ret_ref;
32054 }
32055
32056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32057         LDKWarningMessage this_obj_conv;
32058         this_obj_conv.inner = (void*)(this_obj & (~1));
32059         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32061         WarningMessage_free(this_obj_conv);
32062 }
32063
32064 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32065         LDKWarningMessage this_ptr_conv;
32066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32067         this_ptr_conv.is_owned = false;
32068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32069         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32070         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
32071         return ret_arr;
32072 }
32073
32074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32075         LDKWarningMessage this_ptr_conv;
32076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32077         this_ptr_conv.is_owned = false;
32078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32079         LDKThirtyTwoBytes val_ref;
32080         CHECK((*env)->GetArrayLength(env, val) == 32);
32081         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32082         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
32083 }
32084
32085 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
32086         LDKWarningMessage this_ptr_conv;
32087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32088         this_ptr_conv.is_owned = false;
32089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32090         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
32091         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
32092         Str_free(ret_str);
32093         return ret_conv;
32094 }
32095
32096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
32097         LDKWarningMessage this_ptr_conv;
32098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32099         this_ptr_conv.is_owned = false;
32100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32101         LDKStr val_conv = java_to_owned_str(env, val);
32102         WarningMessage_set_data(&this_ptr_conv, val_conv);
32103 }
32104
32105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
32106         LDKThirtyTwoBytes channel_id_arg_ref;
32107         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32108         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32109         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
32110         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
32111         int64_t ret_ref = 0;
32112         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32113         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32115         ret_ref = (uintptr_t)ret_var.inner;
32116         if (ret_var.is_owned) {
32117                 ret_ref |= 1;
32118         }
32119         return ret_ref;
32120 }
32121
32122 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
32123         LDKWarningMessage ret_var = WarningMessage_clone(arg);
32124 int64_t ret_ref = 0;
32125 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32126 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32127 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32128 ret_ref = (uintptr_t)ret_var.inner;
32129 if (ret_var.is_owned) {
32130         ret_ref |= 1;
32131 }
32132         return ret_ref;
32133 }
32134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32135         LDKWarningMessage arg_conv;
32136         arg_conv.inner = (void*)(arg & (~1));
32137         arg_conv.is_owned = false;
32138         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32139         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
32140         return ret_conv;
32141 }
32142
32143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32144         LDKWarningMessage orig_conv;
32145         orig_conv.inner = (void*)(orig & (~1));
32146         orig_conv.is_owned = false;
32147         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32148         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
32149         int64_t ret_ref = 0;
32150         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32151         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32153         ret_ref = (uintptr_t)ret_var.inner;
32154         if (ret_var.is_owned) {
32155                 ret_ref |= 1;
32156         }
32157         return ret_ref;
32158 }
32159
32160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32161         LDKPing this_obj_conv;
32162         this_obj_conv.inner = (void*)(this_obj & (~1));
32163         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32165         Ping_free(this_obj_conv);
32166 }
32167
32168 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
32169         LDKPing this_ptr_conv;
32170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32171         this_ptr_conv.is_owned = false;
32172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32173         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
32174         return ret_conv;
32175 }
32176
32177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32178         LDKPing this_ptr_conv;
32179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32180         this_ptr_conv.is_owned = false;
32181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32182         Ping_set_ponglen(&this_ptr_conv, val);
32183 }
32184
32185 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
32186         LDKPing this_ptr_conv;
32187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32188         this_ptr_conv.is_owned = false;
32189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32190         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
32191         return ret_conv;
32192 }
32193
32194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32195         LDKPing this_ptr_conv;
32196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32197         this_ptr_conv.is_owned = false;
32198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32199         Ping_set_byteslen(&this_ptr_conv, val);
32200 }
32201
32202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
32203         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
32204         int64_t ret_ref = 0;
32205         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32206         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32208         ret_ref = (uintptr_t)ret_var.inner;
32209         if (ret_var.is_owned) {
32210                 ret_ref |= 1;
32211         }
32212         return ret_ref;
32213 }
32214
32215 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
32216         LDKPing ret_var = Ping_clone(arg);
32217 int64_t ret_ref = 0;
32218 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32219 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32220 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32221 ret_ref = (uintptr_t)ret_var.inner;
32222 if (ret_var.is_owned) {
32223         ret_ref |= 1;
32224 }
32225         return ret_ref;
32226 }
32227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32228         LDKPing arg_conv;
32229         arg_conv.inner = (void*)(arg & (~1));
32230         arg_conv.is_owned = false;
32231         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32232         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
32233         return ret_conv;
32234 }
32235
32236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32237         LDKPing orig_conv;
32238         orig_conv.inner = (void*)(orig & (~1));
32239         orig_conv.is_owned = false;
32240         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32241         LDKPing ret_var = Ping_clone(&orig_conv);
32242         int64_t ret_ref = 0;
32243         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32244         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32246         ret_ref = (uintptr_t)ret_var.inner;
32247         if (ret_var.is_owned) {
32248                 ret_ref |= 1;
32249         }
32250         return ret_ref;
32251 }
32252
32253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32254         LDKPong this_obj_conv;
32255         this_obj_conv.inner = (void*)(this_obj & (~1));
32256         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32258         Pong_free(this_obj_conv);
32259 }
32260
32261 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
32262         LDKPong this_ptr_conv;
32263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32264         this_ptr_conv.is_owned = false;
32265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32266         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
32267         return ret_conv;
32268 }
32269
32270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32271         LDKPong this_ptr_conv;
32272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32273         this_ptr_conv.is_owned = false;
32274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32275         Pong_set_byteslen(&this_ptr_conv, val);
32276 }
32277
32278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
32279         LDKPong ret_var = Pong_new(byteslen_arg);
32280         int64_t ret_ref = 0;
32281         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32282         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32284         ret_ref = (uintptr_t)ret_var.inner;
32285         if (ret_var.is_owned) {
32286                 ret_ref |= 1;
32287         }
32288         return ret_ref;
32289 }
32290
32291 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
32292         LDKPong ret_var = Pong_clone(arg);
32293 int64_t ret_ref = 0;
32294 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32295 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32296 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32297 ret_ref = (uintptr_t)ret_var.inner;
32298 if (ret_var.is_owned) {
32299         ret_ref |= 1;
32300 }
32301         return ret_ref;
32302 }
32303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32304         LDKPong arg_conv;
32305         arg_conv.inner = (void*)(arg & (~1));
32306         arg_conv.is_owned = false;
32307         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32308         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
32309         return ret_conv;
32310 }
32311
32312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32313         LDKPong orig_conv;
32314         orig_conv.inner = (void*)(orig & (~1));
32315         orig_conv.is_owned = false;
32316         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32317         LDKPong ret_var = Pong_clone(&orig_conv);
32318         int64_t ret_ref = 0;
32319         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32320         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32322         ret_ref = (uintptr_t)ret_var.inner;
32323         if (ret_var.is_owned) {
32324                 ret_ref |= 1;
32325         }
32326         return ret_ref;
32327 }
32328
32329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32330         LDKOpenChannel this_obj_conv;
32331         this_obj_conv.inner = (void*)(this_obj & (~1));
32332         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32334         OpenChannel_free(this_obj_conv);
32335 }
32336
32337 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
32338         LDKOpenChannel this_ptr_conv;
32339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32340         this_ptr_conv.is_owned = false;
32341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32342         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32343         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
32344         return ret_arr;
32345 }
32346
32347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32348         LDKOpenChannel this_ptr_conv;
32349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32350         this_ptr_conv.is_owned = false;
32351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32352         LDKThirtyTwoBytes val_ref;
32353         CHECK((*env)->GetArrayLength(env, val) == 32);
32354         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32355         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
32356 }
32357
32358 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32359         LDKOpenChannel this_ptr_conv;
32360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32361         this_ptr_conv.is_owned = false;
32362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32363         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32364         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
32365         return ret_arr;
32366 }
32367
32368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32369         LDKOpenChannel this_ptr_conv;
32370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32371         this_ptr_conv.is_owned = false;
32372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32373         LDKThirtyTwoBytes val_ref;
32374         CHECK((*env)->GetArrayLength(env, val) == 32);
32375         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32376         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
32377 }
32378
32379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32380         LDKOpenChannel this_ptr_conv;
32381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32382         this_ptr_conv.is_owned = false;
32383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32384         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
32385         return ret_conv;
32386 }
32387
32388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32389         LDKOpenChannel this_ptr_conv;
32390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32391         this_ptr_conv.is_owned = false;
32392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32393         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
32394 }
32395
32396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32397         LDKOpenChannel this_ptr_conv;
32398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32399         this_ptr_conv.is_owned = false;
32400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32401         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
32402         return ret_conv;
32403 }
32404
32405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32406         LDKOpenChannel this_ptr_conv;
32407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32408         this_ptr_conv.is_owned = false;
32409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32410         OpenChannel_set_push_msat(&this_ptr_conv, val);
32411 }
32412
32413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32414         LDKOpenChannel this_ptr_conv;
32415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32416         this_ptr_conv.is_owned = false;
32417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32418         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
32419         return ret_conv;
32420 }
32421
32422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32423         LDKOpenChannel this_ptr_conv;
32424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32425         this_ptr_conv.is_owned = false;
32426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32427         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
32428 }
32429
32430 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) {
32431         LDKOpenChannel this_ptr_conv;
32432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32433         this_ptr_conv.is_owned = false;
32434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32435         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
32436         return ret_conv;
32437 }
32438
32439 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) {
32440         LDKOpenChannel this_ptr_conv;
32441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32442         this_ptr_conv.is_owned = false;
32443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32444         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
32445 }
32446
32447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32448         LDKOpenChannel this_ptr_conv;
32449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32450         this_ptr_conv.is_owned = false;
32451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32452         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
32453         return ret_conv;
32454 }
32455
32456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32457         LDKOpenChannel this_ptr_conv;
32458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32459         this_ptr_conv.is_owned = false;
32460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32461         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
32462 }
32463
32464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32465         LDKOpenChannel this_ptr_conv;
32466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32467         this_ptr_conv.is_owned = false;
32468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32469         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
32470         return ret_conv;
32471 }
32472
32473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32474         LDKOpenChannel this_ptr_conv;
32475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32476         this_ptr_conv.is_owned = false;
32477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32478         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
32479 }
32480
32481 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
32482         LDKOpenChannel 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         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
32487         return ret_conv;
32488 }
32489
32490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32491         LDKOpenChannel this_ptr_conv;
32492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32493         this_ptr_conv.is_owned = false;
32494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32495         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
32496 }
32497
32498 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32499         LDKOpenChannel this_ptr_conv;
32500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32501         this_ptr_conv.is_owned = false;
32502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32503         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
32504         return ret_conv;
32505 }
32506
32507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32508         LDKOpenChannel this_ptr_conv;
32509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32510         this_ptr_conv.is_owned = false;
32511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32512         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
32513 }
32514
32515 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
32516         LDKOpenChannel this_ptr_conv;
32517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32518         this_ptr_conv.is_owned = false;
32519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32520         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
32521         return ret_conv;
32522 }
32523
32524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32525         LDKOpenChannel this_ptr_conv;
32526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32527         this_ptr_conv.is_owned = false;
32528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32529         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
32530 }
32531
32532 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32533         LDKOpenChannel this_ptr_conv;
32534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32535         this_ptr_conv.is_owned = false;
32536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32537         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32538         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
32539         return ret_arr;
32540 }
32541
32542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32543         LDKOpenChannel this_ptr_conv;
32544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32545         this_ptr_conv.is_owned = false;
32546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32547         LDKPublicKey val_ref;
32548         CHECK((*env)->GetArrayLength(env, val) == 33);
32549         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32550         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
32551 }
32552
32553 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32554         LDKOpenChannel this_ptr_conv;
32555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32556         this_ptr_conv.is_owned = false;
32557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32558         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32559         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
32560         return ret_arr;
32561 }
32562
32563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32564         LDKOpenChannel this_ptr_conv;
32565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32566         this_ptr_conv.is_owned = false;
32567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32568         LDKPublicKey val_ref;
32569         CHECK((*env)->GetArrayLength(env, val) == 33);
32570         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32571         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
32572 }
32573
32574 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32575         LDKOpenChannel this_ptr_conv;
32576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32577         this_ptr_conv.is_owned = false;
32578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32579         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32580         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
32581         return ret_arr;
32582 }
32583
32584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32585         LDKOpenChannel this_ptr_conv;
32586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32587         this_ptr_conv.is_owned = false;
32588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32589         LDKPublicKey val_ref;
32590         CHECK((*env)->GetArrayLength(env, val) == 33);
32591         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32592         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
32593 }
32594
32595 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32596         LDKOpenChannel this_ptr_conv;
32597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32598         this_ptr_conv.is_owned = false;
32599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32600         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32601         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
32602         return ret_arr;
32603 }
32604
32605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32606         LDKOpenChannel this_ptr_conv;
32607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32608         this_ptr_conv.is_owned = false;
32609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32610         LDKPublicKey val_ref;
32611         CHECK((*env)->GetArrayLength(env, val) == 33);
32612         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32613         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
32614 }
32615
32616 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32617         LDKOpenChannel this_ptr_conv;
32618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32619         this_ptr_conv.is_owned = false;
32620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32621         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32622         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
32623         return ret_arr;
32624 }
32625
32626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32627         LDKOpenChannel this_ptr_conv;
32628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32629         this_ptr_conv.is_owned = false;
32630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32631         LDKPublicKey val_ref;
32632         CHECK((*env)->GetArrayLength(env, val) == 33);
32633         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32634         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
32635 }
32636
32637 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32638         LDKOpenChannel this_ptr_conv;
32639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32640         this_ptr_conv.is_owned = false;
32641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32642         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32643         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
32644         return ret_arr;
32645 }
32646
32647 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) {
32648         LDKOpenChannel this_ptr_conv;
32649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32650         this_ptr_conv.is_owned = false;
32651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32652         LDKPublicKey val_ref;
32653         CHECK((*env)->GetArrayLength(env, val) == 33);
32654         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32655         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
32656 }
32657
32658 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
32659         LDKOpenChannel this_ptr_conv;
32660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32661         this_ptr_conv.is_owned = false;
32662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32663         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
32664         return ret_conv;
32665 }
32666
32667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
32668         LDKOpenChannel this_ptr_conv;
32669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32670         this_ptr_conv.is_owned = false;
32671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32672         OpenChannel_set_channel_flags(&this_ptr_conv, val);
32673 }
32674
32675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
32676         LDKOpenChannel this_ptr_conv;
32677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32678         this_ptr_conv.is_owned = false;
32679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32680         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
32681         int64_t ret_ref = 0;
32682         if ((uintptr_t)ret_var.inner > 4096) {
32683                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32684                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32686                 ret_ref = (uintptr_t)ret_var.inner;
32687                 if (ret_var.is_owned) {
32688                         ret_ref |= 1;
32689                 }
32690         }
32691         return ret_ref;
32692 }
32693
32694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32695         LDKOpenChannel this_ptr_conv;
32696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32697         this_ptr_conv.is_owned = false;
32698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32699         LDKChannelTypeFeatures val_conv;
32700         val_conv.inner = (void*)(val & (~1));
32701         val_conv.is_owned = (val & 1) || (val == 0);
32702         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32703         val_conv = ChannelTypeFeatures_clone(&val_conv);
32704         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
32705 }
32706
32707 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
32708         LDKOpenChannel ret_var = OpenChannel_clone(arg);
32709 int64_t ret_ref = 0;
32710 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32711 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32712 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32713 ret_ref = (uintptr_t)ret_var.inner;
32714 if (ret_var.is_owned) {
32715         ret_ref |= 1;
32716 }
32717         return ret_ref;
32718 }
32719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32720         LDKOpenChannel arg_conv;
32721         arg_conv.inner = (void*)(arg & (~1));
32722         arg_conv.is_owned = false;
32723         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32724         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
32725         return ret_conv;
32726 }
32727
32728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32729         LDKOpenChannel orig_conv;
32730         orig_conv.inner = (void*)(orig & (~1));
32731         orig_conv.is_owned = false;
32732         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32733         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
32734         int64_t ret_ref = 0;
32735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32738         ret_ref = (uintptr_t)ret_var.inner;
32739         if (ret_var.is_owned) {
32740                 ret_ref |= 1;
32741         }
32742         return ret_ref;
32743 }
32744
32745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32746         LDKAcceptChannel this_obj_conv;
32747         this_obj_conv.inner = (void*)(this_obj & (~1));
32748         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32750         AcceptChannel_free(this_obj_conv);
32751 }
32752
32753 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32754         LDKAcceptChannel this_ptr_conv;
32755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32756         this_ptr_conv.is_owned = false;
32757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32758         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32759         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
32760         return ret_arr;
32761 }
32762
32763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32764         LDKAcceptChannel this_ptr_conv;
32765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32766         this_ptr_conv.is_owned = false;
32767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32768         LDKThirtyTwoBytes val_ref;
32769         CHECK((*env)->GetArrayLength(env, val) == 32);
32770         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32771         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
32772 }
32773
32774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32775         LDKAcceptChannel this_ptr_conv;
32776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32777         this_ptr_conv.is_owned = false;
32778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32779         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
32780         return ret_conv;
32781 }
32782
32783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32784         LDKAcceptChannel this_ptr_conv;
32785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32786         this_ptr_conv.is_owned = false;
32787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32788         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
32789 }
32790
32791 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) {
32792         LDKAcceptChannel this_ptr_conv;
32793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32794         this_ptr_conv.is_owned = false;
32795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32796         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
32797         return ret_conv;
32798 }
32799
32800 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) {
32801         LDKAcceptChannel this_ptr_conv;
32802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32803         this_ptr_conv.is_owned = false;
32804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32805         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
32806 }
32807
32808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32809         LDKAcceptChannel this_ptr_conv;
32810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32811         this_ptr_conv.is_owned = false;
32812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32813         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
32814         return ret_conv;
32815 }
32816
32817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32818         LDKAcceptChannel this_ptr_conv;
32819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32820         this_ptr_conv.is_owned = false;
32821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32822         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
32823 }
32824
32825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32826         LDKAcceptChannel this_ptr_conv;
32827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32828         this_ptr_conv.is_owned = false;
32829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32830         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
32831         return ret_conv;
32832 }
32833
32834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32835         LDKAcceptChannel this_ptr_conv;
32836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32837         this_ptr_conv.is_owned = false;
32838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32839         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
32840 }
32841
32842 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
32843         LDKAcceptChannel this_ptr_conv;
32844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32845         this_ptr_conv.is_owned = false;
32846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32847         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
32848         return ret_conv;
32849 }
32850
32851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32852         LDKAcceptChannel this_ptr_conv;
32853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32854         this_ptr_conv.is_owned = false;
32855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32856         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
32857 }
32858
32859 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32860         LDKAcceptChannel this_ptr_conv;
32861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32862         this_ptr_conv.is_owned = false;
32863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32864         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
32865         return ret_conv;
32866 }
32867
32868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32869         LDKAcceptChannel this_ptr_conv;
32870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32871         this_ptr_conv.is_owned = false;
32872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32873         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
32874 }
32875
32876 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
32877         LDKAcceptChannel this_ptr_conv;
32878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32879         this_ptr_conv.is_owned = false;
32880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32881         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
32882         return ret_conv;
32883 }
32884
32885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32886         LDKAcceptChannel this_ptr_conv;
32887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32888         this_ptr_conv.is_owned = false;
32889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32890         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
32891 }
32892
32893 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32894         LDKAcceptChannel this_ptr_conv;
32895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32896         this_ptr_conv.is_owned = false;
32897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32898         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32899         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
32900         return ret_arr;
32901 }
32902
32903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32904         LDKAcceptChannel this_ptr_conv;
32905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32906         this_ptr_conv.is_owned = false;
32907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32908         LDKPublicKey val_ref;
32909         CHECK((*env)->GetArrayLength(env, val) == 33);
32910         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32911         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
32912 }
32913
32914 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32915         LDKAcceptChannel this_ptr_conv;
32916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32917         this_ptr_conv.is_owned = false;
32918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32919         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32920         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
32921         return ret_arr;
32922 }
32923
32924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32925         LDKAcceptChannel this_ptr_conv;
32926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32927         this_ptr_conv.is_owned = false;
32928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32929         LDKPublicKey val_ref;
32930         CHECK((*env)->GetArrayLength(env, val) == 33);
32931         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32932         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
32933 }
32934
32935 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32936         LDKAcceptChannel this_ptr_conv;
32937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32938         this_ptr_conv.is_owned = false;
32939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32940         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32941         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
32942         return ret_arr;
32943 }
32944
32945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32946         LDKAcceptChannel this_ptr_conv;
32947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32948         this_ptr_conv.is_owned = false;
32949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32950         LDKPublicKey val_ref;
32951         CHECK((*env)->GetArrayLength(env, val) == 33);
32952         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32953         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
32954 }
32955
32956 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32957         LDKAcceptChannel this_ptr_conv;
32958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32959         this_ptr_conv.is_owned = false;
32960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32961         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32962         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
32963         return ret_arr;
32964 }
32965
32966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32967         LDKAcceptChannel this_ptr_conv;
32968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32969         this_ptr_conv.is_owned = false;
32970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32971         LDKPublicKey val_ref;
32972         CHECK((*env)->GetArrayLength(env, val) == 33);
32973         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32974         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
32975 }
32976
32977 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32978         LDKAcceptChannel this_ptr_conv;
32979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32980         this_ptr_conv.is_owned = false;
32981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32982         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32983         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
32984         return ret_arr;
32985 }
32986
32987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32988         LDKAcceptChannel this_ptr_conv;
32989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32990         this_ptr_conv.is_owned = false;
32991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32992         LDKPublicKey val_ref;
32993         CHECK((*env)->GetArrayLength(env, val) == 33);
32994         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32995         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
32996 }
32997
32998 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32999         LDKAcceptChannel this_ptr_conv;
33000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33001         this_ptr_conv.is_owned = false;
33002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33003         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33004         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
33005         return ret_arr;
33006 }
33007
33008 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) {
33009         LDKAcceptChannel this_ptr_conv;
33010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33011         this_ptr_conv.is_owned = false;
33012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33013         LDKPublicKey val_ref;
33014         CHECK((*env)->GetArrayLength(env, val) == 33);
33015         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33016         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
33017 }
33018
33019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
33020         LDKAcceptChannel this_ptr_conv;
33021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33022         this_ptr_conv.is_owned = false;
33023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33024         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
33025         int64_t ret_ref = 0;
33026         if ((uintptr_t)ret_var.inner > 4096) {
33027                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33028                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33030                 ret_ref = (uintptr_t)ret_var.inner;
33031                 if (ret_var.is_owned) {
33032                         ret_ref |= 1;
33033                 }
33034         }
33035         return ret_ref;
33036 }
33037
33038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33039         LDKAcceptChannel this_ptr_conv;
33040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33041         this_ptr_conv.is_owned = false;
33042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33043         LDKChannelTypeFeatures val_conv;
33044         val_conv.inner = (void*)(val & (~1));
33045         val_conv.is_owned = (val & 1) || (val == 0);
33046         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33047         val_conv = ChannelTypeFeatures_clone(&val_conv);
33048         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
33049 }
33050
33051 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
33052         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
33053 int64_t ret_ref = 0;
33054 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33055 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33056 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33057 ret_ref = (uintptr_t)ret_var.inner;
33058 if (ret_var.is_owned) {
33059         ret_ref |= 1;
33060 }
33061         return ret_ref;
33062 }
33063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33064         LDKAcceptChannel arg_conv;
33065         arg_conv.inner = (void*)(arg & (~1));
33066         arg_conv.is_owned = false;
33067         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33068         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
33069         return ret_conv;
33070 }
33071
33072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33073         LDKAcceptChannel orig_conv;
33074         orig_conv.inner = (void*)(orig & (~1));
33075         orig_conv.is_owned = false;
33076         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33077         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
33078         int64_t ret_ref = 0;
33079         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33080         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33082         ret_ref = (uintptr_t)ret_var.inner;
33083         if (ret_var.is_owned) {
33084                 ret_ref |= 1;
33085         }
33086         return ret_ref;
33087 }
33088
33089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33090         LDKFundingCreated this_obj_conv;
33091         this_obj_conv.inner = (void*)(this_obj & (~1));
33092         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33094         FundingCreated_free(this_obj_conv);
33095 }
33096
33097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33098         LDKFundingCreated this_ptr_conv;
33099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33100         this_ptr_conv.is_owned = false;
33101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33102         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33103         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
33104         return ret_arr;
33105 }
33106
33107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33108         LDKFundingCreated this_ptr_conv;
33109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33110         this_ptr_conv.is_owned = false;
33111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33112         LDKThirtyTwoBytes val_ref;
33113         CHECK((*env)->GetArrayLength(env, val) == 32);
33114         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33115         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
33116 }
33117
33118 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
33119         LDKFundingCreated this_ptr_conv;
33120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33121         this_ptr_conv.is_owned = false;
33122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33123         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33124         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
33125         return ret_arr;
33126 }
33127
33128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33129         LDKFundingCreated this_ptr_conv;
33130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33131         this_ptr_conv.is_owned = false;
33132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33133         LDKThirtyTwoBytes val_ref;
33134         CHECK((*env)->GetArrayLength(env, val) == 32);
33135         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33136         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
33137 }
33138
33139 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
33140         LDKFundingCreated this_ptr_conv;
33141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33142         this_ptr_conv.is_owned = false;
33143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33144         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
33145         return ret_conv;
33146 }
33147
33148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33149         LDKFundingCreated this_ptr_conv;
33150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33151         this_ptr_conv.is_owned = false;
33152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33153         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
33154 }
33155
33156 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33157         LDKFundingCreated this_ptr_conv;
33158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33159         this_ptr_conv.is_owned = false;
33160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33161         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33162         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
33163         return ret_arr;
33164 }
33165
33166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33167         LDKFundingCreated this_ptr_conv;
33168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33169         this_ptr_conv.is_owned = false;
33170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33171         LDKSignature val_ref;
33172         CHECK((*env)->GetArrayLength(env, val) == 64);
33173         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33174         FundingCreated_set_signature(&this_ptr_conv, val_ref);
33175 }
33176
33177 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) {
33178         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
33179         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
33180         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
33181         LDKThirtyTwoBytes funding_txid_arg_ref;
33182         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
33183         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
33184         LDKSignature signature_arg_ref;
33185         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33186         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33187         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
33188         int64_t ret_ref = 0;
33189         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33190         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33192         ret_ref = (uintptr_t)ret_var.inner;
33193         if (ret_var.is_owned) {
33194                 ret_ref |= 1;
33195         }
33196         return ret_ref;
33197 }
33198
33199 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
33200         LDKFundingCreated ret_var = FundingCreated_clone(arg);
33201 int64_t ret_ref = 0;
33202 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33203 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33204 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33205 ret_ref = (uintptr_t)ret_var.inner;
33206 if (ret_var.is_owned) {
33207         ret_ref |= 1;
33208 }
33209         return ret_ref;
33210 }
33211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33212         LDKFundingCreated arg_conv;
33213         arg_conv.inner = (void*)(arg & (~1));
33214         arg_conv.is_owned = false;
33215         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33216         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
33217         return ret_conv;
33218 }
33219
33220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33221         LDKFundingCreated orig_conv;
33222         orig_conv.inner = (void*)(orig & (~1));
33223         orig_conv.is_owned = false;
33224         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33225         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
33226         int64_t ret_ref = 0;
33227         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33228         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33230         ret_ref = (uintptr_t)ret_var.inner;
33231         if (ret_var.is_owned) {
33232                 ret_ref |= 1;
33233         }
33234         return ret_ref;
33235 }
33236
33237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33238         LDKFundingSigned this_obj_conv;
33239         this_obj_conv.inner = (void*)(this_obj & (~1));
33240         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33242         FundingSigned_free(this_obj_conv);
33243 }
33244
33245 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33246         LDKFundingSigned 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33251         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
33252         return ret_arr;
33253 }
33254
33255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33256         LDKFundingSigned this_ptr_conv;
33257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33258         this_ptr_conv.is_owned = false;
33259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33260         LDKThirtyTwoBytes val_ref;
33261         CHECK((*env)->GetArrayLength(env, val) == 32);
33262         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33263         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
33264 }
33265
33266 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33267         LDKFundingSigned this_ptr_conv;
33268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33269         this_ptr_conv.is_owned = false;
33270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33271         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33272         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
33273         return ret_arr;
33274 }
33275
33276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33277         LDKFundingSigned this_ptr_conv;
33278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33279         this_ptr_conv.is_owned = false;
33280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33281         LDKSignature val_ref;
33282         CHECK((*env)->GetArrayLength(env, val) == 64);
33283         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33284         FundingSigned_set_signature(&this_ptr_conv, val_ref);
33285 }
33286
33287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
33288         LDKThirtyTwoBytes channel_id_arg_ref;
33289         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33290         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33291         LDKSignature signature_arg_ref;
33292         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33293         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33294         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
33295         int64_t ret_ref = 0;
33296         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33297         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33299         ret_ref = (uintptr_t)ret_var.inner;
33300         if (ret_var.is_owned) {
33301                 ret_ref |= 1;
33302         }
33303         return ret_ref;
33304 }
33305
33306 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
33307         LDKFundingSigned ret_var = FundingSigned_clone(arg);
33308 int64_t ret_ref = 0;
33309 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33310 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33311 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33312 ret_ref = (uintptr_t)ret_var.inner;
33313 if (ret_var.is_owned) {
33314         ret_ref |= 1;
33315 }
33316         return ret_ref;
33317 }
33318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33319         LDKFundingSigned arg_conv;
33320         arg_conv.inner = (void*)(arg & (~1));
33321         arg_conv.is_owned = false;
33322         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33323         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
33324         return ret_conv;
33325 }
33326
33327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33328         LDKFundingSigned orig_conv;
33329         orig_conv.inner = (void*)(orig & (~1));
33330         orig_conv.is_owned = false;
33331         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33332         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
33333         int64_t ret_ref = 0;
33334         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33335         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33337         ret_ref = (uintptr_t)ret_var.inner;
33338         if (ret_var.is_owned) {
33339                 ret_ref |= 1;
33340         }
33341         return ret_ref;
33342 }
33343
33344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33345         LDKChannelReady this_obj_conv;
33346         this_obj_conv.inner = (void*)(this_obj & (~1));
33347         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33349         ChannelReady_free(this_obj_conv);
33350 }
33351
33352 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33353         LDKChannelReady this_ptr_conv;
33354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33355         this_ptr_conv.is_owned = false;
33356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33357         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33358         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
33359         return ret_arr;
33360 }
33361
33362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33363         LDKChannelReady this_ptr_conv;
33364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33365         this_ptr_conv.is_owned = false;
33366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33367         LDKThirtyTwoBytes val_ref;
33368         CHECK((*env)->GetArrayLength(env, val) == 32);
33369         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33370         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
33371 }
33372
33373 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33374         LDKChannelReady this_ptr_conv;
33375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33376         this_ptr_conv.is_owned = false;
33377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33378         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33379         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
33380         return ret_arr;
33381 }
33382
33383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33384         LDKChannelReady this_ptr_conv;
33385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33386         this_ptr_conv.is_owned = false;
33387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33388         LDKPublicKey val_ref;
33389         CHECK((*env)->GetArrayLength(env, val) == 33);
33390         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33391         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
33392 }
33393
33394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
33395         LDKChannelReady this_ptr_conv;
33396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33397         this_ptr_conv.is_owned = false;
33398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33399         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
33400         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
33401         int64_t ret_ref = (uintptr_t)ret_copy;
33402         return ret_ref;
33403 }
33404
33405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33406         LDKChannelReady this_ptr_conv;
33407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33408         this_ptr_conv.is_owned = false;
33409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33410         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33411         CHECK_ACCESS(val_ptr);
33412         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
33413         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
33414         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
33415 }
33416
33417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg, int64_t short_channel_id_alias_arg) {
33418         LDKThirtyTwoBytes channel_id_arg_ref;
33419         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33420         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33421         LDKPublicKey next_per_commitment_point_arg_ref;
33422         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
33423         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
33424         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
33425         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
33426         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
33427         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
33428         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
33429         int64_t ret_ref = 0;
33430         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33431         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33433         ret_ref = (uintptr_t)ret_var.inner;
33434         if (ret_var.is_owned) {
33435                 ret_ref |= 1;
33436         }
33437         return ret_ref;
33438 }
33439
33440 static inline uintptr_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
33441         LDKChannelReady ret_var = ChannelReady_clone(arg);
33442 int64_t ret_ref = 0;
33443 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33444 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33445 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33446 ret_ref = (uintptr_t)ret_var.inner;
33447 if (ret_var.is_owned) {
33448         ret_ref |= 1;
33449 }
33450         return ret_ref;
33451 }
33452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33453         LDKChannelReady arg_conv;
33454         arg_conv.inner = (void*)(arg & (~1));
33455         arg_conv.is_owned = false;
33456         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33457         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
33458         return ret_conv;
33459 }
33460
33461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33462         LDKChannelReady orig_conv;
33463         orig_conv.inner = (void*)(orig & (~1));
33464         orig_conv.is_owned = false;
33465         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33466         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
33467         int64_t ret_ref = 0;
33468         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33469         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33471         ret_ref = (uintptr_t)ret_var.inner;
33472         if (ret_var.is_owned) {
33473                 ret_ref |= 1;
33474         }
33475         return ret_ref;
33476 }
33477
33478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33479         LDKShutdown this_obj_conv;
33480         this_obj_conv.inner = (void*)(this_obj & (~1));
33481         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33483         Shutdown_free(this_obj_conv);
33484 }
33485
33486 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33487         LDKShutdown this_ptr_conv;
33488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33489         this_ptr_conv.is_owned = false;
33490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33491         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33492         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
33493         return ret_arr;
33494 }
33495
33496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33497         LDKShutdown this_ptr_conv;
33498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33499         this_ptr_conv.is_owned = false;
33500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33501         LDKThirtyTwoBytes val_ref;
33502         CHECK((*env)->GetArrayLength(env, val) == 32);
33503         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33504         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
33505 }
33506
33507 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
33508         LDKShutdown this_ptr_conv;
33509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33510         this_ptr_conv.is_owned = false;
33511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33512         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
33513         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33514         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33515         return ret_arr;
33516 }
33517
33518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33519         LDKShutdown this_ptr_conv;
33520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33521         this_ptr_conv.is_owned = false;
33522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33523         LDKCVec_u8Z val_ref;
33524         val_ref.datalen = (*env)->GetArrayLength(env, val);
33525         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
33526         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
33527         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
33528 }
33529
33530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
33531         LDKThirtyTwoBytes channel_id_arg_ref;
33532         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33533         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33534         LDKCVec_u8Z scriptpubkey_arg_ref;
33535         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
33536         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
33537         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
33538         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
33539         int64_t ret_ref = 0;
33540         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33541         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33543         ret_ref = (uintptr_t)ret_var.inner;
33544         if (ret_var.is_owned) {
33545                 ret_ref |= 1;
33546         }
33547         return ret_ref;
33548 }
33549
33550 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
33551         LDKShutdown ret_var = Shutdown_clone(arg);
33552 int64_t ret_ref = 0;
33553 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33554 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33555 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33556 ret_ref = (uintptr_t)ret_var.inner;
33557 if (ret_var.is_owned) {
33558         ret_ref |= 1;
33559 }
33560         return ret_ref;
33561 }
33562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33563         LDKShutdown arg_conv;
33564         arg_conv.inner = (void*)(arg & (~1));
33565         arg_conv.is_owned = false;
33566         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33567         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
33568         return ret_conv;
33569 }
33570
33571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33572         LDKShutdown orig_conv;
33573         orig_conv.inner = (void*)(orig & (~1));
33574         orig_conv.is_owned = false;
33575         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33576         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
33577         int64_t ret_ref = 0;
33578         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33579         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33581         ret_ref = (uintptr_t)ret_var.inner;
33582         if (ret_var.is_owned) {
33583                 ret_ref |= 1;
33584         }
33585         return ret_ref;
33586 }
33587
33588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33589         LDKClosingSignedFeeRange this_obj_conv;
33590         this_obj_conv.inner = (void*)(this_obj & (~1));
33591         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33593         ClosingSignedFeeRange_free(this_obj_conv);
33594 }
33595
33596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33597         LDKClosingSignedFeeRange this_ptr_conv;
33598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33599         this_ptr_conv.is_owned = false;
33600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33601         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
33602         return ret_conv;
33603 }
33604
33605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33606         LDKClosingSignedFeeRange this_ptr_conv;
33607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33608         this_ptr_conv.is_owned = false;
33609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33610         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
33611 }
33612
33613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33614         LDKClosingSignedFeeRange this_ptr_conv;
33615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33616         this_ptr_conv.is_owned = false;
33617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33618         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
33619         return ret_conv;
33620 }
33621
33622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33623         LDKClosingSignedFeeRange this_ptr_conv;
33624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33625         this_ptr_conv.is_owned = false;
33626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33627         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
33628 }
33629
33630 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) {
33631         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
33632         int64_t ret_ref = 0;
33633         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33634         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33636         ret_ref = (uintptr_t)ret_var.inner;
33637         if (ret_var.is_owned) {
33638                 ret_ref |= 1;
33639         }
33640         return ret_ref;
33641 }
33642
33643 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
33644         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
33645 int64_t ret_ref = 0;
33646 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33647 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33648 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33649 ret_ref = (uintptr_t)ret_var.inner;
33650 if (ret_var.is_owned) {
33651         ret_ref |= 1;
33652 }
33653         return ret_ref;
33654 }
33655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33656         LDKClosingSignedFeeRange arg_conv;
33657         arg_conv.inner = (void*)(arg & (~1));
33658         arg_conv.is_owned = false;
33659         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33660         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
33661         return ret_conv;
33662 }
33663
33664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33665         LDKClosingSignedFeeRange orig_conv;
33666         orig_conv.inner = (void*)(orig & (~1));
33667         orig_conv.is_owned = false;
33668         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33669         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
33670         int64_t ret_ref = 0;
33671         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33672         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33674         ret_ref = (uintptr_t)ret_var.inner;
33675         if (ret_var.is_owned) {
33676                 ret_ref |= 1;
33677         }
33678         return ret_ref;
33679 }
33680
33681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33682         LDKClosingSigned this_obj_conv;
33683         this_obj_conv.inner = (void*)(this_obj & (~1));
33684         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33686         ClosingSigned_free(this_obj_conv);
33687 }
33688
33689 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33690         LDKClosingSigned this_ptr_conv;
33691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33692         this_ptr_conv.is_owned = false;
33693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33694         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33695         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
33696         return ret_arr;
33697 }
33698
33699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33700         LDKClosingSigned this_ptr_conv;
33701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33702         this_ptr_conv.is_owned = false;
33703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33704         LDKThirtyTwoBytes val_ref;
33705         CHECK((*env)->GetArrayLength(env, val) == 32);
33706         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33707         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
33708 }
33709
33710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33711         LDKClosingSigned this_ptr_conv;
33712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33713         this_ptr_conv.is_owned = false;
33714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33715         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
33716         return ret_conv;
33717 }
33718
33719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33720         LDKClosingSigned this_ptr_conv;
33721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33722         this_ptr_conv.is_owned = false;
33723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33724         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
33725 }
33726
33727 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33728         LDKClosingSigned this_ptr_conv;
33729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33730         this_ptr_conv.is_owned = false;
33731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33732         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33733         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
33734         return ret_arr;
33735 }
33736
33737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33738         LDKClosingSigned this_ptr_conv;
33739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33740         this_ptr_conv.is_owned = false;
33741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33742         LDKSignature val_ref;
33743         CHECK((*env)->GetArrayLength(env, val) == 64);
33744         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33745         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
33746 }
33747
33748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
33749         LDKClosingSigned this_ptr_conv;
33750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33751         this_ptr_conv.is_owned = false;
33752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33753         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
33754         int64_t ret_ref = 0;
33755         if ((uintptr_t)ret_var.inner > 4096) {
33756                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33757                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33759                 ret_ref = (uintptr_t)ret_var.inner;
33760                 if (ret_var.is_owned) {
33761                         ret_ref |= 1;
33762                 }
33763         }
33764         return ret_ref;
33765 }
33766
33767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33768         LDKClosingSigned this_ptr_conv;
33769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33770         this_ptr_conv.is_owned = false;
33771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33772         LDKClosingSignedFeeRange val_conv;
33773         val_conv.inner = (void*)(val & (~1));
33774         val_conv.is_owned = (val & 1) || (val == 0);
33775         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33776         val_conv = ClosingSignedFeeRange_clone(&val_conv);
33777         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
33778 }
33779
33780 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) {
33781         LDKThirtyTwoBytes channel_id_arg_ref;
33782         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33783         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33784         LDKSignature signature_arg_ref;
33785         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33786         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33787         LDKClosingSignedFeeRange fee_range_arg_conv;
33788         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
33789         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
33790         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
33791         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
33792         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
33793         int64_t ret_ref = 0;
33794         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33795         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33797         ret_ref = (uintptr_t)ret_var.inner;
33798         if (ret_var.is_owned) {
33799                 ret_ref |= 1;
33800         }
33801         return ret_ref;
33802 }
33803
33804 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
33805         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
33806 int64_t ret_ref = 0;
33807 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33808 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33809 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33810 ret_ref = (uintptr_t)ret_var.inner;
33811 if (ret_var.is_owned) {
33812         ret_ref |= 1;
33813 }
33814         return ret_ref;
33815 }
33816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33817         LDKClosingSigned arg_conv;
33818         arg_conv.inner = (void*)(arg & (~1));
33819         arg_conv.is_owned = false;
33820         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33821         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
33822         return ret_conv;
33823 }
33824
33825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33826         LDKClosingSigned orig_conv;
33827         orig_conv.inner = (void*)(orig & (~1));
33828         orig_conv.is_owned = false;
33829         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33830         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
33831         int64_t ret_ref = 0;
33832         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33833         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33835         ret_ref = (uintptr_t)ret_var.inner;
33836         if (ret_var.is_owned) {
33837                 ret_ref |= 1;
33838         }
33839         return ret_ref;
33840 }
33841
33842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33843         LDKUpdateAddHTLC this_obj_conv;
33844         this_obj_conv.inner = (void*)(this_obj & (~1));
33845         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33847         UpdateAddHTLC_free(this_obj_conv);
33848 }
33849
33850 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33851         LDKUpdateAddHTLC this_ptr_conv;
33852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33853         this_ptr_conv.is_owned = false;
33854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33855         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33856         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
33857         return ret_arr;
33858 }
33859
33860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33861         LDKUpdateAddHTLC this_ptr_conv;
33862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33863         this_ptr_conv.is_owned = false;
33864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33865         LDKThirtyTwoBytes val_ref;
33866         CHECK((*env)->GetArrayLength(env, val) == 32);
33867         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33868         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
33869 }
33870
33871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33872         LDKUpdateAddHTLC this_ptr_conv;
33873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33874         this_ptr_conv.is_owned = false;
33875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33876         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
33877         return ret_conv;
33878 }
33879
33880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33881         LDKUpdateAddHTLC this_ptr_conv;
33882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33883         this_ptr_conv.is_owned = false;
33884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33885         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
33886 }
33887
33888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33889         LDKUpdateAddHTLC this_ptr_conv;
33890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33891         this_ptr_conv.is_owned = false;
33892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33893         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
33894         return ret_conv;
33895 }
33896
33897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33898         LDKUpdateAddHTLC this_ptr_conv;
33899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33900         this_ptr_conv.is_owned = false;
33901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33902         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
33903 }
33904
33905 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33906         LDKUpdateAddHTLC this_ptr_conv;
33907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33908         this_ptr_conv.is_owned = false;
33909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33910         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33911         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
33912         return ret_arr;
33913 }
33914
33915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33916         LDKUpdateAddHTLC this_ptr_conv;
33917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33918         this_ptr_conv.is_owned = false;
33919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33920         LDKThirtyTwoBytes val_ref;
33921         CHECK((*env)->GetArrayLength(env, val) == 32);
33922         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33923         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
33924 }
33925
33926 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
33927         LDKUpdateAddHTLC this_ptr_conv;
33928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33929         this_ptr_conv.is_owned = false;
33930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33931         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
33932         return ret_conv;
33933 }
33934
33935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33936         LDKUpdateAddHTLC this_ptr_conv;
33937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33938         this_ptr_conv.is_owned = false;
33939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33940         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
33941 }
33942
33943 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
33944         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
33945 int64_t ret_ref = 0;
33946 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33947 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33948 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33949 ret_ref = (uintptr_t)ret_var.inner;
33950 if (ret_var.is_owned) {
33951         ret_ref |= 1;
33952 }
33953         return ret_ref;
33954 }
33955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33956         LDKUpdateAddHTLC arg_conv;
33957         arg_conv.inner = (void*)(arg & (~1));
33958         arg_conv.is_owned = false;
33959         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33960         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
33961         return ret_conv;
33962 }
33963
33964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33965         LDKUpdateAddHTLC orig_conv;
33966         orig_conv.inner = (void*)(orig & (~1));
33967         orig_conv.is_owned = false;
33968         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33969         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
33970         int64_t ret_ref = 0;
33971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33974         ret_ref = (uintptr_t)ret_var.inner;
33975         if (ret_var.is_owned) {
33976                 ret_ref |= 1;
33977         }
33978         return ret_ref;
33979 }
33980
33981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33982         LDKUpdateFulfillHTLC this_obj_conv;
33983         this_obj_conv.inner = (void*)(this_obj & (~1));
33984         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33986         UpdateFulfillHTLC_free(this_obj_conv);
33987 }
33988
33989 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33990         LDKUpdateFulfillHTLC this_ptr_conv;
33991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33992         this_ptr_conv.is_owned = false;
33993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33994         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33995         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
33996         return ret_arr;
33997 }
33998
33999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34000         LDKUpdateFulfillHTLC this_ptr_conv;
34001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34002         this_ptr_conv.is_owned = false;
34003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34004         LDKThirtyTwoBytes val_ref;
34005         CHECK((*env)->GetArrayLength(env, val) == 32);
34006         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34007         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
34008 }
34009
34010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34011         LDKUpdateFulfillHTLC this_ptr_conv;
34012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34013         this_ptr_conv.is_owned = false;
34014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34015         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
34016         return ret_conv;
34017 }
34018
34019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34020         LDKUpdateFulfillHTLC this_ptr_conv;
34021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34022         this_ptr_conv.is_owned = false;
34023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34024         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
34025 }
34026
34027 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
34028         LDKUpdateFulfillHTLC this_ptr_conv;
34029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34030         this_ptr_conv.is_owned = false;
34031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34032         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34033         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
34034         return ret_arr;
34035 }
34036
34037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34038         LDKUpdateFulfillHTLC this_ptr_conv;
34039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34040         this_ptr_conv.is_owned = false;
34041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34042         LDKThirtyTwoBytes val_ref;
34043         CHECK((*env)->GetArrayLength(env, val) == 32);
34044         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34045         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
34046 }
34047
34048 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) {
34049         LDKThirtyTwoBytes channel_id_arg_ref;
34050         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34051         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34052         LDKThirtyTwoBytes payment_preimage_arg_ref;
34053         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
34054         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
34055         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
34056         int64_t ret_ref = 0;
34057         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34058         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34060         ret_ref = (uintptr_t)ret_var.inner;
34061         if (ret_var.is_owned) {
34062                 ret_ref |= 1;
34063         }
34064         return ret_ref;
34065 }
34066
34067 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
34068         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
34069 int64_t ret_ref = 0;
34070 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34071 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34072 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34073 ret_ref = (uintptr_t)ret_var.inner;
34074 if (ret_var.is_owned) {
34075         ret_ref |= 1;
34076 }
34077         return ret_ref;
34078 }
34079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34080         LDKUpdateFulfillHTLC arg_conv;
34081         arg_conv.inner = (void*)(arg & (~1));
34082         arg_conv.is_owned = false;
34083         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34084         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
34085         return ret_conv;
34086 }
34087
34088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34089         LDKUpdateFulfillHTLC orig_conv;
34090         orig_conv.inner = (void*)(orig & (~1));
34091         orig_conv.is_owned = false;
34092         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34093         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
34094         int64_t ret_ref = 0;
34095         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34096         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34098         ret_ref = (uintptr_t)ret_var.inner;
34099         if (ret_var.is_owned) {
34100                 ret_ref |= 1;
34101         }
34102         return ret_ref;
34103 }
34104
34105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34106         LDKUpdateFailHTLC this_obj_conv;
34107         this_obj_conv.inner = (void*)(this_obj & (~1));
34108         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34110         UpdateFailHTLC_free(this_obj_conv);
34111 }
34112
34113 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34114         LDKUpdateFailHTLC this_ptr_conv;
34115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34116         this_ptr_conv.is_owned = false;
34117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34118         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34119         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
34120         return ret_arr;
34121 }
34122
34123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34124         LDKUpdateFailHTLC this_ptr_conv;
34125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34126         this_ptr_conv.is_owned = false;
34127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34128         LDKThirtyTwoBytes val_ref;
34129         CHECK((*env)->GetArrayLength(env, val) == 32);
34130         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34131         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
34132 }
34133
34134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34135         LDKUpdateFailHTLC this_ptr_conv;
34136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34137         this_ptr_conv.is_owned = false;
34138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34139         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
34140         return ret_conv;
34141 }
34142
34143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34144         LDKUpdateFailHTLC this_ptr_conv;
34145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34146         this_ptr_conv.is_owned = false;
34147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34148         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
34149 }
34150
34151 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
34152         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
34153 int64_t ret_ref = 0;
34154 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34155 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34156 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34157 ret_ref = (uintptr_t)ret_var.inner;
34158 if (ret_var.is_owned) {
34159         ret_ref |= 1;
34160 }
34161         return ret_ref;
34162 }
34163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34164         LDKUpdateFailHTLC arg_conv;
34165         arg_conv.inner = (void*)(arg & (~1));
34166         arg_conv.is_owned = false;
34167         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34168         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
34169         return ret_conv;
34170 }
34171
34172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34173         LDKUpdateFailHTLC orig_conv;
34174         orig_conv.inner = (void*)(orig & (~1));
34175         orig_conv.is_owned = false;
34176         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34177         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
34178         int64_t ret_ref = 0;
34179         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34180         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34182         ret_ref = (uintptr_t)ret_var.inner;
34183         if (ret_var.is_owned) {
34184                 ret_ref |= 1;
34185         }
34186         return ret_ref;
34187 }
34188
34189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34190         LDKUpdateFailMalformedHTLC this_obj_conv;
34191         this_obj_conv.inner = (void*)(this_obj & (~1));
34192         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34194         UpdateFailMalformedHTLC_free(this_obj_conv);
34195 }
34196
34197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34198         LDKUpdateFailMalformedHTLC this_ptr_conv;
34199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34200         this_ptr_conv.is_owned = false;
34201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34202         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34203         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
34204         return ret_arr;
34205 }
34206
34207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34208         LDKUpdateFailMalformedHTLC this_ptr_conv;
34209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34210         this_ptr_conv.is_owned = false;
34211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34212         LDKThirtyTwoBytes val_ref;
34213         CHECK((*env)->GetArrayLength(env, val) == 32);
34214         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34215         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
34216 }
34217
34218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34219         LDKUpdateFailMalformedHTLC this_ptr_conv;
34220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34221         this_ptr_conv.is_owned = false;
34222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34223         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
34224         return ret_conv;
34225 }
34226
34227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34228         LDKUpdateFailMalformedHTLC this_ptr_conv;
34229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34230         this_ptr_conv.is_owned = false;
34231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34232         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
34233 }
34234
34235 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
34236         LDKUpdateFailMalformedHTLC this_ptr_conv;
34237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34238         this_ptr_conv.is_owned = false;
34239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34240         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
34241         return ret_conv;
34242 }
34243
34244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34245         LDKUpdateFailMalformedHTLC this_ptr_conv;
34246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34247         this_ptr_conv.is_owned = false;
34248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34249         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
34250 }
34251
34252 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
34253         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
34254 int64_t ret_ref = 0;
34255 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34256 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34257 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34258 ret_ref = (uintptr_t)ret_var.inner;
34259 if (ret_var.is_owned) {
34260         ret_ref |= 1;
34261 }
34262         return ret_ref;
34263 }
34264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34265         LDKUpdateFailMalformedHTLC arg_conv;
34266         arg_conv.inner = (void*)(arg & (~1));
34267         arg_conv.is_owned = false;
34268         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34269         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
34270         return ret_conv;
34271 }
34272
34273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34274         LDKUpdateFailMalformedHTLC orig_conv;
34275         orig_conv.inner = (void*)(orig & (~1));
34276         orig_conv.is_owned = false;
34277         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34278         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
34279         int64_t ret_ref = 0;
34280         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34281         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34283         ret_ref = (uintptr_t)ret_var.inner;
34284         if (ret_var.is_owned) {
34285                 ret_ref |= 1;
34286         }
34287         return ret_ref;
34288 }
34289
34290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34291         LDKCommitmentSigned this_obj_conv;
34292         this_obj_conv.inner = (void*)(this_obj & (~1));
34293         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34295         CommitmentSigned_free(this_obj_conv);
34296 }
34297
34298 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34299         LDKCommitmentSigned this_ptr_conv;
34300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34301         this_ptr_conv.is_owned = false;
34302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34303         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34304         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
34305         return ret_arr;
34306 }
34307
34308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34309         LDKCommitmentSigned 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         LDKThirtyTwoBytes val_ref;
34314         CHECK((*env)->GetArrayLength(env, val) == 32);
34315         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34316         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
34317 }
34318
34319 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34320         LDKCommitmentSigned this_ptr_conv;
34321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34322         this_ptr_conv.is_owned = false;
34323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34324         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34325         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
34326         return ret_arr;
34327 }
34328
34329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34330         LDKCommitmentSigned this_ptr_conv;
34331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34332         this_ptr_conv.is_owned = false;
34333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34334         LDKSignature val_ref;
34335         CHECK((*env)->GetArrayLength(env, val) == 64);
34336         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34337         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
34338 }
34339
34340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
34341         LDKCommitmentSigned this_ptr_conv;
34342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34343         this_ptr_conv.is_owned = false;
34344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34345         LDKCVec_SignatureZ val_constr;
34346         val_constr.datalen = (*env)->GetArrayLength(env, val);
34347         if (val_constr.datalen > 0)
34348                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34349         else
34350                 val_constr.data = NULL;
34351         for (size_t i = 0; i < val_constr.datalen; i++) {
34352                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
34353                 LDKSignature val_conv_8_ref;
34354                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
34355                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
34356                 val_constr.data[i] = val_conv_8_ref;
34357         }
34358         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
34359 }
34360
34361 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) {
34362         LDKThirtyTwoBytes channel_id_arg_ref;
34363         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34364         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34365         LDKSignature signature_arg_ref;
34366         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34367         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34368         LDKCVec_SignatureZ htlc_signatures_arg_constr;
34369         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
34370         if (htlc_signatures_arg_constr.datalen > 0)
34371                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34372         else
34373                 htlc_signatures_arg_constr.data = NULL;
34374         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
34375                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
34376                 LDKSignature htlc_signatures_arg_conv_8_ref;
34377                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
34378                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
34379                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
34380         }
34381         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
34382         int64_t ret_ref = 0;
34383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34386         ret_ref = (uintptr_t)ret_var.inner;
34387         if (ret_var.is_owned) {
34388                 ret_ref |= 1;
34389         }
34390         return ret_ref;
34391 }
34392
34393 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
34394         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
34395 int64_t ret_ref = 0;
34396 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34397 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34398 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34399 ret_ref = (uintptr_t)ret_var.inner;
34400 if (ret_var.is_owned) {
34401         ret_ref |= 1;
34402 }
34403         return ret_ref;
34404 }
34405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34406         LDKCommitmentSigned arg_conv;
34407         arg_conv.inner = (void*)(arg & (~1));
34408         arg_conv.is_owned = false;
34409         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34410         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
34411         return ret_conv;
34412 }
34413
34414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34415         LDKCommitmentSigned orig_conv;
34416         orig_conv.inner = (void*)(orig & (~1));
34417         orig_conv.is_owned = false;
34418         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34419         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
34420         int64_t ret_ref = 0;
34421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34424         ret_ref = (uintptr_t)ret_var.inner;
34425         if (ret_var.is_owned) {
34426                 ret_ref |= 1;
34427         }
34428         return ret_ref;
34429 }
34430
34431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34432         LDKRevokeAndACK this_obj_conv;
34433         this_obj_conv.inner = (void*)(this_obj & (~1));
34434         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34436         RevokeAndACK_free(this_obj_conv);
34437 }
34438
34439 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34440         LDKRevokeAndACK this_ptr_conv;
34441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34442         this_ptr_conv.is_owned = false;
34443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34444         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34445         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
34446         return ret_arr;
34447 }
34448
34449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34450         LDKRevokeAndACK this_ptr_conv;
34451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34452         this_ptr_conv.is_owned = false;
34453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34454         LDKThirtyTwoBytes val_ref;
34455         CHECK((*env)->GetArrayLength(env, val) == 32);
34456         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34457         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
34458 }
34459
34460 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
34461         LDKRevokeAndACK this_ptr_conv;
34462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34463         this_ptr_conv.is_owned = false;
34464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34465         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34466         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
34467         return ret_arr;
34468 }
34469
34470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34471         LDKRevokeAndACK this_ptr_conv;
34472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34473         this_ptr_conv.is_owned = false;
34474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34475         LDKThirtyTwoBytes val_ref;
34476         CHECK((*env)->GetArrayLength(env, val) == 32);
34477         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34478         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
34479 }
34480
34481 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34482         LDKRevokeAndACK this_ptr_conv;
34483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34484         this_ptr_conv.is_owned = false;
34485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34486         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34487         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
34488         return ret_arr;
34489 }
34490
34491 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) {
34492         LDKRevokeAndACK this_ptr_conv;
34493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34494         this_ptr_conv.is_owned = false;
34495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34496         LDKPublicKey val_ref;
34497         CHECK((*env)->GetArrayLength(env, val) == 33);
34498         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34499         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
34500 }
34501
34502 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) {
34503         LDKThirtyTwoBytes channel_id_arg_ref;
34504         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34505         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34506         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
34507         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
34508         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
34509         LDKPublicKey next_per_commitment_point_arg_ref;
34510         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
34511         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
34512         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
34513         int64_t ret_ref = 0;
34514         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34515         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34517         ret_ref = (uintptr_t)ret_var.inner;
34518         if (ret_var.is_owned) {
34519                 ret_ref |= 1;
34520         }
34521         return ret_ref;
34522 }
34523
34524 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
34525         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
34526 int64_t ret_ref = 0;
34527 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34528 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34529 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34530 ret_ref = (uintptr_t)ret_var.inner;
34531 if (ret_var.is_owned) {
34532         ret_ref |= 1;
34533 }
34534         return ret_ref;
34535 }
34536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34537         LDKRevokeAndACK arg_conv;
34538         arg_conv.inner = (void*)(arg & (~1));
34539         arg_conv.is_owned = false;
34540         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34541         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
34542         return ret_conv;
34543 }
34544
34545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34546         LDKRevokeAndACK orig_conv;
34547         orig_conv.inner = (void*)(orig & (~1));
34548         orig_conv.is_owned = false;
34549         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34550         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
34551         int64_t ret_ref = 0;
34552         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34553         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34555         ret_ref = (uintptr_t)ret_var.inner;
34556         if (ret_var.is_owned) {
34557                 ret_ref |= 1;
34558         }
34559         return ret_ref;
34560 }
34561
34562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34563         LDKUpdateFee this_obj_conv;
34564         this_obj_conv.inner = (void*)(this_obj & (~1));
34565         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34567         UpdateFee_free(this_obj_conv);
34568 }
34569
34570 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34571         LDKUpdateFee this_ptr_conv;
34572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34573         this_ptr_conv.is_owned = false;
34574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34575         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34576         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
34577         return ret_arr;
34578 }
34579
34580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34581         LDKUpdateFee this_ptr_conv;
34582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34583         this_ptr_conv.is_owned = false;
34584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34585         LDKThirtyTwoBytes val_ref;
34586         CHECK((*env)->GetArrayLength(env, val) == 32);
34587         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34588         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
34589 }
34590
34591 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
34592         LDKUpdateFee this_ptr_conv;
34593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34594         this_ptr_conv.is_owned = false;
34595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34596         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
34597         return ret_conv;
34598 }
34599
34600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34601         LDKUpdateFee this_ptr_conv;
34602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34603         this_ptr_conv.is_owned = false;
34604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34605         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
34606 }
34607
34608 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) {
34609         LDKThirtyTwoBytes channel_id_arg_ref;
34610         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34611         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34612         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
34613         int64_t ret_ref = 0;
34614         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34615         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34617         ret_ref = (uintptr_t)ret_var.inner;
34618         if (ret_var.is_owned) {
34619                 ret_ref |= 1;
34620         }
34621         return ret_ref;
34622 }
34623
34624 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
34625         LDKUpdateFee ret_var = UpdateFee_clone(arg);
34626 int64_t ret_ref = 0;
34627 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34628 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34629 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34630 ret_ref = (uintptr_t)ret_var.inner;
34631 if (ret_var.is_owned) {
34632         ret_ref |= 1;
34633 }
34634         return ret_ref;
34635 }
34636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34637         LDKUpdateFee arg_conv;
34638         arg_conv.inner = (void*)(arg & (~1));
34639         arg_conv.is_owned = false;
34640         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34641         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
34642         return ret_conv;
34643 }
34644
34645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34646         LDKUpdateFee orig_conv;
34647         orig_conv.inner = (void*)(orig & (~1));
34648         orig_conv.is_owned = false;
34649         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34650         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
34651         int64_t ret_ref = 0;
34652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34655         ret_ref = (uintptr_t)ret_var.inner;
34656         if (ret_var.is_owned) {
34657                 ret_ref |= 1;
34658         }
34659         return ret_ref;
34660 }
34661
34662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34663         LDKDataLossProtect this_obj_conv;
34664         this_obj_conv.inner = (void*)(this_obj & (~1));
34665         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34667         DataLossProtect_free(this_obj_conv);
34668 }
34669
34670 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
34671         LDKDataLossProtect this_ptr_conv;
34672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34673         this_ptr_conv.is_owned = false;
34674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34675         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34676         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
34677         return ret_arr;
34678 }
34679
34680 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) {
34681         LDKDataLossProtect this_ptr_conv;
34682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34683         this_ptr_conv.is_owned = false;
34684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34685         LDKThirtyTwoBytes val_ref;
34686         CHECK((*env)->GetArrayLength(env, val) == 32);
34687         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34688         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
34689 }
34690
34691 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34692         LDKDataLossProtect this_ptr_conv;
34693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34694         this_ptr_conv.is_owned = false;
34695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34696         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34697         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
34698         return ret_arr;
34699 }
34700
34701 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) {
34702         LDKDataLossProtect this_ptr_conv;
34703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34704         this_ptr_conv.is_owned = false;
34705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34706         LDKPublicKey val_ref;
34707         CHECK((*env)->GetArrayLength(env, val) == 33);
34708         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34709         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
34710 }
34711
34712 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) {
34713         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
34714         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
34715         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
34716         LDKPublicKey my_current_per_commitment_point_arg_ref;
34717         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
34718         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
34719         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
34720         int64_t ret_ref = 0;
34721         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34722         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34724         ret_ref = (uintptr_t)ret_var.inner;
34725         if (ret_var.is_owned) {
34726                 ret_ref |= 1;
34727         }
34728         return ret_ref;
34729 }
34730
34731 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
34732         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
34733 int64_t ret_ref = 0;
34734 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34735 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34736 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34737 ret_ref = (uintptr_t)ret_var.inner;
34738 if (ret_var.is_owned) {
34739         ret_ref |= 1;
34740 }
34741         return ret_ref;
34742 }
34743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34744         LDKDataLossProtect arg_conv;
34745         arg_conv.inner = (void*)(arg & (~1));
34746         arg_conv.is_owned = false;
34747         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34748         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
34749         return ret_conv;
34750 }
34751
34752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34753         LDKDataLossProtect orig_conv;
34754         orig_conv.inner = (void*)(orig & (~1));
34755         orig_conv.is_owned = false;
34756         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34757         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
34758         int64_t ret_ref = 0;
34759         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34760         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34762         ret_ref = (uintptr_t)ret_var.inner;
34763         if (ret_var.is_owned) {
34764                 ret_ref |= 1;
34765         }
34766         return ret_ref;
34767 }
34768
34769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34770         LDKChannelReestablish this_obj_conv;
34771         this_obj_conv.inner = (void*)(this_obj & (~1));
34772         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34774         ChannelReestablish_free(this_obj_conv);
34775 }
34776
34777 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34778         LDKChannelReestablish this_ptr_conv;
34779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34780         this_ptr_conv.is_owned = false;
34781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34782         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34783         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
34784         return ret_arr;
34785 }
34786
34787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34788         LDKChannelReestablish this_ptr_conv;
34789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34790         this_ptr_conv.is_owned = false;
34791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34792         LDKThirtyTwoBytes val_ref;
34793         CHECK((*env)->GetArrayLength(env, val) == 32);
34794         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34795         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
34796 }
34797
34798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
34799         LDKChannelReestablish this_ptr_conv;
34800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34801         this_ptr_conv.is_owned = false;
34802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34803         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
34804         return ret_conv;
34805 }
34806
34807 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) {
34808         LDKChannelReestablish this_ptr_conv;
34809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34810         this_ptr_conv.is_owned = false;
34811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34812         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
34813 }
34814
34815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
34816         LDKChannelReestablish this_ptr_conv;
34817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34818         this_ptr_conv.is_owned = false;
34819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34820         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
34821         return ret_conv;
34822 }
34823
34824 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) {
34825         LDKChannelReestablish this_ptr_conv;
34826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34827         this_ptr_conv.is_owned = false;
34828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34829         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
34830 }
34831
34832 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
34833         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
34834 int64_t ret_ref = 0;
34835 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34836 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34837 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34838 ret_ref = (uintptr_t)ret_var.inner;
34839 if (ret_var.is_owned) {
34840         ret_ref |= 1;
34841 }
34842         return ret_ref;
34843 }
34844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34845         LDKChannelReestablish arg_conv;
34846         arg_conv.inner = (void*)(arg & (~1));
34847         arg_conv.is_owned = false;
34848         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34849         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
34850         return ret_conv;
34851 }
34852
34853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34854         LDKChannelReestablish orig_conv;
34855         orig_conv.inner = (void*)(orig & (~1));
34856         orig_conv.is_owned = false;
34857         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34858         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
34859         int64_t ret_ref = 0;
34860         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34861         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34863         ret_ref = (uintptr_t)ret_var.inner;
34864         if (ret_var.is_owned) {
34865                 ret_ref |= 1;
34866         }
34867         return ret_ref;
34868 }
34869
34870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34871         LDKAnnouncementSignatures this_obj_conv;
34872         this_obj_conv.inner = (void*)(this_obj & (~1));
34873         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34875         AnnouncementSignatures_free(this_obj_conv);
34876 }
34877
34878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34879         LDKAnnouncementSignatures this_ptr_conv;
34880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34881         this_ptr_conv.is_owned = false;
34882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34883         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34884         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
34885         return ret_arr;
34886 }
34887
34888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34889         LDKAnnouncementSignatures this_ptr_conv;
34890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34891         this_ptr_conv.is_owned = false;
34892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34893         LDKThirtyTwoBytes val_ref;
34894         CHECK((*env)->GetArrayLength(env, val) == 32);
34895         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34896         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
34897 }
34898
34899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34900         LDKAnnouncementSignatures this_ptr_conv;
34901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34902         this_ptr_conv.is_owned = false;
34903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34904         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
34905         return ret_conv;
34906 }
34907
34908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34909         LDKAnnouncementSignatures this_ptr_conv;
34910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34911         this_ptr_conv.is_owned = false;
34912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34913         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
34914 }
34915
34916 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34917         LDKAnnouncementSignatures this_ptr_conv;
34918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34919         this_ptr_conv.is_owned = false;
34920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34921         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34922         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
34923         return ret_arr;
34924 }
34925
34926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34927         LDKAnnouncementSignatures this_ptr_conv;
34928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34929         this_ptr_conv.is_owned = false;
34930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34931         LDKSignature val_ref;
34932         CHECK((*env)->GetArrayLength(env, val) == 64);
34933         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34934         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
34935 }
34936
34937 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34938         LDKAnnouncementSignatures this_ptr_conv;
34939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34940         this_ptr_conv.is_owned = false;
34941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34942         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34943         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
34944         return ret_arr;
34945 }
34946
34947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34948         LDKAnnouncementSignatures this_ptr_conv;
34949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34950         this_ptr_conv.is_owned = false;
34951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34952         LDKSignature val_ref;
34953         CHECK((*env)->GetArrayLength(env, val) == 64);
34954         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34955         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
34956 }
34957
34958 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) {
34959         LDKThirtyTwoBytes channel_id_arg_ref;
34960         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34961         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34962         LDKSignature node_signature_arg_ref;
34963         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
34964         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
34965         LDKSignature bitcoin_signature_arg_ref;
34966         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
34967         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
34968         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
34969         int64_t ret_ref = 0;
34970         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34971         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34973         ret_ref = (uintptr_t)ret_var.inner;
34974         if (ret_var.is_owned) {
34975                 ret_ref |= 1;
34976         }
34977         return ret_ref;
34978 }
34979
34980 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
34981         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
34982 int64_t ret_ref = 0;
34983 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34984 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34985 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34986 ret_ref = (uintptr_t)ret_var.inner;
34987 if (ret_var.is_owned) {
34988         ret_ref |= 1;
34989 }
34990         return ret_ref;
34991 }
34992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34993         LDKAnnouncementSignatures arg_conv;
34994         arg_conv.inner = (void*)(arg & (~1));
34995         arg_conv.is_owned = false;
34996         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34997         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
34998         return ret_conv;
34999 }
35000
35001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35002         LDKAnnouncementSignatures orig_conv;
35003         orig_conv.inner = (void*)(orig & (~1));
35004         orig_conv.is_owned = false;
35005         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35006         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
35007         int64_t ret_ref = 0;
35008         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35009         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35011         ret_ref = (uintptr_t)ret_var.inner;
35012         if (ret_var.is_owned) {
35013                 ret_ref |= 1;
35014         }
35015         return ret_ref;
35016 }
35017
35018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35019         if ((this_ptr & 1) != 0) return;
35020         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35021         CHECK_ACCESS(this_ptr_ptr);
35022         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
35023         FREE((void*)this_ptr);
35024         NetAddress_free(this_ptr_conv);
35025 }
35026
35027 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
35028         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35029         *ret_copy = NetAddress_clone(arg);
35030 int64_t ret_ref = (uintptr_t)ret_copy;
35031         return ret_ref;
35032 }
35033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35034         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
35035         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
35036         return ret_conv;
35037 }
35038
35039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35040         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
35041         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35042         *ret_copy = NetAddress_clone(orig_conv);
35043         int64_t ret_ref = (uintptr_t)ret_copy;
35044         return ret_ref;
35045 }
35046
35047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
35048         LDKFourBytes addr_ref;
35049         CHECK((*env)->GetArrayLength(env, addr) == 4);
35050         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
35051         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35052         *ret_copy = NetAddress_ipv4(addr_ref, port);
35053         int64_t ret_ref = (uintptr_t)ret_copy;
35054         return ret_ref;
35055 }
35056
35057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
35058         LDKSixteenBytes addr_ref;
35059         CHECK((*env)->GetArrayLength(env, addr) == 16);
35060         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
35061         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35062         *ret_copy = NetAddress_ipv6(addr_ref, port);
35063         int64_t ret_ref = (uintptr_t)ret_copy;
35064         return ret_ref;
35065 }
35066
35067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
35068         LDKTwelveBytes a_ref;
35069         CHECK((*env)->GetArrayLength(env, a) == 12);
35070         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
35071         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35072         *ret_copy = NetAddress_onion_v2(a_ref);
35073         int64_t ret_ref = (uintptr_t)ret_copy;
35074         return ret_ref;
35075 }
35076
35077 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) {
35078         LDKThirtyTwoBytes ed25519_pubkey_ref;
35079         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
35080         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
35081         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35082         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
35083         int64_t ret_ref = (uintptr_t)ret_copy;
35084         return ret_ref;
35085 }
35086
35087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1hostname(JNIEnv *env, jclass clz, int64_t hostname, int16_t port) {
35088         LDKHostname hostname_conv;
35089         hostname_conv.inner = (void*)(hostname & (~1));
35090         hostname_conv.is_owned = (hostname & 1) || (hostname == 0);
35091         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
35092         hostname_conv = Hostname_clone(&hostname_conv);
35093         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35094         *ret_copy = NetAddress_hostname(hostname_conv, port);
35095         int64_t ret_ref = (uintptr_t)ret_copy;
35096         return ret_ref;
35097 }
35098
35099 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
35100         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
35101         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
35102         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35103         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35104         CVec_u8Z_free(ret_var);
35105         return ret_arr;
35106 }
35107
35108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35109         LDKu8slice ser_ref;
35110         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35111         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35112         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
35113         *ret_conv = NetAddress_read(ser_ref);
35114         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35115         return (int64_t)ret_conv;
35116 }
35117
35118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35119         LDKUnsignedNodeAnnouncement this_obj_conv;
35120         this_obj_conv.inner = (void*)(this_obj & (~1));
35121         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35123         UnsignedNodeAnnouncement_free(this_obj_conv);
35124 }
35125
35126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
35127         LDKUnsignedNodeAnnouncement this_ptr_conv;
35128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35129         this_ptr_conv.is_owned = false;
35130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35131         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
35132         int64_t ret_ref = 0;
35133         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35134         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35136         ret_ref = (uintptr_t)ret_var.inner;
35137         if (ret_var.is_owned) {
35138                 ret_ref |= 1;
35139         }
35140         return ret_ref;
35141 }
35142
35143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35144         LDKUnsignedNodeAnnouncement this_ptr_conv;
35145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35146         this_ptr_conv.is_owned = false;
35147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35148         LDKNodeFeatures val_conv;
35149         val_conv.inner = (void*)(val & (~1));
35150         val_conv.is_owned = (val & 1) || (val == 0);
35151         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35152         val_conv = NodeFeatures_clone(&val_conv);
35153         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
35154 }
35155
35156 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
35157         LDKUnsignedNodeAnnouncement this_ptr_conv;
35158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35159         this_ptr_conv.is_owned = false;
35160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35161         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
35162         return ret_conv;
35163 }
35164
35165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35166         LDKUnsignedNodeAnnouncement this_ptr_conv;
35167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35168         this_ptr_conv.is_owned = false;
35169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35170         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
35171 }
35172
35173 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35174         LDKUnsignedNodeAnnouncement this_ptr_conv;
35175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35176         this_ptr_conv.is_owned = false;
35177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35178         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35179         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
35180         return ret_arr;
35181 }
35182
35183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35184         LDKUnsignedNodeAnnouncement this_ptr_conv;
35185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35186         this_ptr_conv.is_owned = false;
35187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35188         LDKPublicKey val_ref;
35189         CHECK((*env)->GetArrayLength(env, val) == 33);
35190         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35191         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
35192 }
35193
35194 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
35195         LDKUnsignedNodeAnnouncement this_ptr_conv;
35196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35197         this_ptr_conv.is_owned = false;
35198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35199         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
35200         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
35201         return ret_arr;
35202 }
35203
35204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35205         LDKUnsignedNodeAnnouncement this_ptr_conv;
35206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35207         this_ptr_conv.is_owned = false;
35208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35209         LDKThreeBytes val_ref;
35210         CHECK((*env)->GetArrayLength(env, val) == 3);
35211         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
35212         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
35213 }
35214
35215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
35216         LDKUnsignedNodeAnnouncement this_ptr_conv;
35217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35218         this_ptr_conv.is_owned = false;
35219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35220         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35221         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
35222         return ret_arr;
35223 }
35224
35225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35226         LDKUnsignedNodeAnnouncement this_ptr_conv;
35227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35228         this_ptr_conv.is_owned = false;
35229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35230         LDKThirtyTwoBytes val_ref;
35231         CHECK((*env)->GetArrayLength(env, val) == 32);
35232         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35233         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
35234 }
35235
35236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35237         LDKUnsignedNodeAnnouncement this_ptr_conv;
35238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35239         this_ptr_conv.is_owned = false;
35240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35241         LDKCVec_NetAddressZ val_constr;
35242         val_constr.datalen = (*env)->GetArrayLength(env, val);
35243         if (val_constr.datalen > 0)
35244                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
35245         else
35246                 val_constr.data = NULL;
35247         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35248         for (size_t m = 0; m < val_constr.datalen; m++) {
35249                 int64_t val_conv_12 = val_vals[m];
35250                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
35251                 CHECK_ACCESS(val_conv_12_ptr);
35252                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
35253                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
35254                 val_constr.data[m] = val_conv_12_conv;
35255         }
35256         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35257         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
35258 }
35259
35260 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
35261         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
35262 int64_t ret_ref = 0;
35263 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35264 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35265 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35266 ret_ref = (uintptr_t)ret_var.inner;
35267 if (ret_var.is_owned) {
35268         ret_ref |= 1;
35269 }
35270         return ret_ref;
35271 }
35272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35273         LDKUnsignedNodeAnnouncement arg_conv;
35274         arg_conv.inner = (void*)(arg & (~1));
35275         arg_conv.is_owned = false;
35276         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35277         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
35278         return ret_conv;
35279 }
35280
35281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35282         LDKUnsignedNodeAnnouncement orig_conv;
35283         orig_conv.inner = (void*)(orig & (~1));
35284         orig_conv.is_owned = false;
35285         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35286         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
35287         int64_t ret_ref = 0;
35288         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35289         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35291         ret_ref = (uintptr_t)ret_var.inner;
35292         if (ret_var.is_owned) {
35293                 ret_ref |= 1;
35294         }
35295         return ret_ref;
35296 }
35297
35298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35299         LDKNodeAnnouncement this_obj_conv;
35300         this_obj_conv.inner = (void*)(this_obj & (~1));
35301         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35303         NodeAnnouncement_free(this_obj_conv);
35304 }
35305
35306 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
35307         LDKNodeAnnouncement this_ptr_conv;
35308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35309         this_ptr_conv.is_owned = false;
35310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35311         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35312         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
35313         return ret_arr;
35314 }
35315
35316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35317         LDKNodeAnnouncement this_ptr_conv;
35318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35319         this_ptr_conv.is_owned = false;
35320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35321         LDKSignature val_ref;
35322         CHECK((*env)->GetArrayLength(env, val) == 64);
35323         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35324         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
35325 }
35326
35327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
35328         LDKNodeAnnouncement this_ptr_conv;
35329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35330         this_ptr_conv.is_owned = false;
35331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35332         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
35333         int64_t ret_ref = 0;
35334         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35335         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35337         ret_ref = (uintptr_t)ret_var.inner;
35338         if (ret_var.is_owned) {
35339                 ret_ref |= 1;
35340         }
35341         return ret_ref;
35342 }
35343
35344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35345         LDKNodeAnnouncement this_ptr_conv;
35346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35347         this_ptr_conv.is_owned = false;
35348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35349         LDKUnsignedNodeAnnouncement val_conv;
35350         val_conv.inner = (void*)(val & (~1));
35351         val_conv.is_owned = (val & 1) || (val == 0);
35352         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35353         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
35354         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
35355 }
35356
35357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
35358         LDKSignature signature_arg_ref;
35359         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
35360         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
35361         LDKUnsignedNodeAnnouncement contents_arg_conv;
35362         contents_arg_conv.inner = (void*)(contents_arg & (~1));
35363         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
35364         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
35365         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
35366         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
35367         int64_t ret_ref = 0;
35368         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35369         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35371         ret_ref = (uintptr_t)ret_var.inner;
35372         if (ret_var.is_owned) {
35373                 ret_ref |= 1;
35374         }
35375         return ret_ref;
35376 }
35377
35378 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
35379         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
35380 int64_t ret_ref = 0;
35381 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35382 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35383 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35384 ret_ref = (uintptr_t)ret_var.inner;
35385 if (ret_var.is_owned) {
35386         ret_ref |= 1;
35387 }
35388         return ret_ref;
35389 }
35390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35391         LDKNodeAnnouncement arg_conv;
35392         arg_conv.inner = (void*)(arg & (~1));
35393         arg_conv.is_owned = false;
35394         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35395         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
35396         return ret_conv;
35397 }
35398
35399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35400         LDKNodeAnnouncement orig_conv;
35401         orig_conv.inner = (void*)(orig & (~1));
35402         orig_conv.is_owned = false;
35403         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35404         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
35405         int64_t ret_ref = 0;
35406         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35407         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35409         ret_ref = (uintptr_t)ret_var.inner;
35410         if (ret_var.is_owned) {
35411                 ret_ref |= 1;
35412         }
35413         return ret_ref;
35414 }
35415
35416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35417         LDKUnsignedChannelAnnouncement this_obj_conv;
35418         this_obj_conv.inner = (void*)(this_obj & (~1));
35419         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35421         UnsignedChannelAnnouncement_free(this_obj_conv);
35422 }
35423
35424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
35425         LDKUnsignedChannelAnnouncement this_ptr_conv;
35426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35427         this_ptr_conv.is_owned = false;
35428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35429         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
35430         int64_t ret_ref = 0;
35431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35434         ret_ref = (uintptr_t)ret_var.inner;
35435         if (ret_var.is_owned) {
35436                 ret_ref |= 1;
35437         }
35438         return ret_ref;
35439 }
35440
35441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35442         LDKUnsignedChannelAnnouncement this_ptr_conv;
35443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35444         this_ptr_conv.is_owned = false;
35445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35446         LDKChannelFeatures val_conv;
35447         val_conv.inner = (void*)(val & (~1));
35448         val_conv.is_owned = (val & 1) || (val == 0);
35449         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35450         val_conv = ChannelFeatures_clone(&val_conv);
35451         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
35452 }
35453
35454 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35455         LDKUnsignedChannelAnnouncement this_ptr_conv;
35456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35457         this_ptr_conv.is_owned = false;
35458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35459         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35460         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
35461         return ret_arr;
35462 }
35463
35464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35465         LDKUnsignedChannelAnnouncement this_ptr_conv;
35466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35467         this_ptr_conv.is_owned = false;
35468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35469         LDKThirtyTwoBytes val_ref;
35470         CHECK((*env)->GetArrayLength(env, val) == 32);
35471         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35472         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
35473 }
35474
35475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35476         LDKUnsignedChannelAnnouncement this_ptr_conv;
35477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35478         this_ptr_conv.is_owned = false;
35479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35480         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
35481         return ret_conv;
35482 }
35483
35484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35485         LDKUnsignedChannelAnnouncement this_ptr_conv;
35486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35487         this_ptr_conv.is_owned = false;
35488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35489         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
35490 }
35491
35492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
35493         LDKUnsignedChannelAnnouncement this_ptr_conv;
35494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35495         this_ptr_conv.is_owned = false;
35496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35497         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35498         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
35499         return ret_arr;
35500 }
35501
35502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35503         LDKUnsignedChannelAnnouncement this_ptr_conv;
35504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35505         this_ptr_conv.is_owned = false;
35506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35507         LDKPublicKey val_ref;
35508         CHECK((*env)->GetArrayLength(env, val) == 33);
35509         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35510         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
35511 }
35512
35513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
35514         LDKUnsignedChannelAnnouncement this_ptr_conv;
35515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35516         this_ptr_conv.is_owned = false;
35517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35518         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35519         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
35520         return ret_arr;
35521 }
35522
35523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35524         LDKUnsignedChannelAnnouncement this_ptr_conv;
35525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35526         this_ptr_conv.is_owned = false;
35527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35528         LDKPublicKey val_ref;
35529         CHECK((*env)->GetArrayLength(env, val) == 33);
35530         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35531         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
35532 }
35533
35534 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
35535         LDKUnsignedChannelAnnouncement this_ptr_conv;
35536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35537         this_ptr_conv.is_owned = false;
35538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35539         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35540         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
35541         return ret_arr;
35542 }
35543
35544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35545         LDKUnsignedChannelAnnouncement this_ptr_conv;
35546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35547         this_ptr_conv.is_owned = false;
35548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35549         LDKPublicKey val_ref;
35550         CHECK((*env)->GetArrayLength(env, val) == 33);
35551         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35552         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
35553 }
35554
35555 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
35556         LDKUnsignedChannelAnnouncement this_ptr_conv;
35557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35558         this_ptr_conv.is_owned = false;
35559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35560         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35561         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
35562         return ret_arr;
35563 }
35564
35565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35566         LDKUnsignedChannelAnnouncement this_ptr_conv;
35567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35568         this_ptr_conv.is_owned = false;
35569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35570         LDKPublicKey val_ref;
35571         CHECK((*env)->GetArrayLength(env, val) == 33);
35572         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35573         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
35574 }
35575
35576 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
35577         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
35578 int64_t ret_ref = 0;
35579 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35580 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35581 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35582 ret_ref = (uintptr_t)ret_var.inner;
35583 if (ret_var.is_owned) {
35584         ret_ref |= 1;
35585 }
35586         return ret_ref;
35587 }
35588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35589         LDKUnsignedChannelAnnouncement arg_conv;
35590         arg_conv.inner = (void*)(arg & (~1));
35591         arg_conv.is_owned = false;
35592         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35593         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
35594         return ret_conv;
35595 }
35596
35597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35598         LDKUnsignedChannelAnnouncement orig_conv;
35599         orig_conv.inner = (void*)(orig & (~1));
35600         orig_conv.is_owned = false;
35601         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35602         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
35603         int64_t ret_ref = 0;
35604         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35605         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35607         ret_ref = (uintptr_t)ret_var.inner;
35608         if (ret_var.is_owned) {
35609                 ret_ref |= 1;
35610         }
35611         return ret_ref;
35612 }
35613
35614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35615         LDKChannelAnnouncement this_obj_conv;
35616         this_obj_conv.inner = (void*)(this_obj & (~1));
35617         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35619         ChannelAnnouncement_free(this_obj_conv);
35620 }
35621
35622 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
35623         LDKChannelAnnouncement this_ptr_conv;
35624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35625         this_ptr_conv.is_owned = false;
35626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35627         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35628         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
35629         return ret_arr;
35630 }
35631
35632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35633         LDKChannelAnnouncement this_ptr_conv;
35634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35635         this_ptr_conv.is_owned = false;
35636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35637         LDKSignature val_ref;
35638         CHECK((*env)->GetArrayLength(env, val) == 64);
35639         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35640         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
35641 }
35642
35643 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
35644         LDKChannelAnnouncement this_ptr_conv;
35645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35646         this_ptr_conv.is_owned = false;
35647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35648         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35649         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
35650         return ret_arr;
35651 }
35652
35653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35654         LDKChannelAnnouncement this_ptr_conv;
35655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35656         this_ptr_conv.is_owned = false;
35657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35658         LDKSignature val_ref;
35659         CHECK((*env)->GetArrayLength(env, val) == 64);
35660         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35661         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
35662 }
35663
35664 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
35665         LDKChannelAnnouncement this_ptr_conv;
35666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35667         this_ptr_conv.is_owned = false;
35668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35669         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35670         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
35671         return ret_arr;
35672 }
35673
35674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35675         LDKChannelAnnouncement this_ptr_conv;
35676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35677         this_ptr_conv.is_owned = false;
35678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35679         LDKSignature val_ref;
35680         CHECK((*env)->GetArrayLength(env, val) == 64);
35681         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35682         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
35683 }
35684
35685 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
35686         LDKChannelAnnouncement this_ptr_conv;
35687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35688         this_ptr_conv.is_owned = false;
35689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35690         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35691         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
35692         return ret_arr;
35693 }
35694
35695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35696         LDKChannelAnnouncement this_ptr_conv;
35697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35698         this_ptr_conv.is_owned = false;
35699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35700         LDKSignature val_ref;
35701         CHECK((*env)->GetArrayLength(env, val) == 64);
35702         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35703         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
35704 }
35705
35706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
35707         LDKChannelAnnouncement this_ptr_conv;
35708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35709         this_ptr_conv.is_owned = false;
35710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35711         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
35712         int64_t ret_ref = 0;
35713         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35714         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35715         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35716         ret_ref = (uintptr_t)ret_var.inner;
35717         if (ret_var.is_owned) {
35718                 ret_ref |= 1;
35719         }
35720         return ret_ref;
35721 }
35722
35723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35724         LDKChannelAnnouncement this_ptr_conv;
35725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35726         this_ptr_conv.is_owned = false;
35727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35728         LDKUnsignedChannelAnnouncement val_conv;
35729         val_conv.inner = (void*)(val & (~1));
35730         val_conv.is_owned = (val & 1) || (val == 0);
35731         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35732         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
35733         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
35734 }
35735
35736 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) {
35737         LDKSignature node_signature_1_arg_ref;
35738         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
35739         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
35740         LDKSignature node_signature_2_arg_ref;
35741         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
35742         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
35743         LDKSignature bitcoin_signature_1_arg_ref;
35744         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
35745         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
35746         LDKSignature bitcoin_signature_2_arg_ref;
35747         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
35748         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
35749         LDKUnsignedChannelAnnouncement contents_arg_conv;
35750         contents_arg_conv.inner = (void*)(contents_arg & (~1));
35751         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
35752         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
35753         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
35754         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);
35755         int64_t ret_ref = 0;
35756         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35757         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35759         ret_ref = (uintptr_t)ret_var.inner;
35760         if (ret_var.is_owned) {
35761                 ret_ref |= 1;
35762         }
35763         return ret_ref;
35764 }
35765
35766 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
35767         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
35768 int64_t ret_ref = 0;
35769 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35770 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35771 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35772 ret_ref = (uintptr_t)ret_var.inner;
35773 if (ret_var.is_owned) {
35774         ret_ref |= 1;
35775 }
35776         return ret_ref;
35777 }
35778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35779         LDKChannelAnnouncement arg_conv;
35780         arg_conv.inner = (void*)(arg & (~1));
35781         arg_conv.is_owned = false;
35782         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35783         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
35784         return ret_conv;
35785 }
35786
35787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35788         LDKChannelAnnouncement orig_conv;
35789         orig_conv.inner = (void*)(orig & (~1));
35790         orig_conv.is_owned = false;
35791         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35792         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
35793         int64_t ret_ref = 0;
35794         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35795         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35797         ret_ref = (uintptr_t)ret_var.inner;
35798         if (ret_var.is_owned) {
35799                 ret_ref |= 1;
35800         }
35801         return ret_ref;
35802 }
35803
35804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35805         LDKUnsignedChannelUpdate this_obj_conv;
35806         this_obj_conv.inner = (void*)(this_obj & (~1));
35807         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35809         UnsignedChannelUpdate_free(this_obj_conv);
35810 }
35811
35812 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35813         LDKUnsignedChannelUpdate this_ptr_conv;
35814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35815         this_ptr_conv.is_owned = false;
35816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35817         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35818         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
35819         return ret_arr;
35820 }
35821
35822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35823         LDKUnsignedChannelUpdate this_ptr_conv;
35824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35825         this_ptr_conv.is_owned = false;
35826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35827         LDKThirtyTwoBytes val_ref;
35828         CHECK((*env)->GetArrayLength(env, val) == 32);
35829         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35830         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
35831 }
35832
35833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35834         LDKUnsignedChannelUpdate this_ptr_conv;
35835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35836         this_ptr_conv.is_owned = false;
35837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35838         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
35839         return ret_conv;
35840 }
35841
35842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35843         LDKUnsignedChannelUpdate this_ptr_conv;
35844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35845         this_ptr_conv.is_owned = false;
35846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35847         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
35848 }
35849
35850 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
35851         LDKUnsignedChannelUpdate this_ptr_conv;
35852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35853         this_ptr_conv.is_owned = false;
35854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35855         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
35856         return ret_conv;
35857 }
35858
35859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35860         LDKUnsignedChannelUpdate this_ptr_conv;
35861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35862         this_ptr_conv.is_owned = false;
35863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35864         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
35865 }
35866
35867 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
35868         LDKUnsignedChannelUpdate this_ptr_conv;
35869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35870         this_ptr_conv.is_owned = false;
35871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35872         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
35873         return ret_conv;
35874 }
35875
35876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
35877         LDKUnsignedChannelUpdate this_ptr_conv;
35878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35879         this_ptr_conv.is_owned = false;
35880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35881         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
35882 }
35883
35884 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
35885         LDKUnsignedChannelUpdate this_ptr_conv;
35886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35887         this_ptr_conv.is_owned = false;
35888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35889         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
35890         return ret_conv;
35891 }
35892
35893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35894         LDKUnsignedChannelUpdate this_ptr_conv;
35895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35896         this_ptr_conv.is_owned = false;
35897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35898         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
35899 }
35900
35901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35902         LDKUnsignedChannelUpdate this_ptr_conv;
35903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35904         this_ptr_conv.is_owned = false;
35905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35906         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
35907         return ret_conv;
35908 }
35909
35910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35911         LDKUnsignedChannelUpdate this_ptr_conv;
35912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35913         this_ptr_conv.is_owned = false;
35914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35915         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
35916 }
35917
35918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35919         LDKUnsignedChannelUpdate this_ptr_conv;
35920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35921         this_ptr_conv.is_owned = false;
35922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35923         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
35924         return ret_conv;
35925 }
35926
35927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35928         LDKUnsignedChannelUpdate this_ptr_conv;
35929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35930         this_ptr_conv.is_owned = false;
35931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35932         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
35933 }
35934
35935 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35936         LDKUnsignedChannelUpdate this_ptr_conv;
35937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35938         this_ptr_conv.is_owned = false;
35939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35940         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
35941         return ret_conv;
35942 }
35943
35944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35945         LDKUnsignedChannelUpdate this_ptr_conv;
35946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35947         this_ptr_conv.is_owned = false;
35948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35949         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
35950 }
35951
35952 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
35953         LDKUnsignedChannelUpdate this_ptr_conv;
35954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35955         this_ptr_conv.is_owned = false;
35956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35957         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
35958         return ret_conv;
35959 }
35960
35961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35962         LDKUnsignedChannelUpdate this_ptr_conv;
35963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35964         this_ptr_conv.is_owned = false;
35965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35966         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
35967 }
35968
35969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35970         LDKUnsignedChannelUpdate this_ptr_conv;
35971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35972         this_ptr_conv.is_owned = false;
35973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35974         LDKCVec_u8Z val_ref;
35975         val_ref.datalen = (*env)->GetArrayLength(env, val);
35976         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
35977         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
35978         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
35979 }
35980
35981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, int64_t short_channel_id_arg, int32_t timestamp_arg, int8_t flags_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int8_tArray excess_data_arg) {
35982         LDKThirtyTwoBytes chain_hash_arg_ref;
35983         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35984         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35985         LDKCVec_u8Z excess_data_arg_ref;
35986         excess_data_arg_ref.datalen = (*env)->GetArrayLength(env, excess_data_arg);
35987         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
35988         (*env)->GetByteArrayRegion(env, excess_data_arg, 0, excess_data_arg_ref.datalen, excess_data_arg_ref.data);
35989         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_new(chain_hash_arg_ref, short_channel_id_arg, timestamp_arg, flags_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fee_base_msat_arg, fee_proportional_millionths_arg, excess_data_arg_ref);
35990         int64_t ret_ref = 0;
35991         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35992         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35994         ret_ref = (uintptr_t)ret_var.inner;
35995         if (ret_var.is_owned) {
35996                 ret_ref |= 1;
35997         }
35998         return ret_ref;
35999 }
36000
36001 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
36002         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
36003 int64_t ret_ref = 0;
36004 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36005 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36006 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36007 ret_ref = (uintptr_t)ret_var.inner;
36008 if (ret_var.is_owned) {
36009         ret_ref |= 1;
36010 }
36011         return ret_ref;
36012 }
36013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36014         LDKUnsignedChannelUpdate arg_conv;
36015         arg_conv.inner = (void*)(arg & (~1));
36016         arg_conv.is_owned = false;
36017         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36018         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
36019         return ret_conv;
36020 }
36021
36022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36023         LDKUnsignedChannelUpdate orig_conv;
36024         orig_conv.inner = (void*)(orig & (~1));
36025         orig_conv.is_owned = false;
36026         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36027         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
36028         int64_t ret_ref = 0;
36029         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36030         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36031         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36032         ret_ref = (uintptr_t)ret_var.inner;
36033         if (ret_var.is_owned) {
36034                 ret_ref |= 1;
36035         }
36036         return ret_ref;
36037 }
36038
36039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36040         LDKChannelUpdate this_obj_conv;
36041         this_obj_conv.inner = (void*)(this_obj & (~1));
36042         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36044         ChannelUpdate_free(this_obj_conv);
36045 }
36046
36047 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36048         LDKChannelUpdate this_ptr_conv;
36049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36050         this_ptr_conv.is_owned = false;
36051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36052         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36053         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
36054         return ret_arr;
36055 }
36056
36057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36058         LDKChannelUpdate this_ptr_conv;
36059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36060         this_ptr_conv.is_owned = false;
36061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36062         LDKSignature val_ref;
36063         CHECK((*env)->GetArrayLength(env, val) == 64);
36064         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36065         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
36066 }
36067
36068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
36069         LDKChannelUpdate this_ptr_conv;
36070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36071         this_ptr_conv.is_owned = false;
36072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36073         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
36074         int64_t ret_ref = 0;
36075         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36076         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36078         ret_ref = (uintptr_t)ret_var.inner;
36079         if (ret_var.is_owned) {
36080                 ret_ref |= 1;
36081         }
36082         return ret_ref;
36083 }
36084
36085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36086         LDKChannelUpdate this_ptr_conv;
36087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36088         this_ptr_conv.is_owned = false;
36089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36090         LDKUnsignedChannelUpdate val_conv;
36091         val_conv.inner = (void*)(val & (~1));
36092         val_conv.is_owned = (val & 1) || (val == 0);
36093         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36094         val_conv = UnsignedChannelUpdate_clone(&val_conv);
36095         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
36096 }
36097
36098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
36099         LDKSignature signature_arg_ref;
36100         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36101         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36102         LDKUnsignedChannelUpdate contents_arg_conv;
36103         contents_arg_conv.inner = (void*)(contents_arg & (~1));
36104         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
36105         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
36106         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
36107         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
36108         int64_t ret_ref = 0;
36109         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36110         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36112         ret_ref = (uintptr_t)ret_var.inner;
36113         if (ret_var.is_owned) {
36114                 ret_ref |= 1;
36115         }
36116         return ret_ref;
36117 }
36118
36119 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
36120         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
36121 int64_t ret_ref = 0;
36122 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36123 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36124 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36125 ret_ref = (uintptr_t)ret_var.inner;
36126 if (ret_var.is_owned) {
36127         ret_ref |= 1;
36128 }
36129         return ret_ref;
36130 }
36131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36132         LDKChannelUpdate arg_conv;
36133         arg_conv.inner = (void*)(arg & (~1));
36134         arg_conv.is_owned = false;
36135         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36136         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
36137         return ret_conv;
36138 }
36139
36140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36141         LDKChannelUpdate orig_conv;
36142         orig_conv.inner = (void*)(orig & (~1));
36143         orig_conv.is_owned = false;
36144         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36145         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
36146         int64_t ret_ref = 0;
36147         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36148         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36150         ret_ref = (uintptr_t)ret_var.inner;
36151         if (ret_var.is_owned) {
36152                 ret_ref |= 1;
36153         }
36154         return ret_ref;
36155 }
36156
36157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36158         LDKQueryChannelRange this_obj_conv;
36159         this_obj_conv.inner = (void*)(this_obj & (~1));
36160         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36162         QueryChannelRange_free(this_obj_conv);
36163 }
36164
36165 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36166         LDKQueryChannelRange this_ptr_conv;
36167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36168         this_ptr_conv.is_owned = false;
36169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36170         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36171         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
36172         return ret_arr;
36173 }
36174
36175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36176         LDKQueryChannelRange this_ptr_conv;
36177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36178         this_ptr_conv.is_owned = false;
36179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36180         LDKThirtyTwoBytes val_ref;
36181         CHECK((*env)->GetArrayLength(env, val) == 32);
36182         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36183         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
36184 }
36185
36186 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
36187         LDKQueryChannelRange this_ptr_conv;
36188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36189         this_ptr_conv.is_owned = false;
36190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36191         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
36192         return ret_conv;
36193 }
36194
36195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36196         LDKQueryChannelRange this_ptr_conv;
36197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36198         this_ptr_conv.is_owned = false;
36199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36200         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
36201 }
36202
36203 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
36204         LDKQueryChannelRange this_ptr_conv;
36205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36206         this_ptr_conv.is_owned = false;
36207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36208         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
36209         return ret_conv;
36210 }
36211
36212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36213         LDKQueryChannelRange this_ptr_conv;
36214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36215         this_ptr_conv.is_owned = false;
36216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36217         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
36218 }
36219
36220 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) {
36221         LDKThirtyTwoBytes chain_hash_arg_ref;
36222         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36223         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36224         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
36225         int64_t ret_ref = 0;
36226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36229         ret_ref = (uintptr_t)ret_var.inner;
36230         if (ret_var.is_owned) {
36231                 ret_ref |= 1;
36232         }
36233         return ret_ref;
36234 }
36235
36236 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
36237         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
36238 int64_t ret_ref = 0;
36239 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36240 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36241 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36242 ret_ref = (uintptr_t)ret_var.inner;
36243 if (ret_var.is_owned) {
36244         ret_ref |= 1;
36245 }
36246         return ret_ref;
36247 }
36248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36249         LDKQueryChannelRange arg_conv;
36250         arg_conv.inner = (void*)(arg & (~1));
36251         arg_conv.is_owned = false;
36252         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36253         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
36254         return ret_conv;
36255 }
36256
36257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36258         LDKQueryChannelRange orig_conv;
36259         orig_conv.inner = (void*)(orig & (~1));
36260         orig_conv.is_owned = false;
36261         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36262         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
36263         int64_t ret_ref = 0;
36264         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36265         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36267         ret_ref = (uintptr_t)ret_var.inner;
36268         if (ret_var.is_owned) {
36269                 ret_ref |= 1;
36270         }
36271         return ret_ref;
36272 }
36273
36274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36275         LDKReplyChannelRange this_obj_conv;
36276         this_obj_conv.inner = (void*)(this_obj & (~1));
36277         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36279         ReplyChannelRange_free(this_obj_conv);
36280 }
36281
36282 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36283         LDKReplyChannelRange this_ptr_conv;
36284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36285         this_ptr_conv.is_owned = false;
36286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36287         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36288         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
36289         return ret_arr;
36290 }
36291
36292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36293         LDKReplyChannelRange this_ptr_conv;
36294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36295         this_ptr_conv.is_owned = false;
36296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36297         LDKThirtyTwoBytes val_ref;
36298         CHECK((*env)->GetArrayLength(env, val) == 32);
36299         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36300         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
36301 }
36302
36303 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
36304         LDKReplyChannelRange this_ptr_conv;
36305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36306         this_ptr_conv.is_owned = false;
36307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36308         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
36309         return ret_conv;
36310 }
36311
36312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36313         LDKReplyChannelRange this_ptr_conv;
36314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36315         this_ptr_conv.is_owned = false;
36316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36317         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
36318 }
36319
36320 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
36321         LDKReplyChannelRange this_ptr_conv;
36322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36323         this_ptr_conv.is_owned = false;
36324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36325         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
36326         return ret_conv;
36327 }
36328
36329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36330         LDKReplyChannelRange 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         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
36335 }
36336
36337 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
36338         LDKReplyChannelRange this_ptr_conv;
36339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36340         this_ptr_conv.is_owned = false;
36341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36342         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
36343         return ret_conv;
36344 }
36345
36346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
36347         LDKReplyChannelRange this_ptr_conv;
36348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36349         this_ptr_conv.is_owned = false;
36350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36351         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
36352 }
36353
36354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36355         LDKReplyChannelRange this_ptr_conv;
36356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36357         this_ptr_conv.is_owned = false;
36358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36359         LDKCVec_u64Z val_constr;
36360         val_constr.datalen = (*env)->GetArrayLength(env, val);
36361         if (val_constr.datalen > 0)
36362                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36363         else
36364                 val_constr.data = NULL;
36365         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36366         for (size_t g = 0; g < val_constr.datalen; g++) {
36367                 int64_t val_conv_6 = val_vals[g];
36368                 val_constr.data[g] = val_conv_6;
36369         }
36370         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36371         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
36372 }
36373
36374 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) {
36375         LDKThirtyTwoBytes chain_hash_arg_ref;
36376         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36377         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36378         LDKCVec_u64Z short_channel_ids_arg_constr;
36379         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
36380         if (short_channel_ids_arg_constr.datalen > 0)
36381                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36382         else
36383                 short_channel_ids_arg_constr.data = NULL;
36384         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
36385         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
36386                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
36387                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
36388         }
36389         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
36390         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
36391         int64_t ret_ref = 0;
36392         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36393         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36395         ret_ref = (uintptr_t)ret_var.inner;
36396         if (ret_var.is_owned) {
36397                 ret_ref |= 1;
36398         }
36399         return ret_ref;
36400 }
36401
36402 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
36403         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
36404 int64_t ret_ref = 0;
36405 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36406 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36407 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36408 ret_ref = (uintptr_t)ret_var.inner;
36409 if (ret_var.is_owned) {
36410         ret_ref |= 1;
36411 }
36412         return ret_ref;
36413 }
36414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36415         LDKReplyChannelRange arg_conv;
36416         arg_conv.inner = (void*)(arg & (~1));
36417         arg_conv.is_owned = false;
36418         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36419         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
36420         return ret_conv;
36421 }
36422
36423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36424         LDKReplyChannelRange orig_conv;
36425         orig_conv.inner = (void*)(orig & (~1));
36426         orig_conv.is_owned = false;
36427         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36428         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
36429         int64_t ret_ref = 0;
36430         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36431         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36433         ret_ref = (uintptr_t)ret_var.inner;
36434         if (ret_var.is_owned) {
36435                 ret_ref |= 1;
36436         }
36437         return ret_ref;
36438 }
36439
36440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36441         LDKQueryShortChannelIds this_obj_conv;
36442         this_obj_conv.inner = (void*)(this_obj & (~1));
36443         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36445         QueryShortChannelIds_free(this_obj_conv);
36446 }
36447
36448 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36449         LDKQueryShortChannelIds this_ptr_conv;
36450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36451         this_ptr_conv.is_owned = false;
36452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36453         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36454         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
36455         return ret_arr;
36456 }
36457
36458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36459         LDKQueryShortChannelIds this_ptr_conv;
36460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36461         this_ptr_conv.is_owned = false;
36462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36463         LDKThirtyTwoBytes val_ref;
36464         CHECK((*env)->GetArrayLength(env, val) == 32);
36465         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36466         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
36467 }
36468
36469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36470         LDKQueryShortChannelIds this_ptr_conv;
36471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36472         this_ptr_conv.is_owned = false;
36473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36474         LDKCVec_u64Z val_constr;
36475         val_constr.datalen = (*env)->GetArrayLength(env, val);
36476         if (val_constr.datalen > 0)
36477                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36478         else
36479                 val_constr.data = NULL;
36480         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36481         for (size_t g = 0; g < val_constr.datalen; g++) {
36482                 int64_t val_conv_6 = val_vals[g];
36483                 val_constr.data[g] = val_conv_6;
36484         }
36485         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36486         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
36487 }
36488
36489 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) {
36490         LDKThirtyTwoBytes chain_hash_arg_ref;
36491         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36492         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36493         LDKCVec_u64Z short_channel_ids_arg_constr;
36494         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
36495         if (short_channel_ids_arg_constr.datalen > 0)
36496                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36497         else
36498                 short_channel_ids_arg_constr.data = NULL;
36499         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
36500         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
36501                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
36502                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
36503         }
36504         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
36505         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
36506         int64_t ret_ref = 0;
36507         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36508         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36510         ret_ref = (uintptr_t)ret_var.inner;
36511         if (ret_var.is_owned) {
36512                 ret_ref |= 1;
36513         }
36514         return ret_ref;
36515 }
36516
36517 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
36518         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
36519 int64_t ret_ref = 0;
36520 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36521 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36522 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36523 ret_ref = (uintptr_t)ret_var.inner;
36524 if (ret_var.is_owned) {
36525         ret_ref |= 1;
36526 }
36527         return ret_ref;
36528 }
36529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36530         LDKQueryShortChannelIds arg_conv;
36531         arg_conv.inner = (void*)(arg & (~1));
36532         arg_conv.is_owned = false;
36533         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36534         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
36535         return ret_conv;
36536 }
36537
36538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36539         LDKQueryShortChannelIds orig_conv;
36540         orig_conv.inner = (void*)(orig & (~1));
36541         orig_conv.is_owned = false;
36542         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36543         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
36544         int64_t ret_ref = 0;
36545         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36546         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36548         ret_ref = (uintptr_t)ret_var.inner;
36549         if (ret_var.is_owned) {
36550                 ret_ref |= 1;
36551         }
36552         return ret_ref;
36553 }
36554
36555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36556         LDKReplyShortChannelIdsEnd this_obj_conv;
36557         this_obj_conv.inner = (void*)(this_obj & (~1));
36558         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36560         ReplyShortChannelIdsEnd_free(this_obj_conv);
36561 }
36562
36563 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36564         LDKReplyShortChannelIdsEnd this_ptr_conv;
36565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36566         this_ptr_conv.is_owned = false;
36567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36568         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36569         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
36570         return ret_arr;
36571 }
36572
36573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36574         LDKReplyShortChannelIdsEnd this_ptr_conv;
36575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36576         this_ptr_conv.is_owned = false;
36577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36578         LDKThirtyTwoBytes val_ref;
36579         CHECK((*env)->GetArrayLength(env, val) == 32);
36580         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36581         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
36582 }
36583
36584 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
36585         LDKReplyShortChannelIdsEnd this_ptr_conv;
36586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36587         this_ptr_conv.is_owned = false;
36588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36589         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
36590         return ret_conv;
36591 }
36592
36593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
36594         LDKReplyShortChannelIdsEnd this_ptr_conv;
36595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36596         this_ptr_conv.is_owned = false;
36597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36598         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
36599 }
36600
36601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
36602         LDKThirtyTwoBytes chain_hash_arg_ref;
36603         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36604         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36605         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
36606         int64_t ret_ref = 0;
36607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36610         ret_ref = (uintptr_t)ret_var.inner;
36611         if (ret_var.is_owned) {
36612                 ret_ref |= 1;
36613         }
36614         return ret_ref;
36615 }
36616
36617 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
36618         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
36619 int64_t ret_ref = 0;
36620 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36621 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36622 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36623 ret_ref = (uintptr_t)ret_var.inner;
36624 if (ret_var.is_owned) {
36625         ret_ref |= 1;
36626 }
36627         return ret_ref;
36628 }
36629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36630         LDKReplyShortChannelIdsEnd arg_conv;
36631         arg_conv.inner = (void*)(arg & (~1));
36632         arg_conv.is_owned = false;
36633         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36634         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
36635         return ret_conv;
36636 }
36637
36638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36639         LDKReplyShortChannelIdsEnd orig_conv;
36640         orig_conv.inner = (void*)(orig & (~1));
36641         orig_conv.is_owned = false;
36642         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36643         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
36644         int64_t ret_ref = 0;
36645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36648         ret_ref = (uintptr_t)ret_var.inner;
36649         if (ret_var.is_owned) {
36650                 ret_ref |= 1;
36651         }
36652         return ret_ref;
36653 }
36654
36655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36656         LDKGossipTimestampFilter this_obj_conv;
36657         this_obj_conv.inner = (void*)(this_obj & (~1));
36658         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36660         GossipTimestampFilter_free(this_obj_conv);
36661 }
36662
36663 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36664         LDKGossipTimestampFilter this_ptr_conv;
36665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36666         this_ptr_conv.is_owned = false;
36667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36668         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36669         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
36670         return ret_arr;
36671 }
36672
36673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36674         LDKGossipTimestampFilter this_ptr_conv;
36675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36676         this_ptr_conv.is_owned = false;
36677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36678         LDKThirtyTwoBytes val_ref;
36679         CHECK((*env)->GetArrayLength(env, val) == 32);
36680         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36681         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
36682 }
36683
36684 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
36685         LDKGossipTimestampFilter this_ptr_conv;
36686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36687         this_ptr_conv.is_owned = false;
36688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36689         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
36690         return ret_conv;
36691 }
36692
36693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36694         LDKGossipTimestampFilter this_ptr_conv;
36695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36696         this_ptr_conv.is_owned = false;
36697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36698         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
36699 }
36700
36701 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
36702         LDKGossipTimestampFilter this_ptr_conv;
36703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36704         this_ptr_conv.is_owned = false;
36705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36706         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
36707         return ret_conv;
36708 }
36709
36710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36711         LDKGossipTimestampFilter this_ptr_conv;
36712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36713         this_ptr_conv.is_owned = false;
36714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36715         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
36716 }
36717
36718 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) {
36719         LDKThirtyTwoBytes chain_hash_arg_ref;
36720         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36721         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36722         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
36723         int64_t ret_ref = 0;
36724         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36725         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36727         ret_ref = (uintptr_t)ret_var.inner;
36728         if (ret_var.is_owned) {
36729                 ret_ref |= 1;
36730         }
36731         return ret_ref;
36732 }
36733
36734 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
36735         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
36736 int64_t ret_ref = 0;
36737 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36738 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36739 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36740 ret_ref = (uintptr_t)ret_var.inner;
36741 if (ret_var.is_owned) {
36742         ret_ref |= 1;
36743 }
36744         return ret_ref;
36745 }
36746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36747         LDKGossipTimestampFilter arg_conv;
36748         arg_conv.inner = (void*)(arg & (~1));
36749         arg_conv.is_owned = false;
36750         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36751         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
36752         return ret_conv;
36753 }
36754
36755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36756         LDKGossipTimestampFilter orig_conv;
36757         orig_conv.inner = (void*)(orig & (~1));
36758         orig_conv.is_owned = false;
36759         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36760         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
36761         int64_t ret_ref = 0;
36762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36765         ret_ref = (uintptr_t)ret_var.inner;
36766         if (ret_var.is_owned) {
36767                 ret_ref |= 1;
36768         }
36769         return ret_ref;
36770 }
36771
36772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36773         if ((this_ptr & 1) != 0) return;
36774         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36775         CHECK_ACCESS(this_ptr_ptr);
36776         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
36777         FREE((void*)this_ptr);
36778         ErrorAction_free(this_ptr_conv);
36779 }
36780
36781 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
36782         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36783         *ret_copy = ErrorAction_clone(arg);
36784 int64_t ret_ref = (uintptr_t)ret_copy;
36785         return ret_ref;
36786 }
36787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36788         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
36789         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
36790         return ret_conv;
36791 }
36792
36793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36794         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
36795         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36796         *ret_copy = ErrorAction_clone(orig_conv);
36797         int64_t ret_ref = (uintptr_t)ret_copy;
36798         return ret_ref;
36799 }
36800
36801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
36802         LDKErrorMessage msg_conv;
36803         msg_conv.inner = (void*)(msg & (~1));
36804         msg_conv.is_owned = (msg & 1) || (msg == 0);
36805         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36806         msg_conv = ErrorMessage_clone(&msg_conv);
36807         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36808         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
36809         int64_t ret_ref = (uintptr_t)ret_copy;
36810         return ret_ref;
36811 }
36812
36813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
36814         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36815         *ret_copy = ErrorAction_ignore_error();
36816         int64_t ret_ref = (uintptr_t)ret_copy;
36817         return ret_ref;
36818 }
36819
36820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
36821         LDKLevel a_conv = LDKLevel_from_java(env, a);
36822         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36823         *ret_copy = ErrorAction_ignore_and_log(a_conv);
36824         int64_t ret_ref = (uintptr_t)ret_copy;
36825         return ret_ref;
36826 }
36827
36828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
36829         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36830         *ret_copy = ErrorAction_ignore_duplicate_gossip();
36831         int64_t ret_ref = (uintptr_t)ret_copy;
36832         return ret_ref;
36833 }
36834
36835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
36836         LDKErrorMessage msg_conv;
36837         msg_conv.inner = (void*)(msg & (~1));
36838         msg_conv.is_owned = (msg & 1) || (msg == 0);
36839         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36840         msg_conv = ErrorMessage_clone(&msg_conv);
36841         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36842         *ret_copy = ErrorAction_send_error_message(msg_conv);
36843         int64_t ret_ref = (uintptr_t)ret_copy;
36844         return ret_ref;
36845 }
36846
36847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
36848         LDKWarningMessage msg_conv;
36849         msg_conv.inner = (void*)(msg & (~1));
36850         msg_conv.is_owned = (msg & 1) || (msg == 0);
36851         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36852         msg_conv = WarningMessage_clone(&msg_conv);
36853         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
36854         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36855         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
36856         int64_t ret_ref = (uintptr_t)ret_copy;
36857         return ret_ref;
36858 }
36859
36860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36861         LDKLightningError this_obj_conv;
36862         this_obj_conv.inner = (void*)(this_obj & (~1));
36863         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36865         LightningError_free(this_obj_conv);
36866 }
36867
36868 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
36869         LDKLightningError 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         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
36874         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
36875         Str_free(ret_str);
36876         return ret_conv;
36877 }
36878
36879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
36880         LDKLightningError 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         LDKStr val_conv = java_to_owned_str(env, val);
36885         LightningError_set_err(&this_ptr_conv, val_conv);
36886 }
36887
36888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
36889         LDKLightningError this_ptr_conv;
36890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36891         this_ptr_conv.is_owned = false;
36892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36893         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36894         *ret_copy = LightningError_get_action(&this_ptr_conv);
36895         int64_t ret_ref = (uintptr_t)ret_copy;
36896         return ret_ref;
36897 }
36898
36899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36900         LDKLightningError this_ptr_conv;
36901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36902         this_ptr_conv.is_owned = false;
36903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36904         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36905         CHECK_ACCESS(val_ptr);
36906         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
36907         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
36908         LightningError_set_action(&this_ptr_conv, val_conv);
36909 }
36910
36911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
36912         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
36913         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
36914         CHECK_ACCESS(action_arg_ptr);
36915         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
36916         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
36917         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
36918         int64_t ret_ref = 0;
36919         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36920         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36922         ret_ref = (uintptr_t)ret_var.inner;
36923         if (ret_var.is_owned) {
36924                 ret_ref |= 1;
36925         }
36926         return ret_ref;
36927 }
36928
36929 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
36930         LDKLightningError ret_var = LightningError_clone(arg);
36931 int64_t ret_ref = 0;
36932 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36933 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36934 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36935 ret_ref = (uintptr_t)ret_var.inner;
36936 if (ret_var.is_owned) {
36937         ret_ref |= 1;
36938 }
36939         return ret_ref;
36940 }
36941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36942         LDKLightningError arg_conv;
36943         arg_conv.inner = (void*)(arg & (~1));
36944         arg_conv.is_owned = false;
36945         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36946         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
36947         return ret_conv;
36948 }
36949
36950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36951         LDKLightningError orig_conv;
36952         orig_conv.inner = (void*)(orig & (~1));
36953         orig_conv.is_owned = false;
36954         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36955         LDKLightningError ret_var = LightningError_clone(&orig_conv);
36956         int64_t ret_ref = 0;
36957         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36958         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36960         ret_ref = (uintptr_t)ret_var.inner;
36961         if (ret_var.is_owned) {
36962                 ret_ref |= 1;
36963         }
36964         return ret_ref;
36965 }
36966
36967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36968         LDKCommitmentUpdate this_obj_conv;
36969         this_obj_conv.inner = (void*)(this_obj & (~1));
36970         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36972         CommitmentUpdate_free(this_obj_conv);
36973 }
36974
36975 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
36976         LDKCommitmentUpdate this_ptr_conv;
36977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36978         this_ptr_conv.is_owned = false;
36979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36980         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
36981         int64_tArray ret_arr = NULL;
36982         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36983         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36984         for (size_t p = 0; p < ret_var.datalen; p++) {
36985                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
36986                 int64_t ret_conv_15_ref = 0;
36987                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36988                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36989                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
36990                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
36991                 if (ret_conv_15_var.is_owned) {
36992                         ret_conv_15_ref |= 1;
36993                 }
36994                 ret_arr_ptr[p] = ret_conv_15_ref;
36995         }
36996         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36997         FREE(ret_var.data);
36998         return ret_arr;
36999 }
37000
37001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37002         LDKCommitmentUpdate this_ptr_conv;
37003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37004         this_ptr_conv.is_owned = false;
37005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37006         LDKCVec_UpdateAddHTLCZ val_constr;
37007         val_constr.datalen = (*env)->GetArrayLength(env, val);
37008         if (val_constr.datalen > 0)
37009                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
37010         else
37011                 val_constr.data = NULL;
37012         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37013         for (size_t p = 0; p < val_constr.datalen; p++) {
37014                 int64_t val_conv_15 = val_vals[p];
37015                 LDKUpdateAddHTLC val_conv_15_conv;
37016                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
37017                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
37018                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
37019                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
37020                 val_constr.data[p] = val_conv_15_conv;
37021         }
37022         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37023         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
37024 }
37025
37026 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37027         LDKCommitmentUpdate this_ptr_conv;
37028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37029         this_ptr_conv.is_owned = false;
37030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37031         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
37032         int64_tArray ret_arr = NULL;
37033         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37034         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37035         for (size_t t = 0; t < ret_var.datalen; t++) {
37036                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
37037                 int64_t ret_conv_19_ref = 0;
37038                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37039                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37040                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
37041                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
37042                 if (ret_conv_19_var.is_owned) {
37043                         ret_conv_19_ref |= 1;
37044                 }
37045                 ret_arr_ptr[t] = ret_conv_19_ref;
37046         }
37047         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37048         FREE(ret_var.data);
37049         return ret_arr;
37050 }
37051
37052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37053         LDKCommitmentUpdate this_ptr_conv;
37054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37055         this_ptr_conv.is_owned = false;
37056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37057         LDKCVec_UpdateFulfillHTLCZ val_constr;
37058         val_constr.datalen = (*env)->GetArrayLength(env, val);
37059         if (val_constr.datalen > 0)
37060                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
37061         else
37062                 val_constr.data = NULL;
37063         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37064         for (size_t t = 0; t < val_constr.datalen; t++) {
37065                 int64_t val_conv_19 = val_vals[t];
37066                 LDKUpdateFulfillHTLC val_conv_19_conv;
37067                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
37068                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
37069                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
37070                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
37071                 val_constr.data[t] = val_conv_19_conv;
37072         }
37073         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37074         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
37075 }
37076
37077 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37078         LDKCommitmentUpdate this_ptr_conv;
37079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37080         this_ptr_conv.is_owned = false;
37081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37082         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
37083         int64_tArray ret_arr = NULL;
37084         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37085         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37086         for (size_t q = 0; q < ret_var.datalen; q++) {
37087                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
37088                 int64_t ret_conv_16_ref = 0;
37089                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37090                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37091                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
37092                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
37093                 if (ret_conv_16_var.is_owned) {
37094                         ret_conv_16_ref |= 1;
37095                 }
37096                 ret_arr_ptr[q] = ret_conv_16_ref;
37097         }
37098         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37099         FREE(ret_var.data);
37100         return ret_arr;
37101 }
37102
37103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37104         LDKCommitmentUpdate this_ptr_conv;
37105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37106         this_ptr_conv.is_owned = false;
37107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37108         LDKCVec_UpdateFailHTLCZ val_constr;
37109         val_constr.datalen = (*env)->GetArrayLength(env, val);
37110         if (val_constr.datalen > 0)
37111                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
37112         else
37113                 val_constr.data = NULL;
37114         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37115         for (size_t q = 0; q < val_constr.datalen; q++) {
37116                 int64_t val_conv_16 = val_vals[q];
37117                 LDKUpdateFailHTLC val_conv_16_conv;
37118                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
37119                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
37120                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
37121                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
37122                 val_constr.data[q] = val_conv_16_conv;
37123         }
37124         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37125         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
37126 }
37127
37128 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37129         LDKCommitmentUpdate this_ptr_conv;
37130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37131         this_ptr_conv.is_owned = false;
37132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37133         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
37134         int64_tArray ret_arr = NULL;
37135         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37136         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37137         for (size_t z = 0; z < ret_var.datalen; z++) {
37138                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
37139                 int64_t ret_conv_25_ref = 0;
37140                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37141                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37142                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
37143                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
37144                 if (ret_conv_25_var.is_owned) {
37145                         ret_conv_25_ref |= 1;
37146                 }
37147                 ret_arr_ptr[z] = ret_conv_25_ref;
37148         }
37149         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37150         FREE(ret_var.data);
37151         return ret_arr;
37152 }
37153
37154 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) {
37155         LDKCommitmentUpdate this_ptr_conv;
37156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37157         this_ptr_conv.is_owned = false;
37158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37159         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
37160         val_constr.datalen = (*env)->GetArrayLength(env, val);
37161         if (val_constr.datalen > 0)
37162                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
37163         else
37164                 val_constr.data = NULL;
37165         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37166         for (size_t z = 0; z < val_constr.datalen; z++) {
37167                 int64_t val_conv_25 = val_vals[z];
37168                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
37169                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
37170                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
37171                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
37172                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
37173                 val_constr.data[z] = val_conv_25_conv;
37174         }
37175         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37176         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
37177 }
37178
37179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
37180         LDKCommitmentUpdate this_ptr_conv;
37181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37182         this_ptr_conv.is_owned = false;
37183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37184         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
37185         int64_t ret_ref = 0;
37186         if ((uintptr_t)ret_var.inner > 4096) {
37187                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37188                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37190                 ret_ref = (uintptr_t)ret_var.inner;
37191                 if (ret_var.is_owned) {
37192                         ret_ref |= 1;
37193                 }
37194         }
37195         return ret_ref;
37196 }
37197
37198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37199         LDKCommitmentUpdate this_ptr_conv;
37200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37201         this_ptr_conv.is_owned = false;
37202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37203         LDKUpdateFee val_conv;
37204         val_conv.inner = (void*)(val & (~1));
37205         val_conv.is_owned = (val & 1) || (val == 0);
37206         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37207         val_conv = UpdateFee_clone(&val_conv);
37208         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
37209 }
37210
37211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
37212         LDKCommitmentUpdate this_ptr_conv;
37213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37214         this_ptr_conv.is_owned = false;
37215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37216         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
37217         int64_t ret_ref = 0;
37218         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37219         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37221         ret_ref = (uintptr_t)ret_var.inner;
37222         if (ret_var.is_owned) {
37223                 ret_ref |= 1;
37224         }
37225         return ret_ref;
37226 }
37227
37228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37229         LDKCommitmentUpdate this_ptr_conv;
37230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37231         this_ptr_conv.is_owned = false;
37232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37233         LDKCommitmentSigned val_conv;
37234         val_conv.inner = (void*)(val & (~1));
37235         val_conv.is_owned = (val & 1) || (val == 0);
37236         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37237         val_conv = CommitmentSigned_clone(&val_conv);
37238         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
37239 }
37240
37241 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) {
37242         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
37243         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
37244         if (update_add_htlcs_arg_constr.datalen > 0)
37245                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
37246         else
37247                 update_add_htlcs_arg_constr.data = NULL;
37248         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
37249         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
37250                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
37251                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
37252                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
37253                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
37254                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
37255                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
37256                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
37257         }
37258         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
37259         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
37260         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
37261         if (update_fulfill_htlcs_arg_constr.datalen > 0)
37262                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
37263         else
37264                 update_fulfill_htlcs_arg_constr.data = NULL;
37265         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
37266         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
37267                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
37268                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
37269                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
37270                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
37271                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
37272                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
37273                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
37274         }
37275         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
37276         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
37277         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
37278         if (update_fail_htlcs_arg_constr.datalen > 0)
37279                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
37280         else
37281                 update_fail_htlcs_arg_constr.data = NULL;
37282         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
37283         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
37284                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
37285                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
37286                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
37287                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
37288                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
37289                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
37290                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
37291         }
37292         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
37293         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
37294         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
37295         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
37296                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
37297         else
37298                 update_fail_malformed_htlcs_arg_constr.data = NULL;
37299         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
37300         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
37301                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
37302                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
37303                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
37304                 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);
37305                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
37306                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
37307                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
37308         }
37309         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
37310         LDKUpdateFee update_fee_arg_conv;
37311         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
37312         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
37313         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
37314         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
37315         LDKCommitmentSigned commitment_signed_arg_conv;
37316         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
37317         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
37318         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
37319         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
37320         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);
37321         int64_t ret_ref = 0;
37322         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37323         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37324         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37325         ret_ref = (uintptr_t)ret_var.inner;
37326         if (ret_var.is_owned) {
37327                 ret_ref |= 1;
37328         }
37329         return ret_ref;
37330 }
37331
37332 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
37333         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
37334 int64_t ret_ref = 0;
37335 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37336 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37337 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37338 ret_ref = (uintptr_t)ret_var.inner;
37339 if (ret_var.is_owned) {
37340         ret_ref |= 1;
37341 }
37342         return ret_ref;
37343 }
37344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37345         LDKCommitmentUpdate arg_conv;
37346         arg_conv.inner = (void*)(arg & (~1));
37347         arg_conv.is_owned = false;
37348         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37349         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
37350         return ret_conv;
37351 }
37352
37353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37354         LDKCommitmentUpdate orig_conv;
37355         orig_conv.inner = (void*)(orig & (~1));
37356         orig_conv.is_owned = false;
37357         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37358         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
37359         int64_t ret_ref = 0;
37360         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37361         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37363         ret_ref = (uintptr_t)ret_var.inner;
37364         if (ret_var.is_owned) {
37365                 ret_ref |= 1;
37366         }
37367         return ret_ref;
37368 }
37369
37370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37371         if ((this_ptr & 1) != 0) return;
37372         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37373         CHECK_ACCESS(this_ptr_ptr);
37374         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
37375         FREE((void*)this_ptr);
37376         ChannelMessageHandler_free(this_ptr_conv);
37377 }
37378
37379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37380         if ((this_ptr & 1) != 0) return;
37381         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37382         CHECK_ACCESS(this_ptr_ptr);
37383         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
37384         FREE((void*)this_ptr);
37385         RoutingMessageHandler_free(this_ptr_conv);
37386 }
37387
37388 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
37389         LDKAcceptChannel obj_conv;
37390         obj_conv.inner = (void*)(obj & (~1));
37391         obj_conv.is_owned = false;
37392         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37393         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
37394         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37395         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37396         CVec_u8Z_free(ret_var);
37397         return ret_arr;
37398 }
37399
37400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37401         LDKu8slice ser_ref;
37402         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37403         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37404         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
37405         *ret_conv = AcceptChannel_read(ser_ref);
37406         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37407         return (int64_t)ret_conv;
37408 }
37409
37410 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
37411         LDKAnnouncementSignatures obj_conv;
37412         obj_conv.inner = (void*)(obj & (~1));
37413         obj_conv.is_owned = false;
37414         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37415         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
37416         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37417         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37418         CVec_u8Z_free(ret_var);
37419         return ret_arr;
37420 }
37421
37422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37423         LDKu8slice ser_ref;
37424         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37425         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37426         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
37427         *ret_conv = AnnouncementSignatures_read(ser_ref);
37428         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37429         return (int64_t)ret_conv;
37430 }
37431
37432 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
37433         LDKChannelReestablish obj_conv;
37434         obj_conv.inner = (void*)(obj & (~1));
37435         obj_conv.is_owned = false;
37436         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37437         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
37438         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37439         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37440         CVec_u8Z_free(ret_var);
37441         return ret_arr;
37442 }
37443
37444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37445         LDKu8slice ser_ref;
37446         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37447         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37448         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
37449         *ret_conv = ChannelReestablish_read(ser_ref);
37450         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37451         return (int64_t)ret_conv;
37452 }
37453
37454 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
37455         LDKClosingSigned obj_conv;
37456         obj_conv.inner = (void*)(obj & (~1));
37457         obj_conv.is_owned = false;
37458         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37459         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
37460         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37461         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37462         CVec_u8Z_free(ret_var);
37463         return ret_arr;
37464 }
37465
37466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37467         LDKu8slice ser_ref;
37468         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37469         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37470         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
37471         *ret_conv = ClosingSigned_read(ser_ref);
37472         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37473         return (int64_t)ret_conv;
37474 }
37475
37476 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
37477         LDKClosingSignedFeeRange obj_conv;
37478         obj_conv.inner = (void*)(obj & (~1));
37479         obj_conv.is_owned = false;
37480         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37481         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
37482         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37483         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37484         CVec_u8Z_free(ret_var);
37485         return ret_arr;
37486 }
37487
37488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37489         LDKu8slice ser_ref;
37490         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37491         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37492         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
37493         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
37494         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37495         return (int64_t)ret_conv;
37496 }
37497
37498 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
37499         LDKCommitmentSigned obj_conv;
37500         obj_conv.inner = (void*)(obj & (~1));
37501         obj_conv.is_owned = false;
37502         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37503         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
37504         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37505         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37506         CVec_u8Z_free(ret_var);
37507         return ret_arr;
37508 }
37509
37510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37511         LDKu8slice ser_ref;
37512         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37513         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37514         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
37515         *ret_conv = CommitmentSigned_read(ser_ref);
37516         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37517         return (int64_t)ret_conv;
37518 }
37519
37520 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
37521         LDKFundingCreated obj_conv;
37522         obj_conv.inner = (void*)(obj & (~1));
37523         obj_conv.is_owned = false;
37524         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37525         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
37526         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37527         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37528         CVec_u8Z_free(ret_var);
37529         return ret_arr;
37530 }
37531
37532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37533         LDKu8slice ser_ref;
37534         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37535         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37536         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
37537         *ret_conv = FundingCreated_read(ser_ref);
37538         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37539         return (int64_t)ret_conv;
37540 }
37541
37542 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
37543         LDKFundingSigned obj_conv;
37544         obj_conv.inner = (void*)(obj & (~1));
37545         obj_conv.is_owned = false;
37546         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37547         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
37548         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37549         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37550         CVec_u8Z_free(ret_var);
37551         return ret_arr;
37552 }
37553
37554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37555         LDKu8slice ser_ref;
37556         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37557         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37558         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
37559         *ret_conv = FundingSigned_read(ser_ref);
37560         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37561         return (int64_t)ret_conv;
37562 }
37563
37564 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
37565         LDKChannelReady obj_conv;
37566         obj_conv.inner = (void*)(obj & (~1));
37567         obj_conv.is_owned = false;
37568         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37569         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
37570         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37571         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37572         CVec_u8Z_free(ret_var);
37573         return ret_arr;
37574 }
37575
37576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37577         LDKu8slice ser_ref;
37578         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37579         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37580         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
37581         *ret_conv = ChannelReady_read(ser_ref);
37582         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37583         return (int64_t)ret_conv;
37584 }
37585
37586 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
37587         LDKInit obj_conv;
37588         obj_conv.inner = (void*)(obj & (~1));
37589         obj_conv.is_owned = false;
37590         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37591         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
37592         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37593         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37594         CVec_u8Z_free(ret_var);
37595         return ret_arr;
37596 }
37597
37598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37599         LDKu8slice ser_ref;
37600         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37601         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37602         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
37603         *ret_conv = Init_read(ser_ref);
37604         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37605         return (int64_t)ret_conv;
37606 }
37607
37608 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
37609         LDKOpenChannel obj_conv;
37610         obj_conv.inner = (void*)(obj & (~1));
37611         obj_conv.is_owned = false;
37612         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37613         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
37614         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37615         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37616         CVec_u8Z_free(ret_var);
37617         return ret_arr;
37618 }
37619
37620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37621         LDKu8slice ser_ref;
37622         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37623         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37624         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
37625         *ret_conv = OpenChannel_read(ser_ref);
37626         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37627         return (int64_t)ret_conv;
37628 }
37629
37630 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
37631         LDKRevokeAndACK obj_conv;
37632         obj_conv.inner = (void*)(obj & (~1));
37633         obj_conv.is_owned = false;
37634         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37635         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
37636         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37637         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37638         CVec_u8Z_free(ret_var);
37639         return ret_arr;
37640 }
37641
37642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37643         LDKu8slice ser_ref;
37644         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37645         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37646         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
37647         *ret_conv = RevokeAndACK_read(ser_ref);
37648         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37649         return (int64_t)ret_conv;
37650 }
37651
37652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
37653         LDKShutdown obj_conv;
37654         obj_conv.inner = (void*)(obj & (~1));
37655         obj_conv.is_owned = false;
37656         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37657         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
37658         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37659         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37660         CVec_u8Z_free(ret_var);
37661         return ret_arr;
37662 }
37663
37664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37665         LDKu8slice ser_ref;
37666         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37667         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37668         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
37669         *ret_conv = Shutdown_read(ser_ref);
37670         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37671         return (int64_t)ret_conv;
37672 }
37673
37674 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37675         LDKUpdateFailHTLC obj_conv;
37676         obj_conv.inner = (void*)(obj & (~1));
37677         obj_conv.is_owned = false;
37678         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37679         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
37680         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37681         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37682         CVec_u8Z_free(ret_var);
37683         return ret_arr;
37684 }
37685
37686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37687         LDKu8slice ser_ref;
37688         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37689         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37690         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
37691         *ret_conv = UpdateFailHTLC_read(ser_ref);
37692         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37693         return (int64_t)ret_conv;
37694 }
37695
37696 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37697         LDKUpdateFailMalformedHTLC obj_conv;
37698         obj_conv.inner = (void*)(obj & (~1));
37699         obj_conv.is_owned = false;
37700         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37701         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
37702         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37703         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37704         CVec_u8Z_free(ret_var);
37705         return ret_arr;
37706 }
37707
37708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37709         LDKu8slice ser_ref;
37710         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37711         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37712         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
37713         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
37714         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37715         return (int64_t)ret_conv;
37716 }
37717
37718 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
37719         LDKUpdateFee obj_conv;
37720         obj_conv.inner = (void*)(obj & (~1));
37721         obj_conv.is_owned = false;
37722         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37723         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
37724         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37725         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37726         CVec_u8Z_free(ret_var);
37727         return ret_arr;
37728 }
37729
37730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37731         LDKu8slice ser_ref;
37732         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37733         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37734         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
37735         *ret_conv = UpdateFee_read(ser_ref);
37736         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37737         return (int64_t)ret_conv;
37738 }
37739
37740 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37741         LDKUpdateFulfillHTLC obj_conv;
37742         obj_conv.inner = (void*)(obj & (~1));
37743         obj_conv.is_owned = false;
37744         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37745         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
37746         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37747         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37748         CVec_u8Z_free(ret_var);
37749         return ret_arr;
37750 }
37751
37752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37753         LDKu8slice ser_ref;
37754         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37755         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37756         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
37757         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
37758         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37759         return (int64_t)ret_conv;
37760 }
37761
37762 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37763         LDKUpdateAddHTLC obj_conv;
37764         obj_conv.inner = (void*)(obj & (~1));
37765         obj_conv.is_owned = false;
37766         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37767         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
37768         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37769         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37770         CVec_u8Z_free(ret_var);
37771         return ret_arr;
37772 }
37773
37774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37775         LDKu8slice ser_ref;
37776         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37777         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37778         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
37779         *ret_conv = UpdateAddHTLC_read(ser_ref);
37780         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37781         return (int64_t)ret_conv;
37782 }
37783
37784 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
37785         LDKPing obj_conv;
37786         obj_conv.inner = (void*)(obj & (~1));
37787         obj_conv.is_owned = false;
37788         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37789         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
37790         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37791         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37792         CVec_u8Z_free(ret_var);
37793         return ret_arr;
37794 }
37795
37796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37797         LDKu8slice ser_ref;
37798         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37799         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37800         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
37801         *ret_conv = Ping_read(ser_ref);
37802         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37803         return (int64_t)ret_conv;
37804 }
37805
37806 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
37807         LDKPong obj_conv;
37808         obj_conv.inner = (void*)(obj & (~1));
37809         obj_conv.is_owned = false;
37810         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37811         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
37812         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37813         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37814         CVec_u8Z_free(ret_var);
37815         return ret_arr;
37816 }
37817
37818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37819         LDKu8slice ser_ref;
37820         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37821         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37822         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
37823         *ret_conv = Pong_read(ser_ref);
37824         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37825         return (int64_t)ret_conv;
37826 }
37827
37828 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37829         LDKUnsignedChannelAnnouncement obj_conv;
37830         obj_conv.inner = (void*)(obj & (~1));
37831         obj_conv.is_owned = false;
37832         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37833         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
37834         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37835         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37836         CVec_u8Z_free(ret_var);
37837         return ret_arr;
37838 }
37839
37840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37841         LDKu8slice ser_ref;
37842         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37843         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37844         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
37845         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
37846         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37847         return (int64_t)ret_conv;
37848 }
37849
37850 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37851         LDKChannelAnnouncement obj_conv;
37852         obj_conv.inner = (void*)(obj & (~1));
37853         obj_conv.is_owned = false;
37854         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37855         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
37856         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37857         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37858         CVec_u8Z_free(ret_var);
37859         return ret_arr;
37860 }
37861
37862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37863         LDKu8slice ser_ref;
37864         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37865         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37866         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
37867         *ret_conv = ChannelAnnouncement_read(ser_ref);
37868         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37869         return (int64_t)ret_conv;
37870 }
37871
37872 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
37873         LDKUnsignedChannelUpdate obj_conv;
37874         obj_conv.inner = (void*)(obj & (~1));
37875         obj_conv.is_owned = false;
37876         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37877         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
37878         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37879         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37880         CVec_u8Z_free(ret_var);
37881         return ret_arr;
37882 }
37883
37884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37885         LDKu8slice ser_ref;
37886         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37887         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37888         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
37889         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
37890         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37891         return (int64_t)ret_conv;
37892 }
37893
37894 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
37895         LDKChannelUpdate obj_conv;
37896         obj_conv.inner = (void*)(obj & (~1));
37897         obj_conv.is_owned = false;
37898         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37899         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
37900         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37901         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37902         CVec_u8Z_free(ret_var);
37903         return ret_arr;
37904 }
37905
37906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37907         LDKu8slice ser_ref;
37908         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37909         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37910         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
37911         *ret_conv = ChannelUpdate_read(ser_ref);
37912         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37913         return (int64_t)ret_conv;
37914 }
37915
37916 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
37917         LDKErrorMessage obj_conv;
37918         obj_conv.inner = (void*)(obj & (~1));
37919         obj_conv.is_owned = false;
37920         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37921         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
37922         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37923         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37924         CVec_u8Z_free(ret_var);
37925         return ret_arr;
37926 }
37927
37928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37929         LDKu8slice ser_ref;
37930         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37931         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37932         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
37933         *ret_conv = ErrorMessage_read(ser_ref);
37934         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37935         return (int64_t)ret_conv;
37936 }
37937
37938 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
37939         LDKWarningMessage obj_conv;
37940         obj_conv.inner = (void*)(obj & (~1));
37941         obj_conv.is_owned = false;
37942         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37943         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
37944         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37945         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37946         CVec_u8Z_free(ret_var);
37947         return ret_arr;
37948 }
37949
37950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37951         LDKu8slice ser_ref;
37952         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37953         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37954         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
37955         *ret_conv = WarningMessage_read(ser_ref);
37956         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37957         return (int64_t)ret_conv;
37958 }
37959
37960 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37961         LDKUnsignedNodeAnnouncement obj_conv;
37962         obj_conv.inner = (void*)(obj & (~1));
37963         obj_conv.is_owned = false;
37964         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37965         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
37966         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37967         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37968         CVec_u8Z_free(ret_var);
37969         return ret_arr;
37970 }
37971
37972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37973         LDKu8slice ser_ref;
37974         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37975         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37976         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
37977         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
37978         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37979         return (int64_t)ret_conv;
37980 }
37981
37982 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37983         LDKNodeAnnouncement obj_conv;
37984         obj_conv.inner = (void*)(obj & (~1));
37985         obj_conv.is_owned = false;
37986         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37987         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
37988         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37989         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37990         CVec_u8Z_free(ret_var);
37991         return ret_arr;
37992 }
37993
37994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37995         LDKu8slice ser_ref;
37996         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37997         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37998         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
37999         *ret_conv = NodeAnnouncement_read(ser_ref);
38000         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38001         return (int64_t)ret_conv;
38002 }
38003
38004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38005         LDKu8slice ser_ref;
38006         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38007         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38008         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
38009         *ret_conv = QueryShortChannelIds_read(ser_ref);
38010         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38011         return (int64_t)ret_conv;
38012 }
38013
38014 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
38015         LDKQueryShortChannelIds obj_conv;
38016         obj_conv.inner = (void*)(obj & (~1));
38017         obj_conv.is_owned = false;
38018         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38019         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
38020         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38021         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38022         CVec_u8Z_free(ret_var);
38023         return ret_arr;
38024 }
38025
38026 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
38027         LDKReplyShortChannelIdsEnd obj_conv;
38028         obj_conv.inner = (void*)(obj & (~1));
38029         obj_conv.is_owned = false;
38030         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38031         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
38032         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38033         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38034         CVec_u8Z_free(ret_var);
38035         return ret_arr;
38036 }
38037
38038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38039         LDKu8slice ser_ref;
38040         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38041         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38042         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
38043         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
38044         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38045         return (int64_t)ret_conv;
38046 }
38047
38048 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
38049         LDKQueryChannelRange this_arg_conv;
38050         this_arg_conv.inner = (void*)(this_arg & (~1));
38051         this_arg_conv.is_owned = false;
38052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38053         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
38054         return ret_conv;
38055 }
38056
38057 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
38058         LDKQueryChannelRange obj_conv;
38059         obj_conv.inner = (void*)(obj & (~1));
38060         obj_conv.is_owned = false;
38061         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38062         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
38063         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38064         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38065         CVec_u8Z_free(ret_var);
38066         return ret_arr;
38067 }
38068
38069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38070         LDKu8slice ser_ref;
38071         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38072         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38073         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
38074         *ret_conv = QueryChannelRange_read(ser_ref);
38075         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38076         return (int64_t)ret_conv;
38077 }
38078
38079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38080         LDKu8slice ser_ref;
38081         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38082         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38083         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
38084         *ret_conv = ReplyChannelRange_read(ser_ref);
38085         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38086         return (int64_t)ret_conv;
38087 }
38088
38089 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
38090         LDKReplyChannelRange obj_conv;
38091         obj_conv.inner = (void*)(obj & (~1));
38092         obj_conv.is_owned = false;
38093         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38094         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
38095         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38096         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38097         CVec_u8Z_free(ret_var);
38098         return ret_arr;
38099 }
38100
38101 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
38102         LDKGossipTimestampFilter obj_conv;
38103         obj_conv.inner = (void*)(obj & (~1));
38104         obj_conv.is_owned = false;
38105         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38106         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
38107         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38108         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38109         CVec_u8Z_free(ret_var);
38110         return ret_arr;
38111 }
38112
38113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38114         LDKu8slice ser_ref;
38115         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38116         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38117         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
38118         *ret_conv = GossipTimestampFilter_read(ser_ref);
38119         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38120         return (int64_t)ret_conv;
38121 }
38122
38123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38124         if ((this_ptr & 1) != 0) return;
38125         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38126         CHECK_ACCESS(this_ptr_ptr);
38127         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
38128         FREE((void*)this_ptr);
38129         CustomMessageHandler_free(this_ptr_conv);
38130 }
38131
38132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38133         LDKIgnoringMessageHandler this_obj_conv;
38134         this_obj_conv.inner = (void*)(this_obj & (~1));
38135         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38137         IgnoringMessageHandler_free(this_obj_conv);
38138 }
38139
38140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
38141         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
38142         int64_t ret_ref = 0;
38143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38146         ret_ref = (uintptr_t)ret_var.inner;
38147         if (ret_var.is_owned) {
38148                 ret_ref |= 1;
38149         }
38150         return ret_ref;
38151 }
38152
38153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
38154         LDKIgnoringMessageHandler this_arg_conv;
38155         this_arg_conv.inner = (void*)(this_arg & (~1));
38156         this_arg_conv.is_owned = false;
38157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38158         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
38159         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
38160         return (int64_t)ret_ret;
38161 }
38162
38163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
38164         LDKIgnoringMessageHandler this_arg_conv;
38165         this_arg_conv.inner = (void*)(this_arg & (~1));
38166         this_arg_conv.is_owned = false;
38167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38168         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
38169         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
38170         return (int64_t)ret_ret;
38171 }
38172
38173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
38174         LDKIgnoringMessageHandler this_arg_conv;
38175         this_arg_conv.inner = (void*)(this_arg & (~1));
38176         this_arg_conv.is_owned = false;
38177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38178         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
38179         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
38180         return (int64_t)ret_ret;
38181 }
38182
38183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
38184         LDKIgnoringMessageHandler this_arg_conv;
38185         this_arg_conv.inner = (void*)(this_arg & (~1));
38186         this_arg_conv.is_owned = false;
38187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38188         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
38189         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
38190         return (int64_t)ret_ret;
38191 }
38192
38193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38194         LDKErroringMessageHandler this_obj_conv;
38195         this_obj_conv.inner = (void*)(this_obj & (~1));
38196         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38198         ErroringMessageHandler_free(this_obj_conv);
38199 }
38200
38201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
38202         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
38203         int64_t ret_ref = 0;
38204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38207         ret_ref = (uintptr_t)ret_var.inner;
38208         if (ret_var.is_owned) {
38209                 ret_ref |= 1;
38210         }
38211         return ret_ref;
38212 }
38213
38214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
38215         LDKErroringMessageHandler this_arg_conv;
38216         this_arg_conv.inner = (void*)(this_arg & (~1));
38217         this_arg_conv.is_owned = false;
38218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38219         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
38220         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
38221         return (int64_t)ret_ret;
38222 }
38223
38224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
38225         LDKErroringMessageHandler this_arg_conv;
38226         this_arg_conv.inner = (void*)(this_arg & (~1));
38227         this_arg_conv.is_owned = false;
38228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38229         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
38230         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
38231         return (int64_t)ret_ret;
38232 }
38233
38234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38235         LDKMessageHandler this_obj_conv;
38236         this_obj_conv.inner = (void*)(this_obj & (~1));
38237         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38239         MessageHandler_free(this_obj_conv);
38240 }
38241
38242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
38243         LDKMessageHandler this_ptr_conv;
38244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38245         this_ptr_conv.is_owned = false;
38246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38247         // WARNING: This object doesn't live past this scope, needs clone!
38248         int64_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
38249         return ret_ret;
38250 }
38251
38252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38253         LDKMessageHandler this_ptr_conv;
38254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38255         this_ptr_conv.is_owned = false;
38256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38257         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38258         CHECK_ACCESS(val_ptr);
38259         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
38260         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
38261                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38262                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
38263         }
38264         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
38265 }
38266
38267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
38268         LDKMessageHandler this_ptr_conv;
38269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38270         this_ptr_conv.is_owned = false;
38271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38272         // WARNING: This object doesn't live past this scope, needs clone!
38273         int64_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
38274         return ret_ret;
38275 }
38276
38277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38278         LDKMessageHandler this_ptr_conv;
38279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38280         this_ptr_conv.is_owned = false;
38281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38282         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38283         CHECK_ACCESS(val_ptr);
38284         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
38285         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
38286                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38287                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
38288         }
38289         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
38290 }
38291
38292 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) {
38293         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
38294         CHECK_ACCESS(chan_handler_arg_ptr);
38295         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
38296         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
38297                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38298                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
38299         }
38300         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
38301         CHECK_ACCESS(route_handler_arg_ptr);
38302         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
38303         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
38304                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38305                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
38306         }
38307         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
38308         int64_t ret_ref = 0;
38309         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38310         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38312         ret_ref = (uintptr_t)ret_var.inner;
38313         if (ret_var.is_owned) {
38314                 ret_ref |= 1;
38315         }
38316         return ret_ref;
38317 }
38318
38319 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
38320         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
38321         *ret_ret = SocketDescriptor_clone(arg);
38322         return (int64_t)ret_ret;
38323 }
38324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38325         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
38326         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
38327         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
38328         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
38329         return ret_conv;
38330 }
38331
38332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38333         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
38334         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
38335         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
38336         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
38337         *ret_ret = SocketDescriptor_clone(orig_conv);
38338         return (int64_t)ret_ret;
38339 }
38340
38341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38342         if ((this_ptr & 1) != 0) return;
38343         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38344         CHECK_ACCESS(this_ptr_ptr);
38345         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
38346         FREE((void*)this_ptr);
38347         SocketDescriptor_free(this_ptr_conv);
38348 }
38349
38350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38351         LDKPeerHandleError this_obj_conv;
38352         this_obj_conv.inner = (void*)(this_obj & (~1));
38353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38355         PeerHandleError_free(this_obj_conv);
38356 }
38357
38358 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
38359         LDKPeerHandleError this_ptr_conv;
38360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38361         this_ptr_conv.is_owned = false;
38362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38363         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
38364         return ret_conv;
38365 }
38366
38367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
38368         LDKPeerHandleError this_ptr_conv;
38369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38370         this_ptr_conv.is_owned = false;
38371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38372         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
38373 }
38374
38375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
38376         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
38377         int64_t ret_ref = 0;
38378         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38379         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38381         ret_ref = (uintptr_t)ret_var.inner;
38382         if (ret_var.is_owned) {
38383                 ret_ref |= 1;
38384         }
38385         return ret_ref;
38386 }
38387
38388 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
38389         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
38390 int64_t ret_ref = 0;
38391 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38392 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38393 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38394 ret_ref = (uintptr_t)ret_var.inner;
38395 if (ret_var.is_owned) {
38396         ret_ref |= 1;
38397 }
38398         return ret_ref;
38399 }
38400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38401         LDKPeerHandleError arg_conv;
38402         arg_conv.inner = (void*)(arg & (~1));
38403         arg_conv.is_owned = false;
38404         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38405         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
38406         return ret_conv;
38407 }
38408
38409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38410         LDKPeerHandleError orig_conv;
38411         orig_conv.inner = (void*)(orig & (~1));
38412         orig_conv.is_owned = false;
38413         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38414         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
38415         int64_t ret_ref = 0;
38416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38419         ret_ref = (uintptr_t)ret_var.inner;
38420         if (ret_var.is_owned) {
38421                 ret_ref |= 1;
38422         }
38423         return ret_ref;
38424 }
38425
38426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38427         LDKPeerManager this_obj_conv;
38428         this_obj_conv.inner = (void*)(this_obj & (~1));
38429         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38431         PeerManager_free(this_obj_conv);
38432 }
38433
38434 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) {
38435         LDKMessageHandler message_handler_conv;
38436         message_handler_conv.inner = (void*)(message_handler & (~1));
38437         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
38438         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
38439         // WARNING: we need a move here but no clone is available for LDKMessageHandler
38440         LDKSecretKey our_node_secret_ref;
38441         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
38442         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
38443         unsigned char ephemeral_random_data_arr[32];
38444         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
38445         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
38446         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
38447         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
38448         CHECK_ACCESS(logger_ptr);
38449         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
38450         if (logger_conv.free == LDKLogger_JCalls_free) {
38451                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38452                 LDKLogger_JCalls_cloned(&logger_conv);
38453         }
38454         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
38455         CHECK_ACCESS(custom_message_handler_ptr);
38456         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
38457         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
38458                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38459                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
38460         }
38461         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
38462         int64_t ret_ref = 0;
38463         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38464         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38466         ret_ref = (uintptr_t)ret_var.inner;
38467         if (ret_var.is_owned) {
38468                 ret_ref |= 1;
38469         }
38470         return ret_ref;
38471 }
38472
38473 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
38474         LDKPeerManager this_arg_conv;
38475         this_arg_conv.inner = (void*)(this_arg & (~1));
38476         this_arg_conv.is_owned = false;
38477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38478         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
38479         jobjectArray ret_arr = NULL;
38480         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
38481         ;
38482         for (size_t i = 0; i < ret_var.datalen; i++) {
38483                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
38484                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
38485                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
38486         }
38487         
38488         FREE(ret_var.data);
38489         return ret_arr;
38490 }
38491
38492 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) {
38493         LDKPeerManager this_arg_conv;
38494         this_arg_conv.inner = (void*)(this_arg & (~1));
38495         this_arg_conv.is_owned = false;
38496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38497         LDKPublicKey their_node_id_ref;
38498         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
38499         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
38500         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
38501         CHECK_ACCESS(descriptor_ptr);
38502         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
38503         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
38504                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38505                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
38506         }
38507         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
38508         CHECK_ACCESS(remote_network_address_ptr);
38509         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
38510         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
38511         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
38512         return (int64_t)ret_conv;
38513 }
38514
38515 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) {
38516         LDKPeerManager this_arg_conv;
38517         this_arg_conv.inner = (void*)(this_arg & (~1));
38518         this_arg_conv.is_owned = false;
38519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38520         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
38521         CHECK_ACCESS(descriptor_ptr);
38522         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
38523         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
38524                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38525                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
38526         }
38527         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
38528         CHECK_ACCESS(remote_network_address_ptr);
38529         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
38530         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
38531         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
38532         return (int64_t)ret_conv;
38533 }
38534
38535 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) {
38536         LDKPeerManager this_arg_conv;
38537         this_arg_conv.inner = (void*)(this_arg & (~1));
38538         this_arg_conv.is_owned = false;
38539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38540         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
38541         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
38542         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
38543         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
38544         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
38545         return (int64_t)ret_conv;
38546 }
38547
38548 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) {
38549         LDKPeerManager this_arg_conv;
38550         this_arg_conv.inner = (void*)(this_arg & (~1));
38551         this_arg_conv.is_owned = false;
38552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38553         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
38554         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
38555         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
38556         LDKu8slice data_ref;
38557         data_ref.datalen = (*env)->GetArrayLength(env, data);
38558         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
38559         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
38560         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
38561         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
38562         return (int64_t)ret_conv;
38563 }
38564
38565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
38566         LDKPeerManager this_arg_conv;
38567         this_arg_conv.inner = (void*)(this_arg & (~1));
38568         this_arg_conv.is_owned = false;
38569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38570         PeerManager_process_events(&this_arg_conv);
38571 }
38572
38573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
38574         LDKPeerManager this_arg_conv;
38575         this_arg_conv.inner = (void*)(this_arg & (~1));
38576         this_arg_conv.is_owned = false;
38577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38578         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
38579         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
38580         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
38581         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
38582 }
38583
38584 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) {
38585         LDKPeerManager this_arg_conv;
38586         this_arg_conv.inner = (void*)(this_arg & (~1));
38587         this_arg_conv.is_owned = false;
38588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38589         LDKPublicKey node_id_ref;
38590         CHECK((*env)->GetArrayLength(env, node_id) == 33);
38591         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
38592         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
38593 }
38594
38595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
38596         LDKPeerManager this_arg_conv;
38597         this_arg_conv.inner = (void*)(this_arg & (~1));
38598         this_arg_conv.is_owned = false;
38599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38600         PeerManager_disconnect_all_peers(&this_arg_conv);
38601 }
38602
38603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
38604         LDKPeerManager this_arg_conv;
38605         this_arg_conv.inner = (void*)(this_arg & (~1));
38606         this_arg_conv.is_owned = false;
38607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38608         PeerManager_timer_tick_occurred(&this_arg_conv);
38609 }
38610
38611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
38612         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
38613         return ret_conv;
38614 }
38615
38616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
38617         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
38618         return ret_conv;
38619 }
38620
38621 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
38622         unsigned char commitment_seed_arr[32];
38623         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
38624         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
38625         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
38626         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38627         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
38628         return ret_arr;
38629 }
38630
38631 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) {
38632         LDKCVec_u8Z to_holder_script_ref;
38633         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
38634         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
38635         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
38636         LDKCVec_u8Z to_counterparty_script_ref;
38637         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
38638         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
38639         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
38640         LDKOutPoint funding_outpoint_conv;
38641         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
38642         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
38643         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
38644         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
38645         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);
38646         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38647         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38648         Transaction_free(ret_var);
38649         return ret_arr;
38650 }
38651
38652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38653         LDKCounterpartyCommitmentSecrets this_obj_conv;
38654         this_obj_conv.inner = (void*)(this_obj & (~1));
38655         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38657         CounterpartyCommitmentSecrets_free(this_obj_conv);
38658 }
38659
38660 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
38661         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
38662 int64_t ret_ref = 0;
38663 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38664 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38665 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38666 ret_ref = (uintptr_t)ret_var.inner;
38667 if (ret_var.is_owned) {
38668         ret_ref |= 1;
38669 }
38670         return ret_ref;
38671 }
38672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38673         LDKCounterpartyCommitmentSecrets arg_conv;
38674         arg_conv.inner = (void*)(arg & (~1));
38675         arg_conv.is_owned = false;
38676         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38677         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
38678         return ret_conv;
38679 }
38680
38681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38682         LDKCounterpartyCommitmentSecrets orig_conv;
38683         orig_conv.inner = (void*)(orig & (~1));
38684         orig_conv.is_owned = false;
38685         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38686         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
38687         int64_t ret_ref = 0;
38688         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38689         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38691         ret_ref = (uintptr_t)ret_var.inner;
38692         if (ret_var.is_owned) {
38693                 ret_ref |= 1;
38694         }
38695         return ret_ref;
38696 }
38697
38698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
38699         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
38700         int64_t ret_ref = 0;
38701         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38702         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38704         ret_ref = (uintptr_t)ret_var.inner;
38705         if (ret_var.is_owned) {
38706                 ret_ref |= 1;
38707         }
38708         return ret_ref;
38709 }
38710
38711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
38712         LDKCounterpartyCommitmentSecrets this_arg_conv;
38713         this_arg_conv.inner = (void*)(this_arg & (~1));
38714         this_arg_conv.is_owned = false;
38715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38716         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
38717         return ret_conv;
38718 }
38719
38720 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) {
38721         LDKCounterpartyCommitmentSecrets this_arg_conv;
38722         this_arg_conv.inner = (void*)(this_arg & (~1));
38723         this_arg_conv.is_owned = false;
38724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38725         LDKThirtyTwoBytes secret_ref;
38726         CHECK((*env)->GetArrayLength(env, secret) == 32);
38727         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
38728         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
38729         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
38730         return (int64_t)ret_conv;
38731 }
38732
38733 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
38734         LDKCounterpartyCommitmentSecrets this_arg_conv;
38735         this_arg_conv.inner = (void*)(this_arg & (~1));
38736         this_arg_conv.is_owned = false;
38737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38738         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38739         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
38740         return ret_arr;
38741 }
38742
38743 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
38744         LDKCounterpartyCommitmentSecrets obj_conv;
38745         obj_conv.inner = (void*)(obj & (~1));
38746         obj_conv.is_owned = false;
38747         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38748         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
38749         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38750         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38751         CVec_u8Z_free(ret_var);
38752         return ret_arr;
38753 }
38754
38755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38756         LDKu8slice ser_ref;
38757         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38758         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38759         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
38760         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
38761         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38762         return (int64_t)ret_conv;
38763 }
38764
38765 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) {
38766         LDKPublicKey per_commitment_point_ref;
38767         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38768         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38769         unsigned char base_secret_arr[32];
38770         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
38771         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
38772         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
38773         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
38774         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
38775         return (int64_t)ret_conv;
38776 }
38777
38778 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) {
38779         LDKPublicKey per_commitment_point_ref;
38780         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38781         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38782         LDKPublicKey base_point_ref;
38783         CHECK((*env)->GetArrayLength(env, base_point) == 33);
38784         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
38785         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
38786         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
38787         return (int64_t)ret_conv;
38788 }
38789
38790 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) {
38791         unsigned char per_commitment_secret_arr[32];
38792         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
38793         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
38794         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
38795         unsigned char countersignatory_revocation_base_secret_arr[32];
38796         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
38797         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
38798         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
38799         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
38800         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
38801         return (int64_t)ret_conv;
38802 }
38803
38804 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) {
38805         LDKPublicKey per_commitment_point_ref;
38806         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38807         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38808         LDKPublicKey countersignatory_revocation_base_point_ref;
38809         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
38810         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
38811         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
38812         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
38813         return (int64_t)ret_conv;
38814 }
38815
38816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38817         LDKTxCreationKeys this_obj_conv;
38818         this_obj_conv.inner = (void*)(this_obj & (~1));
38819         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38821         TxCreationKeys_free(this_obj_conv);
38822 }
38823
38824 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
38825         LDKTxCreationKeys this_ptr_conv;
38826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38827         this_ptr_conv.is_owned = false;
38828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38829         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38830         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
38831         return ret_arr;
38832 }
38833
38834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38835         LDKTxCreationKeys this_ptr_conv;
38836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38837         this_ptr_conv.is_owned = false;
38838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38839         LDKPublicKey val_ref;
38840         CHECK((*env)->GetArrayLength(env, val) == 33);
38841         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38842         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
38843 }
38844
38845 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38846         LDKTxCreationKeys this_ptr_conv;
38847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38848         this_ptr_conv.is_owned = false;
38849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38850         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38851         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
38852         return ret_arr;
38853 }
38854
38855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38856         LDKTxCreationKeys this_ptr_conv;
38857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38858         this_ptr_conv.is_owned = false;
38859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38860         LDKPublicKey val_ref;
38861         CHECK((*env)->GetArrayLength(env, val) == 33);
38862         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38863         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
38864 }
38865
38866 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38867         LDKTxCreationKeys this_ptr_conv;
38868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38869         this_ptr_conv.is_owned = false;
38870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38871         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38872         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
38873         return ret_arr;
38874 }
38875
38876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38877         LDKTxCreationKeys this_ptr_conv;
38878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38879         this_ptr_conv.is_owned = false;
38880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38881         LDKPublicKey val_ref;
38882         CHECK((*env)->GetArrayLength(env, val) == 33);
38883         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38884         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
38885 }
38886
38887 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38888         LDKTxCreationKeys this_ptr_conv;
38889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38890         this_ptr_conv.is_owned = false;
38891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38892         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38893         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
38894         return ret_arr;
38895 }
38896
38897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38898         LDKTxCreationKeys this_ptr_conv;
38899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38900         this_ptr_conv.is_owned = false;
38901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38902         LDKPublicKey val_ref;
38903         CHECK((*env)->GetArrayLength(env, val) == 33);
38904         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38905         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
38906 }
38907
38908 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38909         LDKTxCreationKeys this_ptr_conv;
38910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38911         this_ptr_conv.is_owned = false;
38912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38913         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38914         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
38915         return ret_arr;
38916 }
38917
38918 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) {
38919         LDKTxCreationKeys this_ptr_conv;
38920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38921         this_ptr_conv.is_owned = false;
38922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38923         LDKPublicKey val_ref;
38924         CHECK((*env)->GetArrayLength(env, val) == 33);
38925         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38926         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
38927 }
38928
38929 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) {
38930         LDKPublicKey per_commitment_point_arg_ref;
38931         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
38932         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
38933         LDKPublicKey revocation_key_arg_ref;
38934         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
38935         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
38936         LDKPublicKey broadcaster_htlc_key_arg_ref;
38937         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
38938         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
38939         LDKPublicKey countersignatory_htlc_key_arg_ref;
38940         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
38941         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
38942         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
38943         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
38944         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
38945         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);
38946         int64_t ret_ref = 0;
38947         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38948         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38950         ret_ref = (uintptr_t)ret_var.inner;
38951         if (ret_var.is_owned) {
38952                 ret_ref |= 1;
38953         }
38954         return ret_ref;
38955 }
38956
38957 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
38958         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
38959 int64_t ret_ref = 0;
38960 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38961 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38962 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38963 ret_ref = (uintptr_t)ret_var.inner;
38964 if (ret_var.is_owned) {
38965         ret_ref |= 1;
38966 }
38967         return ret_ref;
38968 }
38969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38970         LDKTxCreationKeys arg_conv;
38971         arg_conv.inner = (void*)(arg & (~1));
38972         arg_conv.is_owned = false;
38973         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38974         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
38975         return ret_conv;
38976 }
38977
38978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38979         LDKTxCreationKeys orig_conv;
38980         orig_conv.inner = (void*)(orig & (~1));
38981         orig_conv.is_owned = false;
38982         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38983         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
38984         int64_t ret_ref = 0;
38985         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38986         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38988         ret_ref = (uintptr_t)ret_var.inner;
38989         if (ret_var.is_owned) {
38990                 ret_ref |= 1;
38991         }
38992         return ret_ref;
38993 }
38994
38995 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
38996         LDKTxCreationKeys obj_conv;
38997         obj_conv.inner = (void*)(obj & (~1));
38998         obj_conv.is_owned = false;
38999         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39000         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
39001         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39002         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39003         CVec_u8Z_free(ret_var);
39004         return ret_arr;
39005 }
39006
39007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39008         LDKu8slice ser_ref;
39009         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39010         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39011         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
39012         *ret_conv = TxCreationKeys_read(ser_ref);
39013         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39014         return (int64_t)ret_conv;
39015 }
39016
39017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39018         LDKChannelPublicKeys this_obj_conv;
39019         this_obj_conv.inner = (void*)(this_obj & (~1));
39020         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39022         ChannelPublicKeys_free(this_obj_conv);
39023 }
39024
39025 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
39026         LDKChannelPublicKeys this_ptr_conv;
39027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39028         this_ptr_conv.is_owned = false;
39029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39030         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39031         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
39032         return ret_arr;
39033 }
39034
39035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39036         LDKChannelPublicKeys this_ptr_conv;
39037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39038         this_ptr_conv.is_owned = false;
39039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39040         LDKPublicKey val_ref;
39041         CHECK((*env)->GetArrayLength(env, val) == 33);
39042         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39043         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
39044 }
39045
39046 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39047         LDKChannelPublicKeys this_ptr_conv;
39048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39049         this_ptr_conv.is_owned = false;
39050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39051         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39052         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
39053         return ret_arr;
39054 }
39055
39056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39057         LDKChannelPublicKeys this_ptr_conv;
39058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39059         this_ptr_conv.is_owned = false;
39060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39061         LDKPublicKey val_ref;
39062         CHECK((*env)->GetArrayLength(env, val) == 33);
39063         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39064         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
39065 }
39066
39067 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
39068         LDKChannelPublicKeys this_ptr_conv;
39069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39070         this_ptr_conv.is_owned = false;
39071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39072         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39073         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
39074         return ret_arr;
39075 }
39076
39077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39078         LDKChannelPublicKeys this_ptr_conv;
39079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39080         this_ptr_conv.is_owned = false;
39081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39082         LDKPublicKey val_ref;
39083         CHECK((*env)->GetArrayLength(env, val) == 33);
39084         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39085         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
39086 }
39087
39088 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39089         LDKChannelPublicKeys this_ptr_conv;
39090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39091         this_ptr_conv.is_owned = false;
39092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39093         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39094         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
39095         return ret_arr;
39096 }
39097
39098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39099         LDKChannelPublicKeys this_ptr_conv;
39100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39101         this_ptr_conv.is_owned = false;
39102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39103         LDKPublicKey val_ref;
39104         CHECK((*env)->GetArrayLength(env, val) == 33);
39105         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39106         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
39107 }
39108
39109 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39110         LDKChannelPublicKeys this_ptr_conv;
39111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39112         this_ptr_conv.is_owned = false;
39113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39114         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39115         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
39116         return ret_arr;
39117 }
39118
39119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39120         LDKChannelPublicKeys this_ptr_conv;
39121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39122         this_ptr_conv.is_owned = false;
39123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39124         LDKPublicKey val_ref;
39125         CHECK((*env)->GetArrayLength(env, val) == 33);
39126         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39127         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
39128 }
39129
39130 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) {
39131         LDKPublicKey funding_pubkey_arg_ref;
39132         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
39133         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
39134         LDKPublicKey revocation_basepoint_arg_ref;
39135         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
39136         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
39137         LDKPublicKey payment_point_arg_ref;
39138         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
39139         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
39140         LDKPublicKey delayed_payment_basepoint_arg_ref;
39141         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
39142         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
39143         LDKPublicKey htlc_basepoint_arg_ref;
39144         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
39145         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
39146         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);
39147         int64_t ret_ref = 0;
39148         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39149         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39151         ret_ref = (uintptr_t)ret_var.inner;
39152         if (ret_var.is_owned) {
39153                 ret_ref |= 1;
39154         }
39155         return ret_ref;
39156 }
39157
39158 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
39159         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
39160 int64_t ret_ref = 0;
39161 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39162 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39163 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39164 ret_ref = (uintptr_t)ret_var.inner;
39165 if (ret_var.is_owned) {
39166         ret_ref |= 1;
39167 }
39168         return ret_ref;
39169 }
39170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39171         LDKChannelPublicKeys arg_conv;
39172         arg_conv.inner = (void*)(arg & (~1));
39173         arg_conv.is_owned = false;
39174         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39175         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
39176         return ret_conv;
39177 }
39178
39179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39180         LDKChannelPublicKeys orig_conv;
39181         orig_conv.inner = (void*)(orig & (~1));
39182         orig_conv.is_owned = false;
39183         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39184         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
39185         int64_t ret_ref = 0;
39186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39189         ret_ref = (uintptr_t)ret_var.inner;
39190         if (ret_var.is_owned) {
39191                 ret_ref |= 1;
39192         }
39193         return ret_ref;
39194 }
39195
39196 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
39197         LDKChannelPublicKeys obj_conv;
39198         obj_conv.inner = (void*)(obj & (~1));
39199         obj_conv.is_owned = false;
39200         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39201         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
39202         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39203         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39204         CVec_u8Z_free(ret_var);
39205         return ret_arr;
39206 }
39207
39208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39209         LDKu8slice ser_ref;
39210         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39211         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39212         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
39213         *ret_conv = ChannelPublicKeys_read(ser_ref);
39214         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39215         return (int64_t)ret_conv;
39216 }
39217
39218 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) {
39219         LDKPublicKey per_commitment_point_ref;
39220         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
39221         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
39222         LDKPublicKey broadcaster_delayed_payment_base_ref;
39223         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
39224         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
39225         LDKPublicKey broadcaster_htlc_base_ref;
39226         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
39227         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
39228         LDKPublicKey countersignatory_revocation_base_ref;
39229         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
39230         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
39231         LDKPublicKey countersignatory_htlc_base_ref;
39232         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
39233         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
39234         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
39235         *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);
39236         return (int64_t)ret_conv;
39237 }
39238
39239 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) {
39240         LDKPublicKey per_commitment_point_ref;
39241         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
39242         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
39243         LDKChannelPublicKeys broadcaster_keys_conv;
39244         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
39245         broadcaster_keys_conv.is_owned = false;
39246         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
39247         LDKChannelPublicKeys countersignatory_keys_conv;
39248         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
39249         countersignatory_keys_conv.is_owned = false;
39250         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
39251         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
39252         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
39253         return (int64_t)ret_conv;
39254 }
39255
39256 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) {
39257         LDKPublicKey revocation_key_ref;
39258         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
39259         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
39260         LDKPublicKey broadcaster_delayed_payment_key_ref;
39261         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
39262         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
39263         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
39264         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39265         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39266         CVec_u8Z_free(ret_var);
39267         return ret_arr;
39268 }
39269
39270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39271         LDKHTLCOutputInCommitment this_obj_conv;
39272         this_obj_conv.inner = (void*)(this_obj & (~1));
39273         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39275         HTLCOutputInCommitment_free(this_obj_conv);
39276 }
39277
39278 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
39279         LDKHTLCOutputInCommitment this_ptr_conv;
39280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39281         this_ptr_conv.is_owned = false;
39282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39283         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
39284         return ret_conv;
39285 }
39286
39287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39288         LDKHTLCOutputInCommitment this_ptr_conv;
39289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39290         this_ptr_conv.is_owned = false;
39291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39292         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
39293 }
39294
39295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39296         LDKHTLCOutputInCommitment this_ptr_conv;
39297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39298         this_ptr_conv.is_owned = false;
39299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39300         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
39301         return ret_conv;
39302 }
39303
39304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39305         LDKHTLCOutputInCommitment this_ptr_conv;
39306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39307         this_ptr_conv.is_owned = false;
39308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39309         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
39310 }
39311
39312 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
39313         LDKHTLCOutputInCommitment this_ptr_conv;
39314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39315         this_ptr_conv.is_owned = false;
39316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39317         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
39318         return ret_conv;
39319 }
39320
39321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39322         LDKHTLCOutputInCommitment this_ptr_conv;
39323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39324         this_ptr_conv.is_owned = false;
39325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39326         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
39327 }
39328
39329 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39330         LDKHTLCOutputInCommitment this_ptr_conv;
39331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39332         this_ptr_conv.is_owned = false;
39333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39334         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39335         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
39336         return ret_arr;
39337 }
39338
39339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39340         LDKHTLCOutputInCommitment this_ptr_conv;
39341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39342         this_ptr_conv.is_owned = false;
39343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39344         LDKThirtyTwoBytes val_ref;
39345         CHECK((*env)->GetArrayLength(env, val) == 32);
39346         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39347         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
39348 }
39349
39350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
39351         LDKHTLCOutputInCommitment this_ptr_conv;
39352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39353         this_ptr_conv.is_owned = false;
39354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39355         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
39356         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
39357         int64_t ret_ref = (uintptr_t)ret_copy;
39358         return ret_ref;
39359 }
39360
39361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39362         LDKHTLCOutputInCommitment this_ptr_conv;
39363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39364         this_ptr_conv.is_owned = false;
39365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39366         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
39367         CHECK_ACCESS(val_ptr);
39368         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
39369         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
39370         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
39371 }
39372
39373 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) {
39374         LDKThirtyTwoBytes payment_hash_arg_ref;
39375         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
39376         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
39377         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
39378         CHECK_ACCESS(transaction_output_index_arg_ptr);
39379         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
39380         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
39381         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
39382         int64_t ret_ref = 0;
39383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39386         ret_ref = (uintptr_t)ret_var.inner;
39387         if (ret_var.is_owned) {
39388                 ret_ref |= 1;
39389         }
39390         return ret_ref;
39391 }
39392
39393 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
39394         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
39395 int64_t ret_ref = 0;
39396 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39397 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39398 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39399 ret_ref = (uintptr_t)ret_var.inner;
39400 if (ret_var.is_owned) {
39401         ret_ref |= 1;
39402 }
39403         return ret_ref;
39404 }
39405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39406         LDKHTLCOutputInCommitment arg_conv;
39407         arg_conv.inner = (void*)(arg & (~1));
39408         arg_conv.is_owned = false;
39409         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39410         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
39411         return ret_conv;
39412 }
39413
39414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39415         LDKHTLCOutputInCommitment orig_conv;
39416         orig_conv.inner = (void*)(orig & (~1));
39417         orig_conv.is_owned = false;
39418         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39419         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
39420         int64_t ret_ref = 0;
39421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39424         ret_ref = (uintptr_t)ret_var.inner;
39425         if (ret_var.is_owned) {
39426                 ret_ref |= 1;
39427         }
39428         return ret_ref;
39429 }
39430
39431 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
39432         LDKHTLCOutputInCommitment obj_conv;
39433         obj_conv.inner = (void*)(obj & (~1));
39434         obj_conv.is_owned = false;
39435         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39436         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
39437         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39438         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39439         CVec_u8Z_free(ret_var);
39440         return ret_arr;
39441 }
39442
39443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39444         LDKu8slice ser_ref;
39445         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39446         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39447         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
39448         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
39449         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39450         return (int64_t)ret_conv;
39451 }
39452
39453 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) {
39454         LDKHTLCOutputInCommitment htlc_conv;
39455         htlc_conv.inner = (void*)(htlc & (~1));
39456         htlc_conv.is_owned = false;
39457         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
39458         LDKTxCreationKeys keys_conv;
39459         keys_conv.inner = (void*)(keys & (~1));
39460         keys_conv.is_owned = false;
39461         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
39462         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
39463         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39464         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39465         CVec_u8Z_free(ret_var);
39466         return ret_arr;
39467 }
39468
39469 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
39470         LDKPublicKey broadcaster_ref;
39471         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
39472         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
39473         LDKPublicKey countersignatory_ref;
39474         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
39475         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
39476         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
39477         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39478         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39479         CVec_u8Z_free(ret_var);
39480         return ret_arr;
39481 }
39482
39483 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) {
39484         unsigned char commitment_txid_arr[32];
39485         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
39486         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
39487         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
39488         LDKHTLCOutputInCommitment htlc_conv;
39489         htlc_conv.inner = (void*)(htlc & (~1));
39490         htlc_conv.is_owned = false;
39491         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
39492         LDKPublicKey broadcaster_delayed_payment_key_ref;
39493         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
39494         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
39495         LDKPublicKey revocation_key_ref;
39496         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
39497         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
39498         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);
39499         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39500         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39501         Transaction_free(ret_var);
39502         return ret_arr;
39503 }
39504
39505 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
39506         LDKPublicKey funding_pubkey_ref;
39507         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
39508         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
39509         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
39510         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39511         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39512         CVec_u8Z_free(ret_var);
39513         return ret_arr;
39514 }
39515
39516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39517         LDKChannelTransactionParameters this_obj_conv;
39518         this_obj_conv.inner = (void*)(this_obj & (~1));
39519         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39521         ChannelTransactionParameters_free(this_obj_conv);
39522 }
39523
39524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
39525         LDKChannelTransactionParameters this_ptr_conv;
39526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39527         this_ptr_conv.is_owned = false;
39528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39529         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
39530         int64_t ret_ref = 0;
39531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39534         ret_ref = (uintptr_t)ret_var.inner;
39535         if (ret_var.is_owned) {
39536                 ret_ref |= 1;
39537         }
39538         return ret_ref;
39539 }
39540
39541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39542         LDKChannelTransactionParameters this_ptr_conv;
39543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39544         this_ptr_conv.is_owned = false;
39545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39546         LDKChannelPublicKeys val_conv;
39547         val_conv.inner = (void*)(val & (~1));
39548         val_conv.is_owned = (val & 1) || (val == 0);
39549         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39550         val_conv = ChannelPublicKeys_clone(&val_conv);
39551         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
39552 }
39553
39554 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
39555         LDKChannelTransactionParameters this_ptr_conv;
39556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39557         this_ptr_conv.is_owned = false;
39558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39559         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
39560         return ret_conv;
39561 }
39562
39563 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) {
39564         LDKChannelTransactionParameters this_ptr_conv;
39565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39566         this_ptr_conv.is_owned = false;
39567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39568         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
39569 }
39570
39571 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
39572         LDKChannelTransactionParameters this_ptr_conv;
39573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39574         this_ptr_conv.is_owned = false;
39575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39576         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
39577         return ret_conv;
39578 }
39579
39580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39581         LDKChannelTransactionParameters this_ptr_conv;
39582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39583         this_ptr_conv.is_owned = false;
39584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39585         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
39586 }
39587
39588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
39589         LDKChannelTransactionParameters this_ptr_conv;
39590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39591         this_ptr_conv.is_owned = false;
39592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39593         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
39594         int64_t ret_ref = 0;
39595         if ((uintptr_t)ret_var.inner > 4096) {
39596                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39597                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39599                 ret_ref = (uintptr_t)ret_var.inner;
39600                 if (ret_var.is_owned) {
39601                         ret_ref |= 1;
39602                 }
39603         }
39604         return ret_ref;
39605 }
39606
39607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39608         LDKChannelTransactionParameters this_ptr_conv;
39609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39610         this_ptr_conv.is_owned = false;
39611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39612         LDKCounterpartyChannelTransactionParameters val_conv;
39613         val_conv.inner = (void*)(val & (~1));
39614         val_conv.is_owned = (val & 1) || (val == 0);
39615         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39616         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
39617         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
39618 }
39619
39620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39621         LDKChannelTransactionParameters this_ptr_conv;
39622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39623         this_ptr_conv.is_owned = false;
39624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39625         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
39626         int64_t ret_ref = 0;
39627         if ((uintptr_t)ret_var.inner > 4096) {
39628                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39629                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39631                 ret_ref = (uintptr_t)ret_var.inner;
39632                 if (ret_var.is_owned) {
39633                         ret_ref |= 1;
39634                 }
39635         }
39636         return ret_ref;
39637 }
39638
39639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39640         LDKChannelTransactionParameters this_ptr_conv;
39641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39642         this_ptr_conv.is_owned = false;
39643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39644         LDKOutPoint val_conv;
39645         val_conv.inner = (void*)(val & (~1));
39646         val_conv.is_owned = (val & 1) || (val == 0);
39647         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39648         val_conv = OutPoint_clone(&val_conv);
39649         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
39650 }
39651
39652 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
39653         LDKChannelTransactionParameters this_ptr_conv;
39654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39655         this_ptr_conv.is_owned = false;
39656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39657         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
39658         return ret_conv;
39659 }
39660
39661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
39662         LDKChannelTransactionParameters this_ptr_conv;
39663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39664         this_ptr_conv.is_owned = false;
39665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39666         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
39667         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
39668 }
39669
39670 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) {
39671         LDKChannelPublicKeys holder_pubkeys_arg_conv;
39672         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
39673         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
39674         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
39675         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
39676         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
39677         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
39678         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
39679         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
39680         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
39681         LDKOutPoint funding_outpoint_arg_conv;
39682         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
39683         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
39684         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
39685         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
39686         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
39687         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);
39688         int64_t ret_ref = 0;
39689         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39690         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39692         ret_ref = (uintptr_t)ret_var.inner;
39693         if (ret_var.is_owned) {
39694                 ret_ref |= 1;
39695         }
39696         return ret_ref;
39697 }
39698
39699 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
39700         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
39701 int64_t ret_ref = 0;
39702 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39703 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39704 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39705 ret_ref = (uintptr_t)ret_var.inner;
39706 if (ret_var.is_owned) {
39707         ret_ref |= 1;
39708 }
39709         return ret_ref;
39710 }
39711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39712         LDKChannelTransactionParameters arg_conv;
39713         arg_conv.inner = (void*)(arg & (~1));
39714         arg_conv.is_owned = false;
39715         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39716         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
39717         return ret_conv;
39718 }
39719
39720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39721         LDKChannelTransactionParameters orig_conv;
39722         orig_conv.inner = (void*)(orig & (~1));
39723         orig_conv.is_owned = false;
39724         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39725         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
39726         int64_t ret_ref = 0;
39727         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39728         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39730         ret_ref = (uintptr_t)ret_var.inner;
39731         if (ret_var.is_owned) {
39732                 ret_ref |= 1;
39733         }
39734         return ret_ref;
39735 }
39736
39737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39738         LDKCounterpartyChannelTransactionParameters this_obj_conv;
39739         this_obj_conv.inner = (void*)(this_obj & (~1));
39740         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39742         CounterpartyChannelTransactionParameters_free(this_obj_conv);
39743 }
39744
39745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
39746         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39748         this_ptr_conv.is_owned = false;
39749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39750         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
39751         int64_t ret_ref = 0;
39752         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39753         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39755         ret_ref = (uintptr_t)ret_var.inner;
39756         if (ret_var.is_owned) {
39757                 ret_ref |= 1;
39758         }
39759         return ret_ref;
39760 }
39761
39762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39763         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39765         this_ptr_conv.is_owned = false;
39766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39767         LDKChannelPublicKeys val_conv;
39768         val_conv.inner = (void*)(val & (~1));
39769         val_conv.is_owned = (val & 1) || (val == 0);
39770         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39771         val_conv = ChannelPublicKeys_clone(&val_conv);
39772         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
39773 }
39774
39775 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
39776         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39778         this_ptr_conv.is_owned = false;
39779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39780         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
39781         return ret_conv;
39782 }
39783
39784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
39785         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39787         this_ptr_conv.is_owned = false;
39788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39789         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
39790 }
39791
39792 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) {
39793         LDKChannelPublicKeys pubkeys_arg_conv;
39794         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
39795         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
39796         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
39797         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
39798         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
39799         int64_t ret_ref = 0;
39800         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39801         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39803         ret_ref = (uintptr_t)ret_var.inner;
39804         if (ret_var.is_owned) {
39805                 ret_ref |= 1;
39806         }
39807         return ret_ref;
39808 }
39809
39810 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
39811         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
39812 int64_t ret_ref = 0;
39813 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39814 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39815 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39816 ret_ref = (uintptr_t)ret_var.inner;
39817 if (ret_var.is_owned) {
39818         ret_ref |= 1;
39819 }
39820         return ret_ref;
39821 }
39822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39823         LDKCounterpartyChannelTransactionParameters arg_conv;
39824         arg_conv.inner = (void*)(arg & (~1));
39825         arg_conv.is_owned = false;
39826         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39827         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
39828         return ret_conv;
39829 }
39830
39831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39832         LDKCounterpartyChannelTransactionParameters orig_conv;
39833         orig_conv.inner = (void*)(orig & (~1));
39834         orig_conv.is_owned = false;
39835         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39836         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
39837         int64_t ret_ref = 0;
39838         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39839         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39841         ret_ref = (uintptr_t)ret_var.inner;
39842         if (ret_var.is_owned) {
39843                 ret_ref |= 1;
39844         }
39845         return ret_ref;
39846 }
39847
39848 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
39849         LDKChannelTransactionParameters this_arg_conv;
39850         this_arg_conv.inner = (void*)(this_arg & (~1));
39851         this_arg_conv.is_owned = false;
39852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39853         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
39854         return ret_conv;
39855 }
39856
39857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
39858         LDKChannelTransactionParameters this_arg_conv;
39859         this_arg_conv.inner = (void*)(this_arg & (~1));
39860         this_arg_conv.is_owned = false;
39861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39862         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
39863         int64_t ret_ref = 0;
39864         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39865         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39867         ret_ref = (uintptr_t)ret_var.inner;
39868         if (ret_var.is_owned) {
39869                 ret_ref |= 1;
39870         }
39871         return ret_ref;
39872 }
39873
39874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
39875         LDKChannelTransactionParameters this_arg_conv;
39876         this_arg_conv.inner = (void*)(this_arg & (~1));
39877         this_arg_conv.is_owned = false;
39878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39879         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
39880         int64_t ret_ref = 0;
39881         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39882         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39884         ret_ref = (uintptr_t)ret_var.inner;
39885         if (ret_var.is_owned) {
39886                 ret_ref |= 1;
39887         }
39888         return ret_ref;
39889 }
39890
39891 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
39892         LDKCounterpartyChannelTransactionParameters obj_conv;
39893         obj_conv.inner = (void*)(obj & (~1));
39894         obj_conv.is_owned = false;
39895         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39896         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
39897         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39898         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39899         CVec_u8Z_free(ret_var);
39900         return ret_arr;
39901 }
39902
39903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39904         LDKu8slice ser_ref;
39905         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39906         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39907         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
39908         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
39909         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39910         return (int64_t)ret_conv;
39911 }
39912
39913 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
39914         LDKChannelTransactionParameters obj_conv;
39915         obj_conv.inner = (void*)(obj & (~1));
39916         obj_conv.is_owned = false;
39917         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39918         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
39919         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39920         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39921         CVec_u8Z_free(ret_var);
39922         return ret_arr;
39923 }
39924
39925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39926         LDKu8slice ser_ref;
39927         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39928         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39929         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
39930         *ret_conv = ChannelTransactionParameters_read(ser_ref);
39931         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39932         return (int64_t)ret_conv;
39933 }
39934
39935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39936         LDKDirectedChannelTransactionParameters this_obj_conv;
39937         this_obj_conv.inner = (void*)(this_obj & (~1));
39938         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39940         DirectedChannelTransactionParameters_free(this_obj_conv);
39941 }
39942
39943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
39944         LDKDirectedChannelTransactionParameters this_arg_conv;
39945         this_arg_conv.inner = (void*)(this_arg & (~1));
39946         this_arg_conv.is_owned = false;
39947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39948         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
39949         int64_t ret_ref = 0;
39950         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39951         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39953         ret_ref = (uintptr_t)ret_var.inner;
39954         if (ret_var.is_owned) {
39955                 ret_ref |= 1;
39956         }
39957         return ret_ref;
39958 }
39959
39960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
39961         LDKDirectedChannelTransactionParameters this_arg_conv;
39962         this_arg_conv.inner = (void*)(this_arg & (~1));
39963         this_arg_conv.is_owned = false;
39964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39965         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
39966         int64_t ret_ref = 0;
39967         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39968         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39970         ret_ref = (uintptr_t)ret_var.inner;
39971         if (ret_var.is_owned) {
39972                 ret_ref |= 1;
39973         }
39974         return ret_ref;
39975 }
39976
39977 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
39978         LDKDirectedChannelTransactionParameters this_arg_conv;
39979         this_arg_conv.inner = (void*)(this_arg & (~1));
39980         this_arg_conv.is_owned = false;
39981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39982         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
39983         return ret_conv;
39984 }
39985
39986 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
39987         LDKDirectedChannelTransactionParameters this_arg_conv;
39988         this_arg_conv.inner = (void*)(this_arg & (~1));
39989         this_arg_conv.is_owned = false;
39990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39991         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
39992         return ret_conv;
39993 }
39994
39995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
39996         LDKDirectedChannelTransactionParameters this_arg_conv;
39997         this_arg_conv.inner = (void*)(this_arg & (~1));
39998         this_arg_conv.is_owned = false;
39999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40000         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
40001         int64_t ret_ref = 0;
40002         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40003         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40005         ret_ref = (uintptr_t)ret_var.inner;
40006         if (ret_var.is_owned) {
40007                 ret_ref |= 1;
40008         }
40009         return ret_ref;
40010 }
40011
40012 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
40013         LDKDirectedChannelTransactionParameters this_arg_conv;
40014         this_arg_conv.inner = (void*)(this_arg & (~1));
40015         this_arg_conv.is_owned = false;
40016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40017         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
40018         return ret_conv;
40019 }
40020
40021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40022         LDKHolderCommitmentTransaction this_obj_conv;
40023         this_obj_conv.inner = (void*)(this_obj & (~1));
40024         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40026         HolderCommitmentTransaction_free(this_obj_conv);
40027 }
40028
40029 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
40030         LDKHolderCommitmentTransaction this_ptr_conv;
40031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40032         this_ptr_conv.is_owned = false;
40033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40034         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
40035         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
40036         return ret_arr;
40037 }
40038
40039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40040         LDKHolderCommitmentTransaction this_ptr_conv;
40041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40042         this_ptr_conv.is_owned = false;
40043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40044         LDKSignature val_ref;
40045         CHECK((*env)->GetArrayLength(env, val) == 64);
40046         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
40047         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
40048 }
40049
40050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
40051         LDKHolderCommitmentTransaction this_ptr_conv;
40052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40053         this_ptr_conv.is_owned = false;
40054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40055         LDKCVec_SignatureZ val_constr;
40056         val_constr.datalen = (*env)->GetArrayLength(env, val);
40057         if (val_constr.datalen > 0)
40058                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
40059         else
40060                 val_constr.data = NULL;
40061         for (size_t i = 0; i < val_constr.datalen; i++) {
40062                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
40063                 LDKSignature val_conv_8_ref;
40064                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
40065                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
40066                 val_constr.data[i] = val_conv_8_ref;
40067         }
40068         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
40069 }
40070
40071 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
40072         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
40073 int64_t ret_ref = 0;
40074 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40075 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40076 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40077 ret_ref = (uintptr_t)ret_var.inner;
40078 if (ret_var.is_owned) {
40079         ret_ref |= 1;
40080 }
40081         return ret_ref;
40082 }
40083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40084         LDKHolderCommitmentTransaction arg_conv;
40085         arg_conv.inner = (void*)(arg & (~1));
40086         arg_conv.is_owned = false;
40087         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40088         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
40089         return ret_conv;
40090 }
40091
40092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40093         LDKHolderCommitmentTransaction orig_conv;
40094         orig_conv.inner = (void*)(orig & (~1));
40095         orig_conv.is_owned = false;
40096         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40097         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
40098         int64_t ret_ref = 0;
40099         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40100         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40101         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40102         ret_ref = (uintptr_t)ret_var.inner;
40103         if (ret_var.is_owned) {
40104                 ret_ref |= 1;
40105         }
40106         return ret_ref;
40107 }
40108
40109 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
40110         LDKHolderCommitmentTransaction obj_conv;
40111         obj_conv.inner = (void*)(obj & (~1));
40112         obj_conv.is_owned = false;
40113         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40114         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
40115         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40116         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40117         CVec_u8Z_free(ret_var);
40118         return ret_arr;
40119 }
40120
40121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40122         LDKu8slice ser_ref;
40123         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40124         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40125         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
40126         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
40127         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40128         return (int64_t)ret_conv;
40129 }
40130
40131 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) {
40132         LDKCommitmentTransaction commitment_tx_conv;
40133         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
40134         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
40135         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
40136         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
40137         LDKSignature counterparty_sig_ref;
40138         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
40139         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
40140         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
40141         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
40142         if (counterparty_htlc_sigs_constr.datalen > 0)
40143                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
40144         else
40145                 counterparty_htlc_sigs_constr.data = NULL;
40146         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
40147                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
40148                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
40149                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
40150                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
40151                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
40152         }
40153         LDKPublicKey holder_funding_key_ref;
40154         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
40155         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
40156         LDKPublicKey counterparty_funding_key_ref;
40157         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
40158         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
40159         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
40160         int64_t ret_ref = 0;
40161         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40162         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40164         ret_ref = (uintptr_t)ret_var.inner;
40165         if (ret_var.is_owned) {
40166                 ret_ref |= 1;
40167         }
40168         return ret_ref;
40169 }
40170
40171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40172         LDKBuiltCommitmentTransaction this_obj_conv;
40173         this_obj_conv.inner = (void*)(this_obj & (~1));
40174         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40176         BuiltCommitmentTransaction_free(this_obj_conv);
40177 }
40178
40179 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
40180         LDKBuiltCommitmentTransaction this_ptr_conv;
40181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40182         this_ptr_conv.is_owned = false;
40183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40184         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
40185         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40186         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40187         Transaction_free(ret_var);
40188         return ret_arr;
40189 }
40190
40191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40192         LDKBuiltCommitmentTransaction this_ptr_conv;
40193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40194         this_ptr_conv.is_owned = false;
40195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40196         LDKTransaction val_ref;
40197         val_ref.datalen = (*env)->GetArrayLength(env, val);
40198         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
40199         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
40200         val_ref.data_is_owned = true;
40201         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
40202 }
40203
40204 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
40205         LDKBuiltCommitmentTransaction this_ptr_conv;
40206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40207         this_ptr_conv.is_owned = false;
40208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40209         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40210         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
40211         return ret_arr;
40212 }
40213
40214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40215         LDKBuiltCommitmentTransaction 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         LDKThirtyTwoBytes val_ref;
40220         CHECK((*env)->GetArrayLength(env, val) == 32);
40221         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
40222         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
40223 }
40224
40225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
40226         LDKTransaction transaction_arg_ref;
40227         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
40228         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
40229         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
40230         transaction_arg_ref.data_is_owned = true;
40231         LDKThirtyTwoBytes txid_arg_ref;
40232         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
40233         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
40234         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
40235         int64_t ret_ref = 0;
40236         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40237         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40239         ret_ref = (uintptr_t)ret_var.inner;
40240         if (ret_var.is_owned) {
40241                 ret_ref |= 1;
40242         }
40243         return ret_ref;
40244 }
40245
40246 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
40247         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
40248 int64_t ret_ref = 0;
40249 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40250 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40251 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40252 ret_ref = (uintptr_t)ret_var.inner;
40253 if (ret_var.is_owned) {
40254         ret_ref |= 1;
40255 }
40256         return ret_ref;
40257 }
40258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40259         LDKBuiltCommitmentTransaction arg_conv;
40260         arg_conv.inner = (void*)(arg & (~1));
40261         arg_conv.is_owned = false;
40262         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40263         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
40264         return ret_conv;
40265 }
40266
40267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40268         LDKBuiltCommitmentTransaction orig_conv;
40269         orig_conv.inner = (void*)(orig & (~1));
40270         orig_conv.is_owned = false;
40271         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40272         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
40273         int64_t ret_ref = 0;
40274         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40275         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40277         ret_ref = (uintptr_t)ret_var.inner;
40278         if (ret_var.is_owned) {
40279                 ret_ref |= 1;
40280         }
40281         return ret_ref;
40282 }
40283
40284 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
40285         LDKBuiltCommitmentTransaction obj_conv;
40286         obj_conv.inner = (void*)(obj & (~1));
40287         obj_conv.is_owned = false;
40288         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40289         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
40290         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40291         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40292         CVec_u8Z_free(ret_var);
40293         return ret_arr;
40294 }
40295
40296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40297         LDKu8slice ser_ref;
40298         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40299         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40300         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
40301         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
40302         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40303         return (int64_t)ret_conv;
40304 }
40305
40306 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) {
40307         LDKBuiltCommitmentTransaction this_arg_conv;
40308         this_arg_conv.inner = (void*)(this_arg & (~1));
40309         this_arg_conv.is_owned = false;
40310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40311         LDKu8slice funding_redeemscript_ref;
40312         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40313         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40314         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40315         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
40316         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40317         return ret_arr;
40318 }
40319
40320 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) {
40321         LDKBuiltCommitmentTransaction this_arg_conv;
40322         this_arg_conv.inner = (void*)(this_arg & (~1));
40323         this_arg_conv.is_owned = false;
40324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40325         unsigned char funding_key_arr[32];
40326         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
40327         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
40328         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
40329         LDKu8slice funding_redeemscript_ref;
40330         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40331         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40332         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
40333         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
40334         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40335         return ret_arr;
40336 }
40337
40338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40339         LDKClosingTransaction this_obj_conv;
40340         this_obj_conv.inner = (void*)(this_obj & (~1));
40341         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40343         ClosingTransaction_free(this_obj_conv);
40344 }
40345
40346 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
40347         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
40348 int64_t ret_ref = 0;
40349 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40350 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40351 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40352 ret_ref = (uintptr_t)ret_var.inner;
40353 if (ret_var.is_owned) {
40354         ret_ref |= 1;
40355 }
40356         return ret_ref;
40357 }
40358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40359         LDKClosingTransaction arg_conv;
40360         arg_conv.inner = (void*)(arg & (~1));
40361         arg_conv.is_owned = false;
40362         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40363         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
40364         return ret_conv;
40365 }
40366
40367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40368         LDKClosingTransaction orig_conv;
40369         orig_conv.inner = (void*)(orig & (~1));
40370         orig_conv.is_owned = false;
40371         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40372         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
40373         int64_t ret_ref = 0;
40374         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40375         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40377         ret_ref = (uintptr_t)ret_var.inner;
40378         if (ret_var.is_owned) {
40379                 ret_ref |= 1;
40380         }
40381         return ret_ref;
40382 }
40383
40384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
40385         LDKClosingTransaction o_conv;
40386         o_conv.inner = (void*)(o & (~1));
40387         o_conv.is_owned = false;
40388         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40389         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
40390         return ret_conv;
40391 }
40392
40393 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) {
40394         LDKCVec_u8Z to_holder_script_ref;
40395         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
40396         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
40397         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
40398         LDKCVec_u8Z to_counterparty_script_ref;
40399         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
40400         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
40401         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
40402         LDKOutPoint funding_outpoint_conv;
40403         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
40404         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
40405         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
40406         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
40407         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
40408         int64_t ret_ref = 0;
40409         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40410         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40412         ret_ref = (uintptr_t)ret_var.inner;
40413         if (ret_var.is_owned) {
40414                 ret_ref |= 1;
40415         }
40416         return ret_ref;
40417 }
40418
40419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
40420         LDKClosingTransaction this_arg_conv;
40421         this_arg_conv.inner = (void*)(this_arg & (~1));
40422         this_arg_conv.is_owned = false;
40423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40424         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
40425         int64_t ret_ref = 0;
40426         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40427         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40429         ret_ref = (uintptr_t)ret_var.inner;
40430         if (ret_var.is_owned) {
40431                 ret_ref |= 1;
40432         }
40433         return ret_ref;
40434 }
40435
40436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
40437         LDKClosingTransaction this_arg_conv;
40438         this_arg_conv.inner = (void*)(this_arg & (~1));
40439         this_arg_conv.is_owned = false;
40440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40441         LDKOutPoint funding_outpoint_conv;
40442         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
40443         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
40444         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
40445         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
40446         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
40447         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
40448         return (int64_t)ret_conv;
40449 }
40450
40451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40452         LDKClosingTransaction this_arg_conv;
40453         this_arg_conv.inner = (void*)(this_arg & (~1));
40454         this_arg_conv.is_owned = false;
40455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40456         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
40457         return ret_conv;
40458 }
40459
40460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40461         LDKClosingTransaction this_arg_conv;
40462         this_arg_conv.inner = (void*)(this_arg & (~1));
40463         this_arg_conv.is_owned = false;
40464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40465         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
40466         return ret_conv;
40467 }
40468
40469 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40470         LDKClosingTransaction this_arg_conv;
40471         this_arg_conv.inner = (void*)(this_arg & (~1));
40472         this_arg_conv.is_owned = false;
40473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40474         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
40475         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40476         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40477         return ret_arr;
40478 }
40479
40480 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40481         LDKClosingTransaction this_arg_conv;
40482         this_arg_conv.inner = (void*)(this_arg & (~1));
40483         this_arg_conv.is_owned = false;
40484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40485         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
40486         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40487         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40488         return ret_arr;
40489 }
40490
40491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40492         LDKTrustedClosingTransaction this_obj_conv;
40493         this_obj_conv.inner = (void*)(this_obj & (~1));
40494         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40496         TrustedClosingTransaction_free(this_obj_conv);
40497 }
40498
40499 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
40500         LDKTrustedClosingTransaction 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         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
40505         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40506         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40507         Transaction_free(ret_var);
40508         return ret_arr;
40509 }
40510
40511 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) {
40512         LDKTrustedClosingTransaction this_arg_conv;
40513         this_arg_conv.inner = (void*)(this_arg & (~1));
40514         this_arg_conv.is_owned = false;
40515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40516         LDKu8slice funding_redeemscript_ref;
40517         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40518         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40519         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40520         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
40521         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40522         return ret_arr;
40523 }
40524
40525 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) {
40526         LDKTrustedClosingTransaction this_arg_conv;
40527         this_arg_conv.inner = (void*)(this_arg & (~1));
40528         this_arg_conv.is_owned = false;
40529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40530         unsigned char funding_key_arr[32];
40531         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
40532         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
40533         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
40534         LDKu8slice funding_redeemscript_ref;
40535         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40536         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40537         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
40538         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
40539         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40540         return ret_arr;
40541 }
40542
40543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40544         LDKCommitmentTransaction this_obj_conv;
40545         this_obj_conv.inner = (void*)(this_obj & (~1));
40546         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40548         CommitmentTransaction_free(this_obj_conv);
40549 }
40550
40551 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
40552         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
40553 int64_t ret_ref = 0;
40554 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40555 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40556 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40557 ret_ref = (uintptr_t)ret_var.inner;
40558 if (ret_var.is_owned) {
40559         ret_ref |= 1;
40560 }
40561         return ret_ref;
40562 }
40563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40564         LDKCommitmentTransaction arg_conv;
40565         arg_conv.inner = (void*)(arg & (~1));
40566         arg_conv.is_owned = false;
40567         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40568         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
40569         return ret_conv;
40570 }
40571
40572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40573         LDKCommitmentTransaction orig_conv;
40574         orig_conv.inner = (void*)(orig & (~1));
40575         orig_conv.is_owned = false;
40576         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40577         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
40578         int64_t ret_ref = 0;
40579         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40580         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40582         ret_ref = (uintptr_t)ret_var.inner;
40583         if (ret_var.is_owned) {
40584                 ret_ref |= 1;
40585         }
40586         return ret_ref;
40587 }
40588
40589 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
40590         LDKCommitmentTransaction obj_conv;
40591         obj_conv.inner = (void*)(obj & (~1));
40592         obj_conv.is_owned = false;
40593         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40594         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
40595         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40596         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40597         CVec_u8Z_free(ret_var);
40598         return ret_arr;
40599 }
40600
40601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40602         LDKu8slice ser_ref;
40603         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40604         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40605         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
40606         *ret_conv = CommitmentTransaction_read(ser_ref);
40607         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40608         return (int64_t)ret_conv;
40609 }
40610
40611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
40612         LDKCommitmentTransaction this_arg_conv;
40613         this_arg_conv.inner = (void*)(this_arg & (~1));
40614         this_arg_conv.is_owned = false;
40615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40616         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
40617         return ret_conv;
40618 }
40619
40620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40621         LDKCommitmentTransaction this_arg_conv;
40622         this_arg_conv.inner = (void*)(this_arg & (~1));
40623         this_arg_conv.is_owned = false;
40624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40625         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
40626         return ret_conv;
40627 }
40628
40629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40630         LDKCommitmentTransaction this_arg_conv;
40631         this_arg_conv.inner = (void*)(this_arg & (~1));
40632         this_arg_conv.is_owned = false;
40633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40634         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
40635         return ret_conv;
40636 }
40637
40638 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
40639         LDKCommitmentTransaction this_arg_conv;
40640         this_arg_conv.inner = (void*)(this_arg & (~1));
40641         this_arg_conv.is_owned = false;
40642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40643         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
40644         return ret_conv;
40645 }
40646
40647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
40648         LDKCommitmentTransaction this_arg_conv;
40649         this_arg_conv.inner = (void*)(this_arg & (~1));
40650         this_arg_conv.is_owned = false;
40651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40652         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
40653         int64_t ret_ref = 0;
40654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40657         ret_ref = (uintptr_t)ret_var.inner;
40658         if (ret_var.is_owned) {
40659                 ret_ref |= 1;
40660         }
40661         return ret_ref;
40662 }
40663
40664 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) {
40665         LDKCommitmentTransaction this_arg_conv;
40666         this_arg_conv.inner = (void*)(this_arg & (~1));
40667         this_arg_conv.is_owned = false;
40668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40669         LDKDirectedChannelTransactionParameters channel_parameters_conv;
40670         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
40671         channel_parameters_conv.is_owned = false;
40672         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
40673         LDKChannelPublicKeys broadcaster_keys_conv;
40674         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
40675         broadcaster_keys_conv.is_owned = false;
40676         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
40677         LDKChannelPublicKeys countersignatory_keys_conv;
40678         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
40679         countersignatory_keys_conv.is_owned = false;
40680         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
40681         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
40682         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
40683         return (int64_t)ret_conv;
40684 }
40685
40686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40687         LDKTrustedCommitmentTransaction this_obj_conv;
40688         this_obj_conv.inner = (void*)(this_obj & (~1));
40689         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40691         TrustedCommitmentTransaction_free(this_obj_conv);
40692 }
40693
40694 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
40695         LDKTrustedCommitmentTransaction this_arg_conv;
40696         this_arg_conv.inner = (void*)(this_arg & (~1));
40697         this_arg_conv.is_owned = false;
40698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40699         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40700         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
40701         return ret_arr;
40702 }
40703
40704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
40705         LDKTrustedCommitmentTransaction this_arg_conv;
40706         this_arg_conv.inner = (void*)(this_arg & (~1));
40707         this_arg_conv.is_owned = false;
40708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40709         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
40710         int64_t ret_ref = 0;
40711         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40712         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40714         ret_ref = (uintptr_t)ret_var.inner;
40715         if (ret_var.is_owned) {
40716                 ret_ref |= 1;
40717         }
40718         return ret_ref;
40719 }
40720
40721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
40722         LDKTrustedCommitmentTransaction this_arg_conv;
40723         this_arg_conv.inner = (void*)(this_arg & (~1));
40724         this_arg_conv.is_owned = false;
40725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40726         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
40727         int64_t ret_ref = 0;
40728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40731         ret_ref = (uintptr_t)ret_var.inner;
40732         if (ret_var.is_owned) {
40733                 ret_ref |= 1;
40734         }
40735         return ret_ref;
40736 }
40737
40738 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
40739         LDKTrustedCommitmentTransaction this_arg_conv;
40740         this_arg_conv.inner = (void*)(this_arg & (~1));
40741         this_arg_conv.is_owned = false;
40742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40743         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
40744         return ret_conv;
40745 }
40746
40747 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) {
40748         LDKTrustedCommitmentTransaction this_arg_conv;
40749         this_arg_conv.inner = (void*)(this_arg & (~1));
40750         this_arg_conv.is_owned = false;
40751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40752         unsigned char htlc_base_key_arr[32];
40753         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
40754         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
40755         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
40756         LDKDirectedChannelTransactionParameters channel_parameters_conv;
40757         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
40758         channel_parameters_conv.is_owned = false;
40759         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
40760         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
40761         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
40762         return (int64_t)ret_conv;
40763 }
40764
40765 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) {
40766         LDKPublicKey broadcaster_payment_basepoint_ref;
40767         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
40768         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
40769         LDKPublicKey countersignatory_payment_basepoint_ref;
40770         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
40771         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
40772         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
40773         return ret_conv;
40774 }
40775
40776 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40777         LDKInitFeatures a_conv;
40778         a_conv.inner = (void*)(a & (~1));
40779         a_conv.is_owned = false;
40780         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40781         LDKInitFeatures b_conv;
40782         b_conv.inner = (void*)(b & (~1));
40783         b_conv.is_owned = false;
40784         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40785         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
40786         return ret_conv;
40787 }
40788
40789 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40790         LDKNodeFeatures a_conv;
40791         a_conv.inner = (void*)(a & (~1));
40792         a_conv.is_owned = false;
40793         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40794         LDKNodeFeatures b_conv;
40795         b_conv.inner = (void*)(b & (~1));
40796         b_conv.is_owned = false;
40797         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40798         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
40799         return ret_conv;
40800 }
40801
40802 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40803         LDKChannelFeatures a_conv;
40804         a_conv.inner = (void*)(a & (~1));
40805         a_conv.is_owned = false;
40806         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40807         LDKChannelFeatures b_conv;
40808         b_conv.inner = (void*)(b & (~1));
40809         b_conv.is_owned = false;
40810         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40811         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
40812         return ret_conv;
40813 }
40814
40815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40816         LDKInvoiceFeatures a_conv;
40817         a_conv.inner = (void*)(a & (~1));
40818         a_conv.is_owned = false;
40819         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40820         LDKInvoiceFeatures b_conv;
40821         b_conv.inner = (void*)(b & (~1));
40822         b_conv.is_owned = false;
40823         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40824         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
40825         return ret_conv;
40826 }
40827
40828 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40829         LDKChannelTypeFeatures a_conv;
40830         a_conv.inner = (void*)(a & (~1));
40831         a_conv.is_owned = false;
40832         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40833         LDKChannelTypeFeatures b_conv;
40834         b_conv.inner = (void*)(b & (~1));
40835         b_conv.is_owned = false;
40836         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40837         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
40838         return ret_conv;
40839 }
40840
40841 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
40842         LDKInitFeatures ret_var = InitFeatures_clone(arg);
40843 int64_t ret_ref = 0;
40844 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40845 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40846 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40847 ret_ref = (uintptr_t)ret_var.inner;
40848 if (ret_var.is_owned) {
40849         ret_ref |= 1;
40850 }
40851         return ret_ref;
40852 }
40853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40854         LDKInitFeatures arg_conv;
40855         arg_conv.inner = (void*)(arg & (~1));
40856         arg_conv.is_owned = false;
40857         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40858         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
40859         return ret_conv;
40860 }
40861
40862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40863         LDKInitFeatures orig_conv;
40864         orig_conv.inner = (void*)(orig & (~1));
40865         orig_conv.is_owned = false;
40866         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40867         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
40868         int64_t ret_ref = 0;
40869         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40870         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40871         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40872         ret_ref = (uintptr_t)ret_var.inner;
40873         if (ret_var.is_owned) {
40874                 ret_ref |= 1;
40875         }
40876         return ret_ref;
40877 }
40878
40879 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
40880         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
40881 int64_t ret_ref = 0;
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         return ret_ref;
40890 }
40891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40892         LDKNodeFeatures arg_conv;
40893         arg_conv.inner = (void*)(arg & (~1));
40894         arg_conv.is_owned = false;
40895         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40896         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
40897         return ret_conv;
40898 }
40899
40900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40901         LDKNodeFeatures orig_conv;
40902         orig_conv.inner = (void*)(orig & (~1));
40903         orig_conv.is_owned = false;
40904         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40905         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
40906         int64_t ret_ref = 0;
40907         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40908         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40909         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40910         ret_ref = (uintptr_t)ret_var.inner;
40911         if (ret_var.is_owned) {
40912                 ret_ref |= 1;
40913         }
40914         return ret_ref;
40915 }
40916
40917 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
40918         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
40919 int64_t ret_ref = 0;
40920 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40921 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40922 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40923 ret_ref = (uintptr_t)ret_var.inner;
40924 if (ret_var.is_owned) {
40925         ret_ref |= 1;
40926 }
40927         return ret_ref;
40928 }
40929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40930         LDKChannelFeatures arg_conv;
40931         arg_conv.inner = (void*)(arg & (~1));
40932         arg_conv.is_owned = false;
40933         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40934         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
40935         return ret_conv;
40936 }
40937
40938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40939         LDKChannelFeatures orig_conv;
40940         orig_conv.inner = (void*)(orig & (~1));
40941         orig_conv.is_owned = false;
40942         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40943         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
40944         int64_t ret_ref = 0;
40945         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40946         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40948         ret_ref = (uintptr_t)ret_var.inner;
40949         if (ret_var.is_owned) {
40950                 ret_ref |= 1;
40951         }
40952         return ret_ref;
40953 }
40954
40955 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
40956         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
40957 int64_t ret_ref = 0;
40958 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40959 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40960 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40961 ret_ref = (uintptr_t)ret_var.inner;
40962 if (ret_var.is_owned) {
40963         ret_ref |= 1;
40964 }
40965         return ret_ref;
40966 }
40967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40968         LDKInvoiceFeatures arg_conv;
40969         arg_conv.inner = (void*)(arg & (~1));
40970         arg_conv.is_owned = false;
40971         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40972         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
40973         return ret_conv;
40974 }
40975
40976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40977         LDKInvoiceFeatures orig_conv;
40978         orig_conv.inner = (void*)(orig & (~1));
40979         orig_conv.is_owned = false;
40980         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40981         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
40982         int64_t ret_ref = 0;
40983         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40984         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40986         ret_ref = (uintptr_t)ret_var.inner;
40987         if (ret_var.is_owned) {
40988                 ret_ref |= 1;
40989         }
40990         return ret_ref;
40991 }
40992
40993 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
40994         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
40995 int64_t ret_ref = 0;
40996 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40997 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40998 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40999 ret_ref = (uintptr_t)ret_var.inner;
41000 if (ret_var.is_owned) {
41001         ret_ref |= 1;
41002 }
41003         return ret_ref;
41004 }
41005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41006         LDKChannelTypeFeatures arg_conv;
41007         arg_conv.inner = (void*)(arg & (~1));
41008         arg_conv.is_owned = false;
41009         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41010         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
41011         return ret_conv;
41012 }
41013
41014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41015         LDKChannelTypeFeatures orig_conv;
41016         orig_conv.inner = (void*)(orig & (~1));
41017         orig_conv.is_owned = false;
41018         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41019         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
41020         int64_t ret_ref = 0;
41021         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41022         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41024         ret_ref = (uintptr_t)ret_var.inner;
41025         if (ret_var.is_owned) {
41026                 ret_ref |= 1;
41027         }
41028         return ret_ref;
41029 }
41030
41031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41032         LDKInitFeatures this_obj_conv;
41033         this_obj_conv.inner = (void*)(this_obj & (~1));
41034         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41036         InitFeatures_free(this_obj_conv);
41037 }
41038
41039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41040         LDKNodeFeatures this_obj_conv;
41041         this_obj_conv.inner = (void*)(this_obj & (~1));
41042         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41044         NodeFeatures_free(this_obj_conv);
41045 }
41046
41047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41048         LDKChannelFeatures this_obj_conv;
41049         this_obj_conv.inner = (void*)(this_obj & (~1));
41050         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41052         ChannelFeatures_free(this_obj_conv);
41053 }
41054
41055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41056         LDKInvoiceFeatures this_obj_conv;
41057         this_obj_conv.inner = (void*)(this_obj & (~1));
41058         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41060         InvoiceFeatures_free(this_obj_conv);
41061 }
41062
41063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41064         LDKChannelTypeFeatures this_obj_conv;
41065         this_obj_conv.inner = (void*)(this_obj & (~1));
41066         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41068         ChannelTypeFeatures_free(this_obj_conv);
41069 }
41070
41071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
41072         LDKInitFeatures ret_var = InitFeatures_empty();
41073         int64_t ret_ref = 0;
41074         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41075         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41077         ret_ref = (uintptr_t)ret_var.inner;
41078         if (ret_var.is_owned) {
41079                 ret_ref |= 1;
41080         }
41081         return ret_ref;
41082 }
41083
41084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
41085         LDKInitFeatures ret_var = InitFeatures_known();
41086         int64_t ret_ref = 0;
41087         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41088         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41090         ret_ref = (uintptr_t)ret_var.inner;
41091         if (ret_var.is_owned) {
41092                 ret_ref |= 1;
41093         }
41094         return ret_ref;
41095 }
41096
41097 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41098         LDKInitFeatures this_arg_conv;
41099         this_arg_conv.inner = (void*)(this_arg & (~1));
41100         this_arg_conv.is_owned = false;
41101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41102         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
41103         return ret_conv;
41104 }
41105
41106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
41107         LDKNodeFeatures ret_var = NodeFeatures_empty();
41108         int64_t ret_ref = 0;
41109         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41110         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41112         ret_ref = (uintptr_t)ret_var.inner;
41113         if (ret_var.is_owned) {
41114                 ret_ref |= 1;
41115         }
41116         return ret_ref;
41117 }
41118
41119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
41120         LDKNodeFeatures ret_var = NodeFeatures_known();
41121         int64_t ret_ref = 0;
41122         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41123         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41125         ret_ref = (uintptr_t)ret_var.inner;
41126         if (ret_var.is_owned) {
41127                 ret_ref |= 1;
41128         }
41129         return ret_ref;
41130 }
41131
41132 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41133         LDKNodeFeatures this_arg_conv;
41134         this_arg_conv.inner = (void*)(this_arg & (~1));
41135         this_arg_conv.is_owned = false;
41136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41137         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
41138         return ret_conv;
41139 }
41140
41141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
41142         LDKChannelFeatures ret_var = ChannelFeatures_empty();
41143         int64_t ret_ref = 0;
41144         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41145         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41147         ret_ref = (uintptr_t)ret_var.inner;
41148         if (ret_var.is_owned) {
41149                 ret_ref |= 1;
41150         }
41151         return ret_ref;
41152 }
41153
41154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
41155         LDKChannelFeatures ret_var = ChannelFeatures_known();
41156         int64_t ret_ref = 0;
41157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41160         ret_ref = (uintptr_t)ret_var.inner;
41161         if (ret_var.is_owned) {
41162                 ret_ref |= 1;
41163         }
41164         return ret_ref;
41165 }
41166
41167 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41168         LDKChannelFeatures this_arg_conv;
41169         this_arg_conv.inner = (void*)(this_arg & (~1));
41170         this_arg_conv.is_owned = false;
41171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41172         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
41173         return ret_conv;
41174 }
41175
41176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
41177         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
41178         int64_t ret_ref = 0;
41179         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41180         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41182         ret_ref = (uintptr_t)ret_var.inner;
41183         if (ret_var.is_owned) {
41184                 ret_ref |= 1;
41185         }
41186         return ret_ref;
41187 }
41188
41189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
41190         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
41191         int64_t ret_ref = 0;
41192         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41193         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41195         ret_ref = (uintptr_t)ret_var.inner;
41196         if (ret_var.is_owned) {
41197                 ret_ref |= 1;
41198         }
41199         return ret_ref;
41200 }
41201
41202 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41203         LDKInvoiceFeatures this_arg_conv;
41204         this_arg_conv.inner = (void*)(this_arg & (~1));
41205         this_arg_conv.is_owned = false;
41206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41207         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
41208         return ret_conv;
41209 }
41210
41211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
41212         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
41213         int64_t ret_ref = 0;
41214         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41215         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41217         ret_ref = (uintptr_t)ret_var.inner;
41218         if (ret_var.is_owned) {
41219                 ret_ref |= 1;
41220         }
41221         return ret_ref;
41222 }
41223
41224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1known(JNIEnv *env, jclass clz) {
41225         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
41226         int64_t ret_ref = 0;
41227         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41228         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41230         ret_ref = (uintptr_t)ret_var.inner;
41231         if (ret_var.is_owned) {
41232                 ret_ref |= 1;
41233         }
41234         return ret_ref;
41235 }
41236
41237 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41238         LDKChannelTypeFeatures this_arg_conv;
41239         this_arg_conv.inner = (void*)(this_arg & (~1));
41240         this_arg_conv.is_owned = false;
41241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41242         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
41243         return ret_conv;
41244 }
41245
41246 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41247         LDKInitFeatures obj_conv;
41248         obj_conv.inner = (void*)(obj & (~1));
41249         obj_conv.is_owned = false;
41250         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41251         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
41252         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41253         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41254         CVec_u8Z_free(ret_var);
41255         return ret_arr;
41256 }
41257
41258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41259         LDKu8slice ser_ref;
41260         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41261         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41262         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
41263         *ret_conv = InitFeatures_read(ser_ref);
41264         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41265         return (int64_t)ret_conv;
41266 }
41267
41268 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41269         LDKChannelFeatures obj_conv;
41270         obj_conv.inner = (void*)(obj & (~1));
41271         obj_conv.is_owned = false;
41272         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41273         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
41274         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41275         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41276         CVec_u8Z_free(ret_var);
41277         return ret_arr;
41278 }
41279
41280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41281         LDKu8slice ser_ref;
41282         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41283         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41284         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
41285         *ret_conv = ChannelFeatures_read(ser_ref);
41286         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41287         return (int64_t)ret_conv;
41288 }
41289
41290 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41291         LDKNodeFeatures obj_conv;
41292         obj_conv.inner = (void*)(obj & (~1));
41293         obj_conv.is_owned = false;
41294         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41295         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
41296         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41297         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41298         CVec_u8Z_free(ret_var);
41299         return ret_arr;
41300 }
41301
41302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41303         LDKu8slice ser_ref;
41304         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41305         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41306         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
41307         *ret_conv = NodeFeatures_read(ser_ref);
41308         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41309         return (int64_t)ret_conv;
41310 }
41311
41312 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41313         LDKInvoiceFeatures obj_conv;
41314         obj_conv.inner = (void*)(obj & (~1));
41315         obj_conv.is_owned = false;
41316         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41317         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
41318         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41319         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41320         CVec_u8Z_free(ret_var);
41321         return ret_arr;
41322 }
41323
41324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41325         LDKu8slice ser_ref;
41326         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41327         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41328         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
41329         *ret_conv = InvoiceFeatures_read(ser_ref);
41330         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41331         return (int64_t)ret_conv;
41332 }
41333
41334 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41335         LDKChannelTypeFeatures obj_conv;
41336         obj_conv.inner = (void*)(obj & (~1));
41337         obj_conv.is_owned = false;
41338         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41339         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
41340         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41341         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41342         CVec_u8Z_free(ret_var);
41343         return ret_arr;
41344 }
41345
41346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41347         LDKu8slice ser_ref;
41348         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41349         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41350         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
41351         *ret_conv = ChannelTypeFeatures_read(ser_ref);
41352         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41353         return (int64_t)ret_conv;
41354 }
41355
41356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41357         LDKInitFeatures this_arg_conv;
41358         this_arg_conv.inner = (void*)(this_arg & (~1));
41359         this_arg_conv.is_owned = false;
41360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41361         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
41362 }
41363
41364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41365         LDKInitFeatures this_arg_conv;
41366         this_arg_conv.inner = (void*)(this_arg & (~1));
41367         this_arg_conv.is_owned = false;
41368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41369         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
41370 }
41371
41372 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41373         LDKInitFeatures this_arg_conv;
41374         this_arg_conv.inner = (void*)(this_arg & (~1));
41375         this_arg_conv.is_owned = false;
41376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41377         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
41378         return ret_conv;
41379 }
41380
41381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41382         LDKNodeFeatures this_arg_conv;
41383         this_arg_conv.inner = (void*)(this_arg & (~1));
41384         this_arg_conv.is_owned = false;
41385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41386         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
41387 }
41388
41389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41390         LDKNodeFeatures this_arg_conv;
41391         this_arg_conv.inner = (void*)(this_arg & (~1));
41392         this_arg_conv.is_owned = false;
41393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41394         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
41395 }
41396
41397 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41398         LDKNodeFeatures this_arg_conv;
41399         this_arg_conv.inner = (void*)(this_arg & (~1));
41400         this_arg_conv.is_owned = false;
41401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41402         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
41403         return ret_conv;
41404 }
41405
41406 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41407         LDKInitFeatures this_arg_conv;
41408         this_arg_conv.inner = (void*)(this_arg & (~1));
41409         this_arg_conv.is_owned = false;
41410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41411         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
41412         return ret_conv;
41413 }
41414
41415 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41416         LDKNodeFeatures this_arg_conv;
41417         this_arg_conv.inner = (void*)(this_arg & (~1));
41418         this_arg_conv.is_owned = false;
41419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41420         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
41421         return ret_conv;
41422 }
41423
41424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41425         LDKInitFeatures this_arg_conv;
41426         this_arg_conv.inner = (void*)(this_arg & (~1));
41427         this_arg_conv.is_owned = false;
41428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41429         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
41430 }
41431
41432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41433         LDKInitFeatures this_arg_conv;
41434         this_arg_conv.inner = (void*)(this_arg & (~1));
41435         this_arg_conv.is_owned = false;
41436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41437         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
41438 }
41439
41440 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
41441         LDKInitFeatures this_arg_conv;
41442         this_arg_conv.inner = (void*)(this_arg & (~1));
41443         this_arg_conv.is_owned = false;
41444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41445         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
41446         return ret_conv;
41447 }
41448
41449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41450         LDKInitFeatures this_arg_conv;
41451         this_arg_conv.inner = (void*)(this_arg & (~1));
41452         this_arg_conv.is_owned = false;
41453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41454         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
41455 }
41456
41457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41458         LDKInitFeatures this_arg_conv;
41459         this_arg_conv.inner = (void*)(this_arg & (~1));
41460         this_arg_conv.is_owned = false;
41461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41462         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
41463 }
41464
41465 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41466         LDKInitFeatures this_arg_conv;
41467         this_arg_conv.inner = (void*)(this_arg & (~1));
41468         this_arg_conv.is_owned = false;
41469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41470         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
41471         return ret_conv;
41472 }
41473
41474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41475         LDKNodeFeatures this_arg_conv;
41476         this_arg_conv.inner = (void*)(this_arg & (~1));
41477         this_arg_conv.is_owned = false;
41478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41479         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
41480 }
41481
41482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41483         LDKNodeFeatures this_arg_conv;
41484         this_arg_conv.inner = (void*)(this_arg & (~1));
41485         this_arg_conv.is_owned = false;
41486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41487         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
41488 }
41489
41490 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41491         LDKNodeFeatures this_arg_conv;
41492         this_arg_conv.inner = (void*)(this_arg & (~1));
41493         this_arg_conv.is_owned = false;
41494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41495         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
41496         return ret_conv;
41497 }
41498
41499 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41500         LDKInitFeatures this_arg_conv;
41501         this_arg_conv.inner = (void*)(this_arg & (~1));
41502         this_arg_conv.is_owned = false;
41503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41504         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
41505         return ret_conv;
41506 }
41507
41508 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41509         LDKNodeFeatures this_arg_conv;
41510         this_arg_conv.inner = (void*)(this_arg & (~1));
41511         this_arg_conv.is_owned = false;
41512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41513         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
41514         return ret_conv;
41515 }
41516
41517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41518         LDKInitFeatures this_arg_conv;
41519         this_arg_conv.inner = (void*)(this_arg & (~1));
41520         this_arg_conv.is_owned = false;
41521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41522         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
41523 }
41524
41525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41526         LDKInitFeatures this_arg_conv;
41527         this_arg_conv.inner = (void*)(this_arg & (~1));
41528         this_arg_conv.is_owned = false;
41529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41530         InitFeatures_set_gossip_queries_required(&this_arg_conv);
41531 }
41532
41533 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
41534         LDKInitFeatures this_arg_conv;
41535         this_arg_conv.inner = (void*)(this_arg & (~1));
41536         this_arg_conv.is_owned = false;
41537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41538         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
41539         return ret_conv;
41540 }
41541
41542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41543         LDKNodeFeatures this_arg_conv;
41544         this_arg_conv.inner = (void*)(this_arg & (~1));
41545         this_arg_conv.is_owned = false;
41546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41547         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
41548 }
41549
41550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41551         LDKNodeFeatures this_arg_conv;
41552         this_arg_conv.inner = (void*)(this_arg & (~1));
41553         this_arg_conv.is_owned = false;
41554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41555         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
41556 }
41557
41558 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
41559         LDKNodeFeatures this_arg_conv;
41560         this_arg_conv.inner = (void*)(this_arg & (~1));
41561         this_arg_conv.is_owned = false;
41562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41563         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
41564         return ret_conv;
41565 }
41566
41567 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
41568         LDKInitFeatures this_arg_conv;
41569         this_arg_conv.inner = (void*)(this_arg & (~1));
41570         this_arg_conv.is_owned = false;
41571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41572         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
41573         return ret_conv;
41574 }
41575
41576 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
41577         LDKNodeFeatures this_arg_conv;
41578         this_arg_conv.inner = (void*)(this_arg & (~1));
41579         this_arg_conv.is_owned = false;
41580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41581         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
41582         return ret_conv;
41583 }
41584
41585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41586         LDKInitFeatures this_arg_conv;
41587         this_arg_conv.inner = (void*)(this_arg & (~1));
41588         this_arg_conv.is_owned = false;
41589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41590         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
41591 }
41592
41593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41594         LDKInitFeatures this_arg_conv;
41595         this_arg_conv.inner = (void*)(this_arg & (~1));
41596         this_arg_conv.is_owned = false;
41597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41598         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
41599 }
41600
41601 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41602         LDKInitFeatures this_arg_conv;
41603         this_arg_conv.inner = (void*)(this_arg & (~1));
41604         this_arg_conv.is_owned = false;
41605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41606         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
41607         return ret_conv;
41608 }
41609
41610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41611         LDKNodeFeatures this_arg_conv;
41612         this_arg_conv.inner = (void*)(this_arg & (~1));
41613         this_arg_conv.is_owned = false;
41614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41615         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
41616 }
41617
41618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41619         LDKNodeFeatures this_arg_conv;
41620         this_arg_conv.inner = (void*)(this_arg & (~1));
41621         this_arg_conv.is_owned = false;
41622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41623         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
41624 }
41625
41626 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41627         LDKNodeFeatures this_arg_conv;
41628         this_arg_conv.inner = (void*)(this_arg & (~1));
41629         this_arg_conv.is_owned = false;
41630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41631         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
41632         return ret_conv;
41633 }
41634
41635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41636         LDKInvoiceFeatures this_arg_conv;
41637         this_arg_conv.inner = (void*)(this_arg & (~1));
41638         this_arg_conv.is_owned = false;
41639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41640         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
41641 }
41642
41643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41644         LDKInvoiceFeatures this_arg_conv;
41645         this_arg_conv.inner = (void*)(this_arg & (~1));
41646         this_arg_conv.is_owned = false;
41647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41648         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
41649 }
41650
41651 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41652         LDKInvoiceFeatures this_arg_conv;
41653         this_arg_conv.inner = (void*)(this_arg & (~1));
41654         this_arg_conv.is_owned = false;
41655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41656         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
41657         return ret_conv;
41658 }
41659
41660 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41661         LDKInitFeatures this_arg_conv;
41662         this_arg_conv.inner = (void*)(this_arg & (~1));
41663         this_arg_conv.is_owned = false;
41664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41665         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
41666         return ret_conv;
41667 }
41668
41669 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41670         LDKNodeFeatures this_arg_conv;
41671         this_arg_conv.inner = (void*)(this_arg & (~1));
41672         this_arg_conv.is_owned = false;
41673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41674         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
41675         return ret_conv;
41676 }
41677
41678 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
41679         LDKInvoiceFeatures this_arg_conv;
41680         this_arg_conv.inner = (void*)(this_arg & (~1));
41681         this_arg_conv.is_owned = false;
41682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41683         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
41684         return ret_conv;
41685 }
41686
41687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41688         LDKInitFeatures this_arg_conv;
41689         this_arg_conv.inner = (void*)(this_arg & (~1));
41690         this_arg_conv.is_owned = false;
41691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41692         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
41693 }
41694
41695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41696         LDKInitFeatures this_arg_conv;
41697         this_arg_conv.inner = (void*)(this_arg & (~1));
41698         this_arg_conv.is_owned = false;
41699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41700         InitFeatures_set_static_remote_key_required(&this_arg_conv);
41701 }
41702
41703 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41704         LDKInitFeatures this_arg_conv;
41705         this_arg_conv.inner = (void*)(this_arg & (~1));
41706         this_arg_conv.is_owned = false;
41707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41708         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
41709         return ret_conv;
41710 }
41711
41712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41713         LDKNodeFeatures this_arg_conv;
41714         this_arg_conv.inner = (void*)(this_arg & (~1));
41715         this_arg_conv.is_owned = false;
41716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41717         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
41718 }
41719
41720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41721         LDKNodeFeatures this_arg_conv;
41722         this_arg_conv.inner = (void*)(this_arg & (~1));
41723         this_arg_conv.is_owned = false;
41724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41725         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
41726 }
41727
41728 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41729         LDKNodeFeatures this_arg_conv;
41730         this_arg_conv.inner = (void*)(this_arg & (~1));
41731         this_arg_conv.is_owned = false;
41732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41733         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
41734         return ret_conv;
41735 }
41736
41737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41738         LDKChannelTypeFeatures this_arg_conv;
41739         this_arg_conv.inner = (void*)(this_arg & (~1));
41740         this_arg_conv.is_owned = false;
41741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41742         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
41743 }
41744
41745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41746         LDKChannelTypeFeatures this_arg_conv;
41747         this_arg_conv.inner = (void*)(this_arg & (~1));
41748         this_arg_conv.is_owned = false;
41749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41750         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
41751 }
41752
41753 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41754         LDKChannelTypeFeatures this_arg_conv;
41755         this_arg_conv.inner = (void*)(this_arg & (~1));
41756         this_arg_conv.is_owned = false;
41757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41758         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
41759         return ret_conv;
41760 }
41761
41762 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41763         LDKInitFeatures this_arg_conv;
41764         this_arg_conv.inner = (void*)(this_arg & (~1));
41765         this_arg_conv.is_owned = false;
41766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41767         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
41768         return ret_conv;
41769 }
41770
41771 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41772         LDKNodeFeatures this_arg_conv;
41773         this_arg_conv.inner = (void*)(this_arg & (~1));
41774         this_arg_conv.is_owned = false;
41775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41776         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
41777         return ret_conv;
41778 }
41779
41780 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41781         LDKChannelTypeFeatures this_arg_conv;
41782         this_arg_conv.inner = (void*)(this_arg & (~1));
41783         this_arg_conv.is_owned = false;
41784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41785         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
41786         return ret_conv;
41787 }
41788
41789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41790         LDKInitFeatures this_arg_conv;
41791         this_arg_conv.inner = (void*)(this_arg & (~1));
41792         this_arg_conv.is_owned = false;
41793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41794         InitFeatures_set_payment_secret_optional(&this_arg_conv);
41795 }
41796
41797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41798         LDKInitFeatures this_arg_conv;
41799         this_arg_conv.inner = (void*)(this_arg & (~1));
41800         this_arg_conv.is_owned = false;
41801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41802         InitFeatures_set_payment_secret_required(&this_arg_conv);
41803 }
41804
41805 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41806         LDKInitFeatures this_arg_conv;
41807         this_arg_conv.inner = (void*)(this_arg & (~1));
41808         this_arg_conv.is_owned = false;
41809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41810         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
41811         return ret_conv;
41812 }
41813
41814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41815         LDKNodeFeatures this_arg_conv;
41816         this_arg_conv.inner = (void*)(this_arg & (~1));
41817         this_arg_conv.is_owned = false;
41818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41819         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
41820 }
41821
41822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41823         LDKNodeFeatures this_arg_conv;
41824         this_arg_conv.inner = (void*)(this_arg & (~1));
41825         this_arg_conv.is_owned = false;
41826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41827         NodeFeatures_set_payment_secret_required(&this_arg_conv);
41828 }
41829
41830 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41831         LDKNodeFeatures this_arg_conv;
41832         this_arg_conv.inner = (void*)(this_arg & (~1));
41833         this_arg_conv.is_owned = false;
41834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41835         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
41836         return ret_conv;
41837 }
41838
41839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41840         LDKInvoiceFeatures this_arg_conv;
41841         this_arg_conv.inner = (void*)(this_arg & (~1));
41842         this_arg_conv.is_owned = false;
41843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41844         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
41845 }
41846
41847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41848         LDKInvoiceFeatures this_arg_conv;
41849         this_arg_conv.inner = (void*)(this_arg & (~1));
41850         this_arg_conv.is_owned = false;
41851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41852         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
41853 }
41854
41855 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41856         LDKInvoiceFeatures this_arg_conv;
41857         this_arg_conv.inner = (void*)(this_arg & (~1));
41858         this_arg_conv.is_owned = false;
41859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41860         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
41861         return ret_conv;
41862 }
41863
41864 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41865         LDKInitFeatures this_arg_conv;
41866         this_arg_conv.inner = (void*)(this_arg & (~1));
41867         this_arg_conv.is_owned = false;
41868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41869         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
41870         return ret_conv;
41871 }
41872
41873 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41874         LDKNodeFeatures this_arg_conv;
41875         this_arg_conv.inner = (void*)(this_arg & (~1));
41876         this_arg_conv.is_owned = false;
41877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41878         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
41879         return ret_conv;
41880 }
41881
41882 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41883         LDKInvoiceFeatures this_arg_conv;
41884         this_arg_conv.inner = (void*)(this_arg & (~1));
41885         this_arg_conv.is_owned = false;
41886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41887         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
41888         return ret_conv;
41889 }
41890
41891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41892         LDKInitFeatures this_arg_conv;
41893         this_arg_conv.inner = (void*)(this_arg & (~1));
41894         this_arg_conv.is_owned = false;
41895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41896         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
41897 }
41898
41899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41900         LDKInitFeatures this_arg_conv;
41901         this_arg_conv.inner = (void*)(this_arg & (~1));
41902         this_arg_conv.is_owned = false;
41903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41904         InitFeatures_set_basic_mpp_required(&this_arg_conv);
41905 }
41906
41907 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41908         LDKInitFeatures this_arg_conv;
41909         this_arg_conv.inner = (void*)(this_arg & (~1));
41910         this_arg_conv.is_owned = false;
41911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41912         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
41913         return ret_conv;
41914 }
41915
41916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41917         LDKNodeFeatures this_arg_conv;
41918         this_arg_conv.inner = (void*)(this_arg & (~1));
41919         this_arg_conv.is_owned = false;
41920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41921         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
41922 }
41923
41924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41925         LDKNodeFeatures this_arg_conv;
41926         this_arg_conv.inner = (void*)(this_arg & (~1));
41927         this_arg_conv.is_owned = false;
41928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41929         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
41930 }
41931
41932 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41933         LDKNodeFeatures this_arg_conv;
41934         this_arg_conv.inner = (void*)(this_arg & (~1));
41935         this_arg_conv.is_owned = false;
41936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41937         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
41938         return ret_conv;
41939 }
41940
41941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41942         LDKInvoiceFeatures this_arg_conv;
41943         this_arg_conv.inner = (void*)(this_arg & (~1));
41944         this_arg_conv.is_owned = false;
41945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41946         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
41947 }
41948
41949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41950         LDKInvoiceFeatures this_arg_conv;
41951         this_arg_conv.inner = (void*)(this_arg & (~1));
41952         this_arg_conv.is_owned = false;
41953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41954         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
41955 }
41956
41957 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41958         LDKInvoiceFeatures this_arg_conv;
41959         this_arg_conv.inner = (void*)(this_arg & (~1));
41960         this_arg_conv.is_owned = false;
41961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41962         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
41963         return ret_conv;
41964 }
41965
41966 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41967         LDKInitFeatures this_arg_conv;
41968         this_arg_conv.inner = (void*)(this_arg & (~1));
41969         this_arg_conv.is_owned = false;
41970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41971         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
41972         return ret_conv;
41973 }
41974
41975 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41976         LDKNodeFeatures this_arg_conv;
41977         this_arg_conv.inner = (void*)(this_arg & (~1));
41978         this_arg_conv.is_owned = false;
41979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41980         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
41981         return ret_conv;
41982 }
41983
41984 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41985         LDKInvoiceFeatures this_arg_conv;
41986         this_arg_conv.inner = (void*)(this_arg & (~1));
41987         this_arg_conv.is_owned = false;
41988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41989         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
41990         return ret_conv;
41991 }
41992
41993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41994         LDKInitFeatures this_arg_conv;
41995         this_arg_conv.inner = (void*)(this_arg & (~1));
41996         this_arg_conv.is_owned = false;
41997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41998         InitFeatures_set_wumbo_optional(&this_arg_conv);
41999 }
42000
42001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42002         LDKInitFeatures this_arg_conv;
42003         this_arg_conv.inner = (void*)(this_arg & (~1));
42004         this_arg_conv.is_owned = false;
42005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42006         InitFeatures_set_wumbo_required(&this_arg_conv);
42007 }
42008
42009 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42010         LDKInitFeatures this_arg_conv;
42011         this_arg_conv.inner = (void*)(this_arg & (~1));
42012         this_arg_conv.is_owned = false;
42013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42014         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
42015         return ret_conv;
42016 }
42017
42018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42019         LDKNodeFeatures this_arg_conv;
42020         this_arg_conv.inner = (void*)(this_arg & (~1));
42021         this_arg_conv.is_owned = false;
42022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42023         NodeFeatures_set_wumbo_optional(&this_arg_conv);
42024 }
42025
42026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42027         LDKNodeFeatures this_arg_conv;
42028         this_arg_conv.inner = (void*)(this_arg & (~1));
42029         this_arg_conv.is_owned = false;
42030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42031         NodeFeatures_set_wumbo_required(&this_arg_conv);
42032 }
42033
42034 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42035         LDKNodeFeatures this_arg_conv;
42036         this_arg_conv.inner = (void*)(this_arg & (~1));
42037         this_arg_conv.is_owned = false;
42038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42039         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
42040         return ret_conv;
42041 }
42042
42043 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42044         LDKInitFeatures this_arg_conv;
42045         this_arg_conv.inner = (void*)(this_arg & (~1));
42046         this_arg_conv.is_owned = false;
42047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42048         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
42049         return ret_conv;
42050 }
42051
42052 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42053         LDKNodeFeatures this_arg_conv;
42054         this_arg_conv.inner = (void*)(this_arg & (~1));
42055         this_arg_conv.is_owned = false;
42056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42057         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
42058         return ret_conv;
42059 }
42060
42061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42062         LDKInitFeatures this_arg_conv;
42063         this_arg_conv.inner = (void*)(this_arg & (~1));
42064         this_arg_conv.is_owned = false;
42065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42066         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
42067 }
42068
42069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42070         LDKInitFeatures this_arg_conv;
42071         this_arg_conv.inner = (void*)(this_arg & (~1));
42072         this_arg_conv.is_owned = false;
42073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42074         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
42075 }
42076
42077 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42078         LDKInitFeatures this_arg_conv;
42079         this_arg_conv.inner = (void*)(this_arg & (~1));
42080         this_arg_conv.is_owned = false;
42081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42082         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
42083         return ret_conv;
42084 }
42085
42086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42087         LDKNodeFeatures this_arg_conv;
42088         this_arg_conv.inner = (void*)(this_arg & (~1));
42089         this_arg_conv.is_owned = false;
42090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42091         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
42092 }
42093
42094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42095         LDKNodeFeatures this_arg_conv;
42096         this_arg_conv.inner = (void*)(this_arg & (~1));
42097         this_arg_conv.is_owned = false;
42098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42099         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
42100 }
42101
42102 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42103         LDKNodeFeatures this_arg_conv;
42104         this_arg_conv.inner = (void*)(this_arg & (~1));
42105         this_arg_conv.is_owned = false;
42106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42107         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
42108         return ret_conv;
42109 }
42110
42111 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42112         LDKInitFeatures this_arg_conv;
42113         this_arg_conv.inner = (void*)(this_arg & (~1));
42114         this_arg_conv.is_owned = false;
42115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42116         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
42117         return ret_conv;
42118 }
42119
42120 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42121         LDKNodeFeatures this_arg_conv;
42122         this_arg_conv.inner = (void*)(this_arg & (~1));
42123         this_arg_conv.is_owned = false;
42124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42125         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
42126         return ret_conv;
42127 }
42128
42129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42130         LDKInitFeatures this_arg_conv;
42131         this_arg_conv.inner = (void*)(this_arg & (~1));
42132         this_arg_conv.is_owned = false;
42133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42134         InitFeatures_set_channel_type_optional(&this_arg_conv);
42135 }
42136
42137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42138         LDKInitFeatures this_arg_conv;
42139         this_arg_conv.inner = (void*)(this_arg & (~1));
42140         this_arg_conv.is_owned = false;
42141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42142         InitFeatures_set_channel_type_required(&this_arg_conv);
42143 }
42144
42145 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42146         LDKInitFeatures this_arg_conv;
42147         this_arg_conv.inner = (void*)(this_arg & (~1));
42148         this_arg_conv.is_owned = false;
42149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42150         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
42151         return ret_conv;
42152 }
42153
42154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42155         LDKNodeFeatures this_arg_conv;
42156         this_arg_conv.inner = (void*)(this_arg & (~1));
42157         this_arg_conv.is_owned = false;
42158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42159         NodeFeatures_set_channel_type_optional(&this_arg_conv);
42160 }
42161
42162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42163         LDKNodeFeatures this_arg_conv;
42164         this_arg_conv.inner = (void*)(this_arg & (~1));
42165         this_arg_conv.is_owned = false;
42166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42167         NodeFeatures_set_channel_type_required(&this_arg_conv);
42168 }
42169
42170 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42171         LDKNodeFeatures this_arg_conv;
42172         this_arg_conv.inner = (void*)(this_arg & (~1));
42173         this_arg_conv.is_owned = false;
42174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42175         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
42176         return ret_conv;
42177 }
42178
42179 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42180         LDKInitFeatures this_arg_conv;
42181         this_arg_conv.inner = (void*)(this_arg & (~1));
42182         this_arg_conv.is_owned = false;
42183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42184         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
42185         return ret_conv;
42186 }
42187
42188 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42189         LDKNodeFeatures this_arg_conv;
42190         this_arg_conv.inner = (void*)(this_arg & (~1));
42191         this_arg_conv.is_owned = false;
42192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42193         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
42194         return ret_conv;
42195 }
42196
42197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42198         LDKInitFeatures this_arg_conv;
42199         this_arg_conv.inner = (void*)(this_arg & (~1));
42200         this_arg_conv.is_owned = false;
42201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42202         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
42203 }
42204
42205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42206         LDKInitFeatures this_arg_conv;
42207         this_arg_conv.inner = (void*)(this_arg & (~1));
42208         this_arg_conv.is_owned = false;
42209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42210         InitFeatures_set_scid_privacy_required(&this_arg_conv);
42211 }
42212
42213 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42214         LDKInitFeatures this_arg_conv;
42215         this_arg_conv.inner = (void*)(this_arg & (~1));
42216         this_arg_conv.is_owned = false;
42217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42218         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
42219         return ret_conv;
42220 }
42221
42222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42223         LDKNodeFeatures this_arg_conv;
42224         this_arg_conv.inner = (void*)(this_arg & (~1));
42225         this_arg_conv.is_owned = false;
42226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42227         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
42228 }
42229
42230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42231         LDKNodeFeatures this_arg_conv;
42232         this_arg_conv.inner = (void*)(this_arg & (~1));
42233         this_arg_conv.is_owned = false;
42234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42235         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
42236 }
42237
42238 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42239         LDKNodeFeatures this_arg_conv;
42240         this_arg_conv.inner = (void*)(this_arg & (~1));
42241         this_arg_conv.is_owned = false;
42242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42243         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
42244         return ret_conv;
42245 }
42246
42247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42248         LDKChannelTypeFeatures this_arg_conv;
42249         this_arg_conv.inner = (void*)(this_arg & (~1));
42250         this_arg_conv.is_owned = false;
42251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42252         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
42253 }
42254
42255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42256         LDKChannelTypeFeatures this_arg_conv;
42257         this_arg_conv.inner = (void*)(this_arg & (~1));
42258         this_arg_conv.is_owned = false;
42259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42260         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
42261 }
42262
42263 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42264         LDKChannelTypeFeatures this_arg_conv;
42265         this_arg_conv.inner = (void*)(this_arg & (~1));
42266         this_arg_conv.is_owned = false;
42267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42268         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
42269         return ret_conv;
42270 }
42271
42272 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42273         LDKInitFeatures this_arg_conv;
42274         this_arg_conv.inner = (void*)(this_arg & (~1));
42275         this_arg_conv.is_owned = false;
42276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42277         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
42278         return ret_conv;
42279 }
42280
42281 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42282         LDKNodeFeatures this_arg_conv;
42283         this_arg_conv.inner = (void*)(this_arg & (~1));
42284         this_arg_conv.is_owned = false;
42285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42286         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
42287         return ret_conv;
42288 }
42289
42290 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42291         LDKChannelTypeFeatures this_arg_conv;
42292         this_arg_conv.inner = (void*)(this_arg & (~1));
42293         this_arg_conv.is_owned = false;
42294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42295         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
42296         return ret_conv;
42297 }
42298
42299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42300         LDKInitFeatures this_arg_conv;
42301         this_arg_conv.inner = (void*)(this_arg & (~1));
42302         this_arg_conv.is_owned = false;
42303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42304         InitFeatures_set_zero_conf_optional(&this_arg_conv);
42305 }
42306
42307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42308         LDKInitFeatures this_arg_conv;
42309         this_arg_conv.inner = (void*)(this_arg & (~1));
42310         this_arg_conv.is_owned = false;
42311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42312         InitFeatures_set_zero_conf_required(&this_arg_conv);
42313 }
42314
42315 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42316         LDKInitFeatures this_arg_conv;
42317         this_arg_conv.inner = (void*)(this_arg & (~1));
42318         this_arg_conv.is_owned = false;
42319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42320         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
42321         return ret_conv;
42322 }
42323
42324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42325         LDKNodeFeatures this_arg_conv;
42326         this_arg_conv.inner = (void*)(this_arg & (~1));
42327         this_arg_conv.is_owned = false;
42328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42329         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
42330 }
42331
42332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42333         LDKNodeFeatures this_arg_conv;
42334         this_arg_conv.inner = (void*)(this_arg & (~1));
42335         this_arg_conv.is_owned = false;
42336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42337         NodeFeatures_set_zero_conf_required(&this_arg_conv);
42338 }
42339
42340 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42341         LDKNodeFeatures this_arg_conv;
42342         this_arg_conv.inner = (void*)(this_arg & (~1));
42343         this_arg_conv.is_owned = false;
42344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42345         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
42346         return ret_conv;
42347 }
42348
42349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42350         LDKChannelTypeFeatures this_arg_conv;
42351         this_arg_conv.inner = (void*)(this_arg & (~1));
42352         this_arg_conv.is_owned = false;
42353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42354         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
42355 }
42356
42357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42358         LDKChannelTypeFeatures this_arg_conv;
42359         this_arg_conv.inner = (void*)(this_arg & (~1));
42360         this_arg_conv.is_owned = false;
42361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42362         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
42363 }
42364
42365 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42366         LDKChannelTypeFeatures this_arg_conv;
42367         this_arg_conv.inner = (void*)(this_arg & (~1));
42368         this_arg_conv.is_owned = false;
42369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42370         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
42371         return ret_conv;
42372 }
42373
42374 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42375         LDKInitFeatures this_arg_conv;
42376         this_arg_conv.inner = (void*)(this_arg & (~1));
42377         this_arg_conv.is_owned = false;
42378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42379         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
42380         return ret_conv;
42381 }
42382
42383 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42384         LDKNodeFeatures this_arg_conv;
42385         this_arg_conv.inner = (void*)(this_arg & (~1));
42386         this_arg_conv.is_owned = false;
42387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42388         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
42389         return ret_conv;
42390 }
42391
42392 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42393         LDKChannelTypeFeatures this_arg_conv;
42394         this_arg_conv.inner = (void*)(this_arg & (~1));
42395         this_arg_conv.is_owned = false;
42396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42397         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
42398         return ret_conv;
42399 }
42400
42401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42402         LDKNodeFeatures this_arg_conv;
42403         this_arg_conv.inner = (void*)(this_arg & (~1));
42404         this_arg_conv.is_owned = false;
42405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42406         NodeFeatures_set_keysend_optional(&this_arg_conv);
42407 }
42408
42409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42410         LDKNodeFeatures this_arg_conv;
42411         this_arg_conv.inner = (void*)(this_arg & (~1));
42412         this_arg_conv.is_owned = false;
42413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42414         NodeFeatures_set_keysend_required(&this_arg_conv);
42415 }
42416
42417 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
42418         LDKNodeFeatures this_arg_conv;
42419         this_arg_conv.inner = (void*)(this_arg & (~1));
42420         this_arg_conv.is_owned = false;
42421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42422         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
42423         return ret_conv;
42424 }
42425
42426 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
42427         LDKNodeFeatures this_arg_conv;
42428         this_arg_conv.inner = (void*)(this_arg & (~1));
42429         this_arg_conv.is_owned = false;
42430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42431         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
42432         return ret_conv;
42433 }
42434
42435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42436         LDKShutdownScript this_obj_conv;
42437         this_obj_conv.inner = (void*)(this_obj & (~1));
42438         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42440         ShutdownScript_free(this_obj_conv);
42441 }
42442
42443 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
42444         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
42445 int64_t ret_ref = 0;
42446 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42447 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42448 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42449 ret_ref = (uintptr_t)ret_var.inner;
42450 if (ret_var.is_owned) {
42451         ret_ref |= 1;
42452 }
42453         return ret_ref;
42454 }
42455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42456         LDKShutdownScript arg_conv;
42457         arg_conv.inner = (void*)(arg & (~1));
42458         arg_conv.is_owned = false;
42459         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42460         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
42461         return ret_conv;
42462 }
42463
42464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42465         LDKShutdownScript orig_conv;
42466         orig_conv.inner = (void*)(orig & (~1));
42467         orig_conv.is_owned = false;
42468         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42469         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
42470         int64_t ret_ref = 0;
42471         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42472         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42474         ret_ref = (uintptr_t)ret_var.inner;
42475         if (ret_var.is_owned) {
42476                 ret_ref |= 1;
42477         }
42478         return ret_ref;
42479 }
42480
42481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42482         LDKInvalidShutdownScript this_obj_conv;
42483         this_obj_conv.inner = (void*)(this_obj & (~1));
42484         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42486         InvalidShutdownScript_free(this_obj_conv);
42487 }
42488
42489 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
42490         LDKInvalidShutdownScript this_ptr_conv;
42491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42492         this_ptr_conv.is_owned = false;
42493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42494         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
42495         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42496         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42497         return ret_arr;
42498 }
42499
42500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42501         LDKInvalidShutdownScript this_ptr_conv;
42502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42503         this_ptr_conv.is_owned = false;
42504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42505         LDKCVec_u8Z val_ref;
42506         val_ref.datalen = (*env)->GetArrayLength(env, val);
42507         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
42508         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
42509         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
42510 }
42511
42512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
42513         LDKCVec_u8Z script_arg_ref;
42514         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
42515         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
42516         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
42517         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
42518         int64_t ret_ref = 0;
42519         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42520         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42522         ret_ref = (uintptr_t)ret_var.inner;
42523         if (ret_var.is_owned) {
42524                 ret_ref |= 1;
42525         }
42526         return ret_ref;
42527 }
42528
42529 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
42530         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
42531 int64_t ret_ref = 0;
42532 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42533 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42534 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42535 ret_ref = (uintptr_t)ret_var.inner;
42536 if (ret_var.is_owned) {
42537         ret_ref |= 1;
42538 }
42539         return ret_ref;
42540 }
42541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42542         LDKInvalidShutdownScript arg_conv;
42543         arg_conv.inner = (void*)(arg & (~1));
42544         arg_conv.is_owned = false;
42545         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42546         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
42547         return ret_conv;
42548 }
42549
42550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42551         LDKInvalidShutdownScript orig_conv;
42552         orig_conv.inner = (void*)(orig & (~1));
42553         orig_conv.is_owned = false;
42554         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42555         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
42556         int64_t ret_ref = 0;
42557         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42558         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42560         ret_ref = (uintptr_t)ret_var.inner;
42561         if (ret_var.is_owned) {
42562                 ret_ref |= 1;
42563         }
42564         return ret_ref;
42565 }
42566
42567 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
42568         LDKShutdownScript obj_conv;
42569         obj_conv.inner = (void*)(obj & (~1));
42570         obj_conv.is_owned = false;
42571         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42572         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
42573         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42574         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42575         CVec_u8Z_free(ret_var);
42576         return ret_arr;
42577 }
42578
42579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42580         LDKu8slice ser_ref;
42581         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42582         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42583         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
42584         *ret_conv = ShutdownScript_read(ser_ref);
42585         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42586         return (int64_t)ret_conv;
42587 }
42588
42589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
42590         unsigned char pubkey_hash_arr[20];
42591         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
42592         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
42593         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
42594         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
42595         int64_t ret_ref = 0;
42596         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42597         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42599         ret_ref = (uintptr_t)ret_var.inner;
42600         if (ret_var.is_owned) {
42601                 ret_ref |= 1;
42602         }
42603         return ret_ref;
42604 }
42605
42606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
42607         unsigned char script_hash_arr[32];
42608         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
42609         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
42610         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
42611         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
42612         int64_t ret_ref = 0;
42613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42616         ret_ref = (uintptr_t)ret_var.inner;
42617         if (ret_var.is_owned) {
42618                 ret_ref |= 1;
42619         }
42620         return ret_ref;
42621 }
42622
42623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
42624         
42625         LDKu8slice program_ref;
42626         program_ref.datalen = (*env)->GetArrayLength(env, program);
42627         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
42628         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
42629         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
42630         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
42631         return (int64_t)ret_conv;
42632 }
42633
42634 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
42635         LDKShutdownScript this_arg_conv;
42636         this_arg_conv.inner = (void*)(this_arg & (~1));
42637         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
42638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42639         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
42640         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
42641         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42642         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42643         CVec_u8Z_free(ret_var);
42644         return ret_arr;
42645 }
42646
42647 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
42648         LDKShutdownScript this_arg_conv;
42649         this_arg_conv.inner = (void*)(this_arg & (~1));
42650         this_arg_conv.is_owned = false;
42651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42652         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42653         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
42654         return ret_arr;
42655 }
42656
42657 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
42658         LDKShutdownScript this_arg_conv;
42659         this_arg_conv.inner = (void*)(this_arg & (~1));
42660         this_arg_conv.is_owned = false;
42661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42662         LDKInitFeatures features_conv;
42663         features_conv.inner = (void*)(features & (~1));
42664         features_conv.is_owned = false;
42665         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
42666         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
42667         return ret_conv;
42668 }
42669
42670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42671         if ((this_ptr & 1) != 0) return;
42672         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42673         CHECK_ACCESS(this_ptr_ptr);
42674         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
42675         FREE((void*)this_ptr);
42676         CustomMessageReader_free(this_ptr_conv);
42677 }
42678
42679 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
42680         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
42681         *ret_ret = Type_clone(arg);
42682         return (int64_t)ret_ret;
42683 }
42684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42685         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
42686         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
42687         LDKType* arg_conv = (LDKType*)arg_ptr;
42688         int64_t ret_conv = Type_clone_ptr(arg_conv);
42689         return ret_conv;
42690 }
42691
42692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42693         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
42694         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
42695         LDKType* orig_conv = (LDKType*)orig_ptr;
42696         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
42697         *ret_ret = Type_clone(orig_conv);
42698         return (int64_t)ret_ret;
42699 }
42700
42701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42702         if ((this_ptr & 1) != 0) return;
42703         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42704         CHECK_ACCESS(this_ptr_ptr);
42705         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
42706         FREE((void*)this_ptr);
42707         Type_free(this_ptr_conv);
42708 }
42709
42710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42711         LDKNodeId this_obj_conv;
42712         this_obj_conv.inner = (void*)(this_obj & (~1));
42713         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42715         NodeId_free(this_obj_conv);
42716 }
42717
42718 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
42719         LDKNodeId ret_var = NodeId_clone(arg);
42720 int64_t ret_ref = 0;
42721 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42722 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42723 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42724 ret_ref = (uintptr_t)ret_var.inner;
42725 if (ret_var.is_owned) {
42726         ret_ref |= 1;
42727 }
42728         return ret_ref;
42729 }
42730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42731         LDKNodeId arg_conv;
42732         arg_conv.inner = (void*)(arg & (~1));
42733         arg_conv.is_owned = false;
42734         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42735         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
42736         return ret_conv;
42737 }
42738
42739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42740         LDKNodeId orig_conv;
42741         orig_conv.inner = (void*)(orig & (~1));
42742         orig_conv.is_owned = false;
42743         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42744         LDKNodeId ret_var = NodeId_clone(&orig_conv);
42745         int64_t ret_ref = 0;
42746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42749         ret_ref = (uintptr_t)ret_var.inner;
42750         if (ret_var.is_owned) {
42751                 ret_ref |= 1;
42752         }
42753         return ret_ref;
42754 }
42755
42756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
42757         LDKPublicKey pubkey_ref;
42758         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
42759         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
42760         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
42761         int64_t ret_ref = 0;
42762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42765         ret_ref = (uintptr_t)ret_var.inner;
42766         if (ret_var.is_owned) {
42767                 ret_ref |= 1;
42768         }
42769         return ret_ref;
42770 }
42771
42772 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
42773         LDKNodeId this_arg_conv;
42774         this_arg_conv.inner = (void*)(this_arg & (~1));
42775         this_arg_conv.is_owned = false;
42776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42777         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
42778         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42779         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42780         return ret_arr;
42781 }
42782
42783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
42784         LDKNodeId o_conv;
42785         o_conv.inner = (void*)(o & (~1));
42786         o_conv.is_owned = false;
42787         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42788         int64_t ret_conv = NodeId_hash(&o_conv);
42789         return ret_conv;
42790 }
42791
42792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
42793         LDKNodeId obj_conv;
42794         obj_conv.inner = (void*)(obj & (~1));
42795         obj_conv.is_owned = false;
42796         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42797         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
42798         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42799         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42800         CVec_u8Z_free(ret_var);
42801         return ret_arr;
42802 }
42803
42804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42805         LDKu8slice ser_ref;
42806         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42807         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42808         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
42809         *ret_conv = NodeId_read(ser_ref);
42810         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42811         return (int64_t)ret_conv;
42812 }
42813
42814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42815         LDKNetworkGraph this_obj_conv;
42816         this_obj_conv.inner = (void*)(this_obj & (~1));
42817         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42819         NetworkGraph_free(this_obj_conv);
42820 }
42821
42822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42823         LDKReadOnlyNetworkGraph this_obj_conv;
42824         this_obj_conv.inner = (void*)(this_obj & (~1));
42825         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42827         ReadOnlyNetworkGraph_free(this_obj_conv);
42828 }
42829
42830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42831         if ((this_ptr & 1) != 0) return;
42832         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42833         CHECK_ACCESS(this_ptr_ptr);
42834         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
42835         FREE((void*)this_ptr);
42836         NetworkUpdate_free(this_ptr_conv);
42837 }
42838
42839 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
42840         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42841         *ret_copy = NetworkUpdate_clone(arg);
42842 int64_t ret_ref = (uintptr_t)ret_copy;
42843         return ret_ref;
42844 }
42845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42846         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
42847         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
42848         return ret_conv;
42849 }
42850
42851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42852         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
42853         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42854         *ret_copy = NetworkUpdate_clone(orig_conv);
42855         int64_t ret_ref = (uintptr_t)ret_copy;
42856         return ret_ref;
42857 }
42858
42859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
42860         LDKChannelUpdate msg_conv;
42861         msg_conv.inner = (void*)(msg & (~1));
42862         msg_conv.is_owned = (msg & 1) || (msg == 0);
42863         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
42864         msg_conv = ChannelUpdate_clone(&msg_conv);
42865         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42866         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
42867         int64_t ret_ref = (uintptr_t)ret_copy;
42868         return ret_ref;
42869 }
42870
42871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
42872         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42873         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
42874         int64_t ret_ref = (uintptr_t)ret_copy;
42875         return ret_ref;
42876 }
42877
42878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
42879         LDKPublicKey node_id_ref;
42880         CHECK((*env)->GetArrayLength(env, node_id) == 33);
42881         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
42882         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42883         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
42884         int64_t ret_ref = (uintptr_t)ret_copy;
42885         return ret_ref;
42886 }
42887
42888 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
42889         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
42890         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
42891         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42892         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42893         CVec_u8Z_free(ret_var);
42894         return ret_arr;
42895 }
42896
42897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42898         LDKu8slice ser_ref;
42899         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42900         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42901         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
42902         *ret_conv = NetworkUpdate_read(ser_ref);
42903         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42904         return (int64_t)ret_conv;
42905 }
42906
42907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42908         LDKP2PGossipSync this_obj_conv;
42909         this_obj_conv.inner = (void*)(this_obj & (~1));
42910         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42912         P2PGossipSync_free(this_obj_conv);
42913 }
42914
42915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t chain_access, int64_t logger) {
42916         LDKNetworkGraph network_graph_conv;
42917         network_graph_conv.inner = (void*)(network_graph & (~1));
42918         network_graph_conv.is_owned = false;
42919         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42920         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
42921         CHECK_ACCESS(chain_access_ptr);
42922         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
42923         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
42924         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
42925                 // Manually implement clone for Java trait instances
42926                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
42927                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42928                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
42929                 }
42930         }
42931         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42932         CHECK_ACCESS(logger_ptr);
42933         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42934         if (logger_conv.free == LDKLogger_JCalls_free) {
42935                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42936                 LDKLogger_JCalls_cloned(&logger_conv);
42937         }
42938         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
42939         int64_t ret_ref = 0;
42940         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42941         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42943         ret_ref = (uintptr_t)ret_var.inner;
42944         if (ret_var.is_owned) {
42945                 ret_ref |= 1;
42946         }
42947         return ret_ref;
42948 }
42949
42950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
42951         LDKP2PGossipSync this_arg_conv;
42952         this_arg_conv.inner = (void*)(this_arg & (~1));
42953         this_arg_conv.is_owned = false;
42954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42955         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
42956         CHECK_ACCESS(chain_access_ptr);
42957         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
42958         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
42959         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
42960                 // Manually implement clone for Java trait instances
42961                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
42962                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42963                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
42964                 }
42965         }
42966         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
42967 }
42968
42969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
42970         LDKNetworkGraph this_arg_conv;
42971         this_arg_conv.inner = (void*)(this_arg & (~1));
42972         this_arg_conv.is_owned = false;
42973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42974         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
42975         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
42976         return (int64_t)ret_ret;
42977 }
42978
42979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
42980         LDKP2PGossipSync this_arg_conv;
42981         this_arg_conv.inner = (void*)(this_arg & (~1));
42982         this_arg_conv.is_owned = false;
42983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42984         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
42985         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
42986         return (int64_t)ret_ret;
42987 }
42988
42989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
42990         LDKP2PGossipSync this_arg_conv;
42991         this_arg_conv.inner = (void*)(this_arg & (~1));
42992         this_arg_conv.is_owned = false;
42993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42994         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
42995         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
42996         return (int64_t)ret_ret;
42997 }
42998
42999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43000         LDKChannelUpdateInfo this_obj_conv;
43001         this_obj_conv.inner = (void*)(this_obj & (~1));
43002         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43004         ChannelUpdateInfo_free(this_obj_conv);
43005 }
43006
43007 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
43008         LDKChannelUpdateInfo this_ptr_conv;
43009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43010         this_ptr_conv.is_owned = false;
43011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43012         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
43013         return ret_conv;
43014 }
43015
43016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43017         LDKChannelUpdateInfo this_ptr_conv;
43018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43019         this_ptr_conv.is_owned = false;
43020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43021         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
43022 }
43023
43024 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
43025         LDKChannelUpdateInfo this_ptr_conv;
43026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43027         this_ptr_conv.is_owned = false;
43028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43029         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
43030         return ret_conv;
43031 }
43032
43033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
43034         LDKChannelUpdateInfo this_ptr_conv;
43035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43036         this_ptr_conv.is_owned = false;
43037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43038         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
43039 }
43040
43041 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
43042         LDKChannelUpdateInfo this_ptr_conv;
43043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43044         this_ptr_conv.is_owned = false;
43045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43046         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
43047         return ret_conv;
43048 }
43049
43050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
43051         LDKChannelUpdateInfo this_ptr_conv;
43052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43053         this_ptr_conv.is_owned = false;
43054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43055         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
43056 }
43057
43058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43059         LDKChannelUpdateInfo this_ptr_conv;
43060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43061         this_ptr_conv.is_owned = false;
43062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43063         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
43064         return ret_conv;
43065 }
43066
43067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43068         LDKChannelUpdateInfo this_ptr_conv;
43069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43070         this_ptr_conv.is_owned = false;
43071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43072         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
43073 }
43074
43075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43076         LDKChannelUpdateInfo this_ptr_conv;
43077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43078         this_ptr_conv.is_owned = false;
43079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43080         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
43081         return ret_conv;
43082 }
43083
43084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43085         LDKChannelUpdateInfo this_ptr_conv;
43086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43087         this_ptr_conv.is_owned = false;
43088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43089         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
43090 }
43091
43092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
43093         LDKChannelUpdateInfo this_ptr_conv;
43094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43095         this_ptr_conv.is_owned = false;
43096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43097         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
43098         int64_t ret_ref = 0;
43099         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43100         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43101         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43102         ret_ref = (uintptr_t)ret_var.inner;
43103         if (ret_var.is_owned) {
43104                 ret_ref |= 1;
43105         }
43106         return ret_ref;
43107 }
43108
43109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43110         LDKChannelUpdateInfo this_ptr_conv;
43111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43112         this_ptr_conv.is_owned = false;
43113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43114         LDKRoutingFees val_conv;
43115         val_conv.inner = (void*)(val & (~1));
43116         val_conv.is_owned = (val & 1) || (val == 0);
43117         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43118         val_conv = RoutingFees_clone(&val_conv);
43119         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
43120 }
43121
43122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
43123         LDKChannelUpdateInfo this_ptr_conv;
43124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43125         this_ptr_conv.is_owned = false;
43126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43127         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
43128         int64_t ret_ref = 0;
43129         if ((uintptr_t)ret_var.inner > 4096) {
43130                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43131                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43133                 ret_ref = (uintptr_t)ret_var.inner;
43134                 if (ret_var.is_owned) {
43135                         ret_ref |= 1;
43136                 }
43137         }
43138         return ret_ref;
43139 }
43140
43141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43142         LDKChannelUpdateInfo this_ptr_conv;
43143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43144         this_ptr_conv.is_owned = false;
43145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43146         LDKChannelUpdate val_conv;
43147         val_conv.inner = (void*)(val & (~1));
43148         val_conv.is_owned = (val & 1) || (val == 0);
43149         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43150         val_conv = ChannelUpdate_clone(&val_conv);
43151         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
43152 }
43153
43154 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) {
43155         LDKRoutingFees fees_arg_conv;
43156         fees_arg_conv.inner = (void*)(fees_arg & (~1));
43157         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
43158         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
43159         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
43160         LDKChannelUpdate last_update_message_arg_conv;
43161         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
43162         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
43163         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
43164         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
43165         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fees_arg_conv, last_update_message_arg_conv);
43166         int64_t ret_ref = 0;
43167         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43168         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43170         ret_ref = (uintptr_t)ret_var.inner;
43171         if (ret_var.is_owned) {
43172                 ret_ref |= 1;
43173         }
43174         return ret_ref;
43175 }
43176
43177 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
43178         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
43179 int64_t ret_ref = 0;
43180 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43181 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43182 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43183 ret_ref = (uintptr_t)ret_var.inner;
43184 if (ret_var.is_owned) {
43185         ret_ref |= 1;
43186 }
43187         return ret_ref;
43188 }
43189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43190         LDKChannelUpdateInfo arg_conv;
43191         arg_conv.inner = (void*)(arg & (~1));
43192         arg_conv.is_owned = false;
43193         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43194         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
43195         return ret_conv;
43196 }
43197
43198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43199         LDKChannelUpdateInfo orig_conv;
43200         orig_conv.inner = (void*)(orig & (~1));
43201         orig_conv.is_owned = false;
43202         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43203         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
43204         int64_t ret_ref = 0;
43205         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43206         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43208         ret_ref = (uintptr_t)ret_var.inner;
43209         if (ret_var.is_owned) {
43210                 ret_ref |= 1;
43211         }
43212         return ret_ref;
43213 }
43214
43215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
43216         LDKChannelUpdateInfo obj_conv;
43217         obj_conv.inner = (void*)(obj & (~1));
43218         obj_conv.is_owned = false;
43219         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43220         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
43221         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43222         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43223         CVec_u8Z_free(ret_var);
43224         return ret_arr;
43225 }
43226
43227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43228         LDKu8slice ser_ref;
43229         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43230         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43231         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
43232         *ret_conv = ChannelUpdateInfo_read(ser_ref);
43233         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43234         return (int64_t)ret_conv;
43235 }
43236
43237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43238         LDKChannelInfo this_obj_conv;
43239         this_obj_conv.inner = (void*)(this_obj & (~1));
43240         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43242         ChannelInfo_free(this_obj_conv);
43243 }
43244
43245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43246         LDKChannelInfo this_ptr_conv;
43247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43248         this_ptr_conv.is_owned = false;
43249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43250         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
43251         int64_t ret_ref = 0;
43252         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43253         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43255         ret_ref = (uintptr_t)ret_var.inner;
43256         if (ret_var.is_owned) {
43257                 ret_ref |= 1;
43258         }
43259         return ret_ref;
43260 }
43261
43262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43263         LDKChannelInfo this_ptr_conv;
43264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43265         this_ptr_conv.is_owned = false;
43266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43267         LDKChannelFeatures val_conv;
43268         val_conv.inner = (void*)(val & (~1));
43269         val_conv.is_owned = (val & 1) || (val == 0);
43270         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43271         val_conv = ChannelFeatures_clone(&val_conv);
43272         ChannelInfo_set_features(&this_ptr_conv, val_conv);
43273 }
43274
43275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
43276         LDKChannelInfo this_ptr_conv;
43277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43278         this_ptr_conv.is_owned = false;
43279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43280         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
43281         int64_t ret_ref = 0;
43282         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43283         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43285         ret_ref = (uintptr_t)ret_var.inner;
43286         if (ret_var.is_owned) {
43287                 ret_ref |= 1;
43288         }
43289         return ret_ref;
43290 }
43291
43292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43293         LDKChannelInfo this_ptr_conv;
43294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43295         this_ptr_conv.is_owned = false;
43296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43297         LDKNodeId val_conv;
43298         val_conv.inner = (void*)(val & (~1));
43299         val_conv.is_owned = (val & 1) || (val == 0);
43300         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43301         val_conv = NodeId_clone(&val_conv);
43302         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
43303 }
43304
43305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
43306         LDKChannelInfo this_ptr_conv;
43307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43308         this_ptr_conv.is_owned = false;
43309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43310         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
43311         int64_t ret_ref = 0;
43312         if ((uintptr_t)ret_var.inner > 4096) {
43313                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43314                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43316                 ret_ref = (uintptr_t)ret_var.inner;
43317                 if (ret_var.is_owned) {
43318                         ret_ref |= 1;
43319                 }
43320         }
43321         return ret_ref;
43322 }
43323
43324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43325         LDKChannelInfo this_ptr_conv;
43326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43327         this_ptr_conv.is_owned = false;
43328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43329         LDKChannelUpdateInfo val_conv;
43330         val_conv.inner = (void*)(val & (~1));
43331         val_conv.is_owned = (val & 1) || (val == 0);
43332         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43333         val_conv = ChannelUpdateInfo_clone(&val_conv);
43334         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
43335 }
43336
43337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
43338         LDKChannelInfo this_ptr_conv;
43339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43340         this_ptr_conv.is_owned = false;
43341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43342         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
43343         int64_t ret_ref = 0;
43344         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43345         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43347         ret_ref = (uintptr_t)ret_var.inner;
43348         if (ret_var.is_owned) {
43349                 ret_ref |= 1;
43350         }
43351         return ret_ref;
43352 }
43353
43354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43355         LDKChannelInfo this_ptr_conv;
43356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43357         this_ptr_conv.is_owned = false;
43358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43359         LDKNodeId val_conv;
43360         val_conv.inner = (void*)(val & (~1));
43361         val_conv.is_owned = (val & 1) || (val == 0);
43362         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43363         val_conv = NodeId_clone(&val_conv);
43364         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
43365 }
43366
43367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
43368         LDKChannelInfo this_ptr_conv;
43369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43370         this_ptr_conv.is_owned = false;
43371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43372         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
43373         int64_t ret_ref = 0;
43374         if ((uintptr_t)ret_var.inner > 4096) {
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         }
43383         return ret_ref;
43384 }
43385
43386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43387         LDKChannelInfo this_ptr_conv;
43388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43389         this_ptr_conv.is_owned = false;
43390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43391         LDKChannelUpdateInfo val_conv;
43392         val_conv.inner = (void*)(val & (~1));
43393         val_conv.is_owned = (val & 1) || (val == 0);
43394         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43395         val_conv = ChannelUpdateInfo_clone(&val_conv);
43396         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
43397 }
43398
43399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
43400         LDKChannelInfo this_ptr_conv;
43401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43402         this_ptr_conv.is_owned = false;
43403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43404         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
43405         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
43406         int64_t ret_ref = (uintptr_t)ret_copy;
43407         return ret_ref;
43408 }
43409
43410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43411         LDKChannelInfo this_ptr_conv;
43412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43413         this_ptr_conv.is_owned = false;
43414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43415         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
43416         CHECK_ACCESS(val_ptr);
43417         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
43418         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
43419         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
43420 }
43421
43422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
43423         LDKChannelInfo this_ptr_conv;
43424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43425         this_ptr_conv.is_owned = false;
43426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43427         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
43428         int64_t ret_ref = 0;
43429         if ((uintptr_t)ret_var.inner > 4096) {
43430                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43431                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43433                 ret_ref = (uintptr_t)ret_var.inner;
43434                 if (ret_var.is_owned) {
43435                         ret_ref |= 1;
43436                 }
43437         }
43438         return ret_ref;
43439 }
43440
43441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43442         LDKChannelInfo this_ptr_conv;
43443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43444         this_ptr_conv.is_owned = false;
43445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43446         LDKChannelAnnouncement val_conv;
43447         val_conv.inner = (void*)(val & (~1));
43448         val_conv.is_owned = (val & 1) || (val == 0);
43449         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43450         val_conv = ChannelAnnouncement_clone(&val_conv);
43451         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
43452 }
43453
43454 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
43455         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
43456 int64_t ret_ref = 0;
43457 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43458 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43459 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43460 ret_ref = (uintptr_t)ret_var.inner;
43461 if (ret_var.is_owned) {
43462         ret_ref |= 1;
43463 }
43464         return ret_ref;
43465 }
43466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43467         LDKChannelInfo arg_conv;
43468         arg_conv.inner = (void*)(arg & (~1));
43469         arg_conv.is_owned = false;
43470         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43471         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
43472         return ret_conv;
43473 }
43474
43475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43476         LDKChannelInfo orig_conv;
43477         orig_conv.inner = (void*)(orig & (~1));
43478         orig_conv.is_owned = false;
43479         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43480         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
43481         int64_t ret_ref = 0;
43482         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43483         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43485         ret_ref = (uintptr_t)ret_var.inner;
43486         if (ret_var.is_owned) {
43487                 ret_ref |= 1;
43488         }
43489         return ret_ref;
43490 }
43491
43492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1directional_1info(JNIEnv *env, jclass clz, int64_t this_arg, int8_t channel_flags) {
43493         LDKChannelInfo this_arg_conv;
43494         this_arg_conv.inner = (void*)(this_arg & (~1));
43495         this_arg_conv.is_owned = false;
43496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43497         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
43498         int64_t ret_ref = 0;
43499         if ((uintptr_t)ret_var.inner > 4096) {
43500                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43501                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43503                 ret_ref = (uintptr_t)ret_var.inner;
43504                 if (ret_var.is_owned) {
43505                         ret_ref |= 1;
43506                 }
43507         }
43508         return ret_ref;
43509 }
43510
43511 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
43512         LDKChannelInfo obj_conv;
43513         obj_conv.inner = (void*)(obj & (~1));
43514         obj_conv.is_owned = false;
43515         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43516         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
43517         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43518         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43519         CVec_u8Z_free(ret_var);
43520         return ret_arr;
43521 }
43522
43523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43524         LDKu8slice ser_ref;
43525         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43526         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43527         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
43528         *ret_conv = ChannelInfo_read(ser_ref);
43529         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43530         return (int64_t)ret_conv;
43531 }
43532
43533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43534         LDKDirectedChannelInfo this_obj_conv;
43535         this_obj_conv.inner = (void*)(this_obj & (~1));
43536         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43538         DirectedChannelInfo_free(this_obj_conv);
43539 }
43540
43541 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
43542         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
43543 int64_t ret_ref = 0;
43544 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43545 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43546 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43547 ret_ref = (uintptr_t)ret_var.inner;
43548 if (ret_var.is_owned) {
43549         ret_ref |= 1;
43550 }
43551         return ret_ref;
43552 }
43553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43554         LDKDirectedChannelInfo arg_conv;
43555         arg_conv.inner = (void*)(arg & (~1));
43556         arg_conv.is_owned = false;
43557         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43558         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
43559         return ret_conv;
43560 }
43561
43562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43563         LDKDirectedChannelInfo orig_conv;
43564         orig_conv.inner = (void*)(orig & (~1));
43565         orig_conv.is_owned = false;
43566         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43567         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
43568         int64_t ret_ref = 0;
43569         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43570         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43571         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43572         ret_ref = (uintptr_t)ret_var.inner;
43573         if (ret_var.is_owned) {
43574                 ret_ref |= 1;
43575         }
43576         return ret_ref;
43577 }
43578
43579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
43580         LDKDirectedChannelInfo this_arg_conv;
43581         this_arg_conv.inner = (void*)(this_arg & (~1));
43582         this_arg_conv.is_owned = false;
43583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43584         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
43585         int64_t ret_ref = 0;
43586         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43587         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43589         ret_ref = (uintptr_t)ret_var.inner;
43590         if (ret_var.is_owned) {
43591                 ret_ref |= 1;
43592         }
43593         return ret_ref;
43594 }
43595
43596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1direction(JNIEnv *env, jclass clz, int64_t this_arg) {
43597         LDKDirectedChannelInfo this_arg_conv;
43598         this_arg_conv.inner = (void*)(this_arg & (~1));
43599         this_arg_conv.is_owned = false;
43600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43601         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
43602         int64_t ret_ref = 0;
43603         if ((uintptr_t)ret_var.inner > 4096) {
43604                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43605                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43607                 ret_ref = (uintptr_t)ret_var.inner;
43608                 if (ret_var.is_owned) {
43609                         ret_ref |= 1;
43610                 }
43611         }
43612         return ret_ref;
43613 }
43614
43615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
43616         LDKDirectedChannelInfo this_arg_conv;
43617         this_arg_conv.inner = (void*)(this_arg & (~1));
43618         this_arg_conv.is_owned = false;
43619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43620         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
43621         return ret_conv;
43622 }
43623
43624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
43625         LDKDirectedChannelInfo this_arg_conv;
43626         this_arg_conv.inner = (void*)(this_arg & (~1));
43627         this_arg_conv.is_owned = false;
43628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43629         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43630         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
43631         int64_t ret_ref = (uintptr_t)ret_copy;
43632         return ret_ref;
43633 }
43634
43635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43636         if ((this_ptr & 1) != 0) return;
43637         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43638         CHECK_ACCESS(this_ptr_ptr);
43639         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
43640         FREE((void*)this_ptr);
43641         EffectiveCapacity_free(this_ptr_conv);
43642 }
43643
43644 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
43645         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43646         *ret_copy = EffectiveCapacity_clone(arg);
43647 int64_t ret_ref = (uintptr_t)ret_copy;
43648         return ret_ref;
43649 }
43650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43651         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
43652         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
43653         return ret_conv;
43654 }
43655
43656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43657         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
43658         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43659         *ret_copy = EffectiveCapacity_clone(orig_conv);
43660         int64_t ret_ref = (uintptr_t)ret_copy;
43661         return ret_ref;
43662 }
43663
43664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
43665         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43666         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
43667         int64_t ret_ref = (uintptr_t)ret_copy;
43668         return ret_ref;
43669 }
43670
43671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
43672         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43673         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
43674         int64_t ret_ref = (uintptr_t)ret_copy;
43675         return ret_ref;
43676 }
43677
43678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat, int64_t htlc_maximum_msat) {
43679         void* htlc_maximum_msat_ptr = (void*)(((uintptr_t)htlc_maximum_msat) & ~1);
43680         CHECK_ACCESS(htlc_maximum_msat_ptr);
43681         LDKCOption_u64Z htlc_maximum_msat_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_ptr);
43682         htlc_maximum_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat) & ~1));
43683         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43684         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat_conv);
43685         int64_t ret_ref = (uintptr_t)ret_copy;
43686         return ret_ref;
43687 }
43688
43689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
43690         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43691         *ret_copy = EffectiveCapacity_infinite();
43692         int64_t ret_ref = (uintptr_t)ret_copy;
43693         return ret_ref;
43694 }
43695
43696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
43697         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
43698         *ret_copy = EffectiveCapacity_unknown();
43699         int64_t ret_ref = (uintptr_t)ret_copy;
43700         return ret_ref;
43701 }
43702
43703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
43704         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
43705         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
43706         return ret_conv;
43707 }
43708
43709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43710         LDKRoutingFees this_obj_conv;
43711         this_obj_conv.inner = (void*)(this_obj & (~1));
43712         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43714         RoutingFees_free(this_obj_conv);
43715 }
43716
43717 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43718         LDKRoutingFees this_ptr_conv;
43719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43720         this_ptr_conv.is_owned = false;
43721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43722         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
43723         return ret_conv;
43724 }
43725
43726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43727         LDKRoutingFees this_ptr_conv;
43728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43729         this_ptr_conv.is_owned = false;
43730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43731         RoutingFees_set_base_msat(&this_ptr_conv, val);
43732 }
43733
43734 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
43735         LDKRoutingFees this_ptr_conv;
43736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43737         this_ptr_conv.is_owned = false;
43738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43739         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
43740         return ret_conv;
43741 }
43742
43743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43744         LDKRoutingFees this_ptr_conv;
43745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43746         this_ptr_conv.is_owned = false;
43747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43748         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
43749 }
43750
43751 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) {
43752         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
43753         int64_t ret_ref = 0;
43754         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43755         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43757         ret_ref = (uintptr_t)ret_var.inner;
43758         if (ret_var.is_owned) {
43759                 ret_ref |= 1;
43760         }
43761         return ret_ref;
43762 }
43763
43764 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43765         LDKRoutingFees a_conv;
43766         a_conv.inner = (void*)(a & (~1));
43767         a_conv.is_owned = false;
43768         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43769         LDKRoutingFees b_conv;
43770         b_conv.inner = (void*)(b & (~1));
43771         b_conv.is_owned = false;
43772         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43773         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
43774         return ret_conv;
43775 }
43776
43777 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
43778         LDKRoutingFees ret_var = RoutingFees_clone(arg);
43779 int64_t ret_ref = 0;
43780 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43781 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43782 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43783 ret_ref = (uintptr_t)ret_var.inner;
43784 if (ret_var.is_owned) {
43785         ret_ref |= 1;
43786 }
43787         return ret_ref;
43788 }
43789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43790         LDKRoutingFees arg_conv;
43791         arg_conv.inner = (void*)(arg & (~1));
43792         arg_conv.is_owned = false;
43793         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43794         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
43795         return ret_conv;
43796 }
43797
43798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43799         LDKRoutingFees orig_conv;
43800         orig_conv.inner = (void*)(orig & (~1));
43801         orig_conv.is_owned = false;
43802         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43803         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
43804         int64_t ret_ref = 0;
43805         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43806         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43808         ret_ref = (uintptr_t)ret_var.inner;
43809         if (ret_var.is_owned) {
43810                 ret_ref |= 1;
43811         }
43812         return ret_ref;
43813 }
43814
43815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
43816         LDKRoutingFees o_conv;
43817         o_conv.inner = (void*)(o & (~1));
43818         o_conv.is_owned = false;
43819         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43820         int64_t ret_conv = RoutingFees_hash(&o_conv);
43821         return ret_conv;
43822 }
43823
43824 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
43825         LDKRoutingFees obj_conv;
43826         obj_conv.inner = (void*)(obj & (~1));
43827         obj_conv.is_owned = false;
43828         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43829         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
43830         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43831         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43832         CVec_u8Z_free(ret_var);
43833         return ret_arr;
43834 }
43835
43836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43837         LDKu8slice ser_ref;
43838         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43839         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43840         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
43841         *ret_conv = RoutingFees_read(ser_ref);
43842         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43843         return (int64_t)ret_conv;
43844 }
43845
43846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43847         LDKNodeAnnouncementInfo this_obj_conv;
43848         this_obj_conv.inner = (void*)(this_obj & (~1));
43849         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43851         NodeAnnouncementInfo_free(this_obj_conv);
43852 }
43853
43854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43855         LDKNodeAnnouncementInfo this_ptr_conv;
43856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43857         this_ptr_conv.is_owned = false;
43858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43859         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
43860         int64_t ret_ref = 0;
43861         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43862         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43864         ret_ref = (uintptr_t)ret_var.inner;
43865         if (ret_var.is_owned) {
43866                 ret_ref |= 1;
43867         }
43868         return ret_ref;
43869 }
43870
43871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43872         LDKNodeAnnouncementInfo this_ptr_conv;
43873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43874         this_ptr_conv.is_owned = false;
43875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43876         LDKNodeFeatures val_conv;
43877         val_conv.inner = (void*)(val & (~1));
43878         val_conv.is_owned = (val & 1) || (val == 0);
43879         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43880         val_conv = NodeFeatures_clone(&val_conv);
43881         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
43882 }
43883
43884 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
43885         LDKNodeAnnouncementInfo this_ptr_conv;
43886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43887         this_ptr_conv.is_owned = false;
43888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43889         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
43890         return ret_conv;
43891 }
43892
43893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43894         LDKNodeAnnouncementInfo this_ptr_conv;
43895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43896         this_ptr_conv.is_owned = false;
43897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43898         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
43899 }
43900
43901 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
43902         LDKNodeAnnouncementInfo this_ptr_conv;
43903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43904         this_ptr_conv.is_owned = false;
43905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43906         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
43907         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
43908         return ret_arr;
43909 }
43910
43911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43912         LDKNodeAnnouncementInfo this_ptr_conv;
43913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43914         this_ptr_conv.is_owned = false;
43915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43916         LDKThreeBytes val_ref;
43917         CHECK((*env)->GetArrayLength(env, val) == 3);
43918         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
43919         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
43920 }
43921
43922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
43923         LDKNodeAnnouncementInfo this_ptr_conv;
43924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43925         this_ptr_conv.is_owned = false;
43926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43927         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_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_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43940         LDKNodeAnnouncementInfo this_ptr_conv;
43941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43942         this_ptr_conv.is_owned = false;
43943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43944         LDKNodeAlias val_conv;
43945         val_conv.inner = (void*)(val & (~1));
43946         val_conv.is_owned = (val & 1) || (val == 0);
43947         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43948         val_conv = NodeAlias_clone(&val_conv);
43949         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
43950 }
43951
43952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
43953         LDKNodeAnnouncementInfo this_ptr_conv;
43954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43955         this_ptr_conv.is_owned = false;
43956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43957         LDKCVec_NetAddressZ val_constr;
43958         val_constr.datalen = (*env)->GetArrayLength(env, val);
43959         if (val_constr.datalen > 0)
43960                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
43961         else
43962                 val_constr.data = NULL;
43963         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
43964         for (size_t m = 0; m < val_constr.datalen; m++) {
43965                 int64_t val_conv_12 = val_vals[m];
43966                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
43967                 CHECK_ACCESS(val_conv_12_ptr);
43968                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
43969                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
43970                 val_constr.data[m] = val_conv_12_conv;
43971         }
43972         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
43973         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
43974 }
43975
43976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
43977         LDKNodeAnnouncementInfo this_ptr_conv;
43978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43979         this_ptr_conv.is_owned = false;
43980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43981         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
43982         int64_t ret_ref = 0;
43983         if ((uintptr_t)ret_var.inner > 4096) {
43984                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43985                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43987                 ret_ref = (uintptr_t)ret_var.inner;
43988                 if (ret_var.is_owned) {
43989                         ret_ref |= 1;
43990                 }
43991         }
43992         return ret_ref;
43993 }
43994
43995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43996         LDKNodeAnnouncementInfo this_ptr_conv;
43997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43998         this_ptr_conv.is_owned = false;
43999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44000         LDKNodeAnnouncement val_conv;
44001         val_conv.inner = (void*)(val & (~1));
44002         val_conv.is_owned = (val & 1) || (val == 0);
44003         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44004         val_conv = NodeAnnouncement_clone(&val_conv);
44005         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
44006 }
44007
44008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int64_t alias_arg, int64_tArray addresses_arg, int64_t announcement_message_arg) {
44009         LDKNodeFeatures features_arg_conv;
44010         features_arg_conv.inner = (void*)(features_arg & (~1));
44011         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
44012         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
44013         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
44014         LDKThreeBytes rgb_arg_ref;
44015         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
44016         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
44017         LDKNodeAlias alias_arg_conv;
44018         alias_arg_conv.inner = (void*)(alias_arg & (~1));
44019         alias_arg_conv.is_owned = (alias_arg & 1) || (alias_arg == 0);
44020         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
44021         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
44022         LDKCVec_NetAddressZ addresses_arg_constr;
44023         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
44024         if (addresses_arg_constr.datalen > 0)
44025                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
44026         else
44027                 addresses_arg_constr.data = NULL;
44028         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
44029         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
44030                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
44031                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
44032                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
44033                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
44034                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
44035         }
44036         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
44037         LDKNodeAnnouncement announcement_message_arg_conv;
44038         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
44039         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
44040         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
44041         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
44042         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
44043         int64_t ret_ref = 0;
44044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44047         ret_ref = (uintptr_t)ret_var.inner;
44048         if (ret_var.is_owned) {
44049                 ret_ref |= 1;
44050         }
44051         return ret_ref;
44052 }
44053
44054 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
44055         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
44056 int64_t ret_ref = 0;
44057 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44058 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44059 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44060 ret_ref = (uintptr_t)ret_var.inner;
44061 if (ret_var.is_owned) {
44062         ret_ref |= 1;
44063 }
44064         return ret_ref;
44065 }
44066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44067         LDKNodeAnnouncementInfo arg_conv;
44068         arg_conv.inner = (void*)(arg & (~1));
44069         arg_conv.is_owned = false;
44070         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44071         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
44072         return ret_conv;
44073 }
44074
44075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44076         LDKNodeAnnouncementInfo orig_conv;
44077         orig_conv.inner = (void*)(orig & (~1));
44078         orig_conv.is_owned = false;
44079         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44080         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
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
44092 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
44093         LDKNodeAnnouncementInfo obj_conv;
44094         obj_conv.inner = (void*)(obj & (~1));
44095         obj_conv.is_owned = false;
44096         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44097         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
44098         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44099         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44100         CVec_u8Z_free(ret_var);
44101         return ret_arr;
44102 }
44103
44104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44105         LDKu8slice ser_ref;
44106         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44107         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44108         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
44109         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
44110         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44111         return (int64_t)ret_conv;
44112 }
44113
44114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44115         LDKNodeAlias this_obj_conv;
44116         this_obj_conv.inner = (void*)(this_obj & (~1));
44117         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44119         NodeAlias_free(this_obj_conv);
44120 }
44121
44122 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
44123         LDKNodeAlias this_ptr_conv;
44124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44125         this_ptr_conv.is_owned = false;
44126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44127         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44128         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAlias_get_a(&this_ptr_conv));
44129         return ret_arr;
44130 }
44131
44132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44133         LDKNodeAlias this_ptr_conv;
44134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44135         this_ptr_conv.is_owned = false;
44136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44137         LDKThirtyTwoBytes val_ref;
44138         CHECK((*env)->GetArrayLength(env, val) == 32);
44139         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
44140         NodeAlias_set_a(&this_ptr_conv, val_ref);
44141 }
44142
44143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
44144         LDKThirtyTwoBytes a_arg_ref;
44145         CHECK((*env)->GetArrayLength(env, a_arg) == 32);
44146         (*env)->GetByteArrayRegion(env, a_arg, 0, 32, a_arg_ref.data);
44147         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
44148         int64_t ret_ref = 0;
44149         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44150         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44152         ret_ref = (uintptr_t)ret_var.inner;
44153         if (ret_var.is_owned) {
44154                 ret_ref |= 1;
44155         }
44156         return ret_ref;
44157 }
44158
44159 static inline uintptr_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
44160         LDKNodeAlias ret_var = NodeAlias_clone(arg);
44161 int64_t ret_ref = 0;
44162 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44163 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44164 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44165 ret_ref = (uintptr_t)ret_var.inner;
44166 if (ret_var.is_owned) {
44167         ret_ref |= 1;
44168 }
44169         return ret_ref;
44170 }
44171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44172         LDKNodeAlias arg_conv;
44173         arg_conv.inner = (void*)(arg & (~1));
44174         arg_conv.is_owned = false;
44175         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44176         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
44177         return ret_conv;
44178 }
44179
44180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44181         LDKNodeAlias orig_conv;
44182         orig_conv.inner = (void*)(orig & (~1));
44183         orig_conv.is_owned = false;
44184         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44185         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
44186         int64_t ret_ref = 0;
44187         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44188         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44190         ret_ref = (uintptr_t)ret_var.inner;
44191         if (ret_var.is_owned) {
44192                 ret_ref |= 1;
44193         }
44194         return ret_ref;
44195 }
44196
44197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1write(JNIEnv *env, jclass clz, int64_t obj) {
44198         LDKNodeAlias obj_conv;
44199         obj_conv.inner = (void*)(obj & (~1));
44200         obj_conv.is_owned = false;
44201         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44202         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
44203         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44204         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44205         CVec_u8Z_free(ret_var);
44206         return ret_arr;
44207 }
44208
44209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44210         LDKu8slice ser_ref;
44211         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44212         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44213         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
44214         *ret_conv = NodeAlias_read(ser_ref);
44215         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44216         return (int64_t)ret_conv;
44217 }
44218
44219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44220         LDKNodeInfo this_obj_conv;
44221         this_obj_conv.inner = (void*)(this_obj & (~1));
44222         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44224         NodeInfo_free(this_obj_conv);
44225 }
44226
44227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
44228         LDKNodeInfo this_ptr_conv;
44229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44230         this_ptr_conv.is_owned = false;
44231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44232         LDKCVec_u64Z val_constr;
44233         val_constr.datalen = (*env)->GetArrayLength(env, val);
44234         if (val_constr.datalen > 0)
44235                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
44236         else
44237                 val_constr.data = NULL;
44238         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
44239         for (size_t g = 0; g < val_constr.datalen; g++) {
44240                 int64_t val_conv_6 = val_vals[g];
44241                 val_constr.data[g] = val_conv_6;
44242         }
44243         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
44244         NodeInfo_set_channels(&this_ptr_conv, val_constr);
44245 }
44246
44247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
44248         LDKNodeInfo this_ptr_conv;
44249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44250         this_ptr_conv.is_owned = false;
44251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44252         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
44253         int64_t ret_ref = 0;
44254         if ((uintptr_t)ret_var.inner > 4096) {
44255                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44256                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44258                 ret_ref = (uintptr_t)ret_var.inner;
44259                 if (ret_var.is_owned) {
44260                         ret_ref |= 1;
44261                 }
44262         }
44263         return ret_ref;
44264 }
44265
44266 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) {
44267         LDKNodeInfo this_ptr_conv;
44268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44269         this_ptr_conv.is_owned = false;
44270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44271         LDKRoutingFees val_conv;
44272         val_conv.inner = (void*)(val & (~1));
44273         val_conv.is_owned = (val & 1) || (val == 0);
44274         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44275         val_conv = RoutingFees_clone(&val_conv);
44276         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
44277 }
44278
44279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
44280         LDKNodeInfo this_ptr_conv;
44281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44282         this_ptr_conv.is_owned = false;
44283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44284         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
44285         int64_t ret_ref = 0;
44286         if ((uintptr_t)ret_var.inner > 4096) {
44287                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44288                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44290                 ret_ref = (uintptr_t)ret_var.inner;
44291                 if (ret_var.is_owned) {
44292                         ret_ref |= 1;
44293                 }
44294         }
44295         return ret_ref;
44296 }
44297
44298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44299         LDKNodeInfo this_ptr_conv;
44300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44301         this_ptr_conv.is_owned = false;
44302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44303         LDKNodeAnnouncementInfo val_conv;
44304         val_conv.inner = (void*)(val & (~1));
44305         val_conv.is_owned = (val & 1) || (val == 0);
44306         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44307         val_conv = NodeAnnouncementInfo_clone(&val_conv);
44308         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
44309 }
44310
44311 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) {
44312         LDKCVec_u64Z channels_arg_constr;
44313         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
44314         if (channels_arg_constr.datalen > 0)
44315                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
44316         else
44317                 channels_arg_constr.data = NULL;
44318         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
44319         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
44320                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
44321                 channels_arg_constr.data[g] = channels_arg_conv_6;
44322         }
44323         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
44324         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
44325         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
44326         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
44327         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
44328         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
44329         LDKNodeAnnouncementInfo announcement_info_arg_conv;
44330         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
44331         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
44332         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
44333         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
44334         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
44335         int64_t ret_ref = 0;
44336         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44337         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44339         ret_ref = (uintptr_t)ret_var.inner;
44340         if (ret_var.is_owned) {
44341                 ret_ref |= 1;
44342         }
44343         return ret_ref;
44344 }
44345
44346 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
44347         LDKNodeInfo ret_var = NodeInfo_clone(arg);
44348 int64_t ret_ref = 0;
44349 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44350 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44351 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44352 ret_ref = (uintptr_t)ret_var.inner;
44353 if (ret_var.is_owned) {
44354         ret_ref |= 1;
44355 }
44356         return ret_ref;
44357 }
44358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44359         LDKNodeInfo arg_conv;
44360         arg_conv.inner = (void*)(arg & (~1));
44361         arg_conv.is_owned = false;
44362         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44363         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
44364         return ret_conv;
44365 }
44366
44367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44368         LDKNodeInfo orig_conv;
44369         orig_conv.inner = (void*)(orig & (~1));
44370         orig_conv.is_owned = false;
44371         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44372         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
44373         int64_t ret_ref = 0;
44374         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44375         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44377         ret_ref = (uintptr_t)ret_var.inner;
44378         if (ret_var.is_owned) {
44379                 ret_ref |= 1;
44380         }
44381         return ret_ref;
44382 }
44383
44384 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
44385         LDKNodeInfo obj_conv;
44386         obj_conv.inner = (void*)(obj & (~1));
44387         obj_conv.is_owned = false;
44388         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44389         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
44390         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44391         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44392         CVec_u8Z_free(ret_var);
44393         return ret_arr;
44394 }
44395
44396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44397         LDKu8slice ser_ref;
44398         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44399         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44400         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
44401         *ret_conv = NodeInfo_read(ser_ref);
44402         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44403         return (int64_t)ret_conv;
44404 }
44405
44406 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
44407         LDKNetworkGraph obj_conv;
44408         obj_conv.inner = (void*)(obj & (~1));
44409         obj_conv.is_owned = false;
44410         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44411         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
44412         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44413         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44414         CVec_u8Z_free(ret_var);
44415         return ret_arr;
44416 }
44417
44418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
44419         LDKu8slice ser_ref;
44420         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44421         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44422         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
44423         CHECK_ACCESS(arg_ptr);
44424         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
44425         if (arg_conv.free == LDKLogger_JCalls_free) {
44426                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44427                 LDKLogger_JCalls_cloned(&arg_conv);
44428         }
44429         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
44430         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
44431         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44432         return (int64_t)ret_conv;
44433 }
44434
44435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t logger) {
44436         LDKThirtyTwoBytes genesis_hash_ref;
44437         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
44438         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
44439         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
44440         CHECK_ACCESS(logger_ptr);
44441         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
44442         if (logger_conv.free == LDKLogger_JCalls_free) {
44443                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44444                 LDKLogger_JCalls_cloned(&logger_conv);
44445         }
44446         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
44447         int64_t ret_ref = 0;
44448         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44449         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44451         ret_ref = (uintptr_t)ret_var.inner;
44452         if (ret_var.is_owned) {
44453                 ret_ref |= 1;
44454         }
44455         return ret_ref;
44456 }
44457
44458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
44459         LDKNetworkGraph this_arg_conv;
44460         this_arg_conv.inner = (void*)(this_arg & (~1));
44461         this_arg_conv.is_owned = false;
44462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44463         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
44464         int64_t ret_ref = 0;
44465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44468         ret_ref = (uintptr_t)ret_var.inner;
44469         if (ret_var.is_owned) {
44470                 ret_ref |= 1;
44471         }
44472         return ret_ref;
44473 }
44474
44475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
44476         LDKNetworkGraph this_arg_conv;
44477         this_arg_conv.inner = (void*)(this_arg & (~1));
44478         this_arg_conv.is_owned = false;
44479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44480         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
44481         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
44482         int64_t ret_ref = (uintptr_t)ret_copy;
44483         return ret_ref;
44484 }
44485
44486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1set_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg, int32_t last_rapid_gossip_sync_timestamp) {
44487         LDKNetworkGraph this_arg_conv;
44488         this_arg_conv.inner = (void*)(this_arg & (~1));
44489         this_arg_conv.is_owned = false;
44490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44491         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
44492 }
44493
44494 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) {
44495         LDKNetworkGraph this_arg_conv;
44496         this_arg_conv.inner = (void*)(this_arg & (~1));
44497         this_arg_conv.is_owned = false;
44498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44499         LDKNodeAnnouncement msg_conv;
44500         msg_conv.inner = (void*)(msg & (~1));
44501         msg_conv.is_owned = false;
44502         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44503         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44504         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
44505         return (int64_t)ret_conv;
44506 }
44507
44508 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) {
44509         LDKNetworkGraph this_arg_conv;
44510         this_arg_conv.inner = (void*)(this_arg & (~1));
44511         this_arg_conv.is_owned = false;
44512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44513         LDKUnsignedNodeAnnouncement msg_conv;
44514         msg_conv.inner = (void*)(msg & (~1));
44515         msg_conv.is_owned = false;
44516         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44517         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44518         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
44519         return (int64_t)ret_conv;
44520 }
44521
44522 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) {
44523         LDKNetworkGraph this_arg_conv;
44524         this_arg_conv.inner = (void*)(this_arg & (~1));
44525         this_arg_conv.is_owned = false;
44526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44527         LDKChannelAnnouncement msg_conv;
44528         msg_conv.inner = (void*)(msg & (~1));
44529         msg_conv.is_owned = false;
44530         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44531         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
44532         CHECK_ACCESS(chain_access_ptr);
44533         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
44534         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
44535         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
44536                 // Manually implement clone for Java trait instances
44537                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
44538                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44539                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
44540                 }
44541         }
44542         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44543         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
44544         return (int64_t)ret_conv;
44545 }
44546
44547 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) {
44548         LDKNetworkGraph this_arg_conv;
44549         this_arg_conv.inner = (void*)(this_arg & (~1));
44550         this_arg_conv.is_owned = false;
44551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44552         LDKUnsignedChannelAnnouncement msg_conv;
44553         msg_conv.inner = (void*)(msg & (~1));
44554         msg_conv.is_owned = false;
44555         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44556         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
44557         CHECK_ACCESS(chain_access_ptr);
44558         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
44559         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
44560         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
44561                 // Manually implement clone for Java trait instances
44562                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
44563                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44564                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
44565                 }
44566         }
44567         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44568         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
44569         return (int64_t)ret_conv;
44570 }
44571
44572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1add_1channel_1from_1partial_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t timestamp, int64_t features, int8_tArray node_id_1, int8_tArray node_id_2) {
44573         LDKNetworkGraph this_arg_conv;
44574         this_arg_conv.inner = (void*)(this_arg & (~1));
44575         this_arg_conv.is_owned = false;
44576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44577         LDKChannelFeatures features_conv;
44578         features_conv.inner = (void*)(features & (~1));
44579         features_conv.is_owned = (features & 1) || (features == 0);
44580         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
44581         features_conv = ChannelFeatures_clone(&features_conv);
44582         LDKPublicKey node_id_1_ref;
44583         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
44584         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
44585         LDKPublicKey node_id_2_ref;
44586         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
44587         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
44588         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44589         *ret_conv = NetworkGraph_add_channel_from_partial_announcement(&this_arg_conv, short_channel_id, timestamp, features_conv, node_id_1_ref, node_id_2_ref);
44590         return (int64_t)ret_conv;
44591 }
44592
44593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1channel_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
44594         LDKNetworkGraph this_arg_conv;
44595         this_arg_conv.inner = (void*)(this_arg & (~1));
44596         this_arg_conv.is_owned = false;
44597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44598         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
44599 }
44600
44601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1node_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
44602         LDKNetworkGraph this_arg_conv;
44603         this_arg_conv.inner = (void*)(this_arg & (~1));
44604         this_arg_conv.is_owned = false;
44605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44606         LDKPublicKey _node_id_ref;
44607         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
44608         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
44609         NetworkGraph_node_failed(&this_arg_conv, _node_id_ref, is_permanent);
44610 }
44611
44612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
44613         LDKNetworkGraph this_arg_conv;
44614         this_arg_conv.inner = (void*)(this_arg & (~1));
44615         this_arg_conv.is_owned = false;
44616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44617         NetworkGraph_remove_stale_channels(&this_arg_conv);
44618 }
44619
44620 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) {
44621         LDKNetworkGraph this_arg_conv;
44622         this_arg_conv.inner = (void*)(this_arg & (~1));
44623         this_arg_conv.is_owned = false;
44624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44625         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
44626 }
44627
44628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
44629         LDKNetworkGraph this_arg_conv;
44630         this_arg_conv.inner = (void*)(this_arg & (~1));
44631         this_arg_conv.is_owned = false;
44632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44633         LDKChannelUpdate msg_conv;
44634         msg_conv.inner = (void*)(msg & (~1));
44635         msg_conv.is_owned = false;
44636         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44637         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44638         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
44639         return (int64_t)ret_conv;
44640 }
44641
44642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
44643         LDKNetworkGraph this_arg_conv;
44644         this_arg_conv.inner = (void*)(this_arg & (~1));
44645         this_arg_conv.is_owned = false;
44646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44647         LDKUnsignedChannelUpdate msg_conv;
44648         msg_conv.inner = (void*)(msg & (~1));
44649         msg_conv.is_owned = false;
44650         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
44651         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
44652         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
44653         return (int64_t)ret_conv;
44654 }
44655
44656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
44657         LDKReadOnlyNetworkGraph this_arg_conv;
44658         this_arg_conv.inner = (void*)(this_arg & (~1));
44659         this_arg_conv.is_owned = false;
44660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44661         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
44662         int64_t ret_ref = 0;
44663         if ((uintptr_t)ret_var.inner > 4096) {
44664                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44665                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44667                 ret_ref = (uintptr_t)ret_var.inner;
44668                 if (ret_var.is_owned) {
44669                         ret_ref |= 1;
44670                 }
44671         }
44672         return ret_ref;
44673 }
44674
44675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1node(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
44676         LDKReadOnlyNetworkGraph this_arg_conv;
44677         this_arg_conv.inner = (void*)(this_arg & (~1));
44678         this_arg_conv.is_owned = false;
44679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44680         LDKNodeId node_id_conv;
44681         node_id_conv.inner = (void*)(node_id & (~1));
44682         node_id_conv.is_owned = false;
44683         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
44684         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
44685         int64_t ret_ref = 0;
44686         if ((uintptr_t)ret_var.inner > 4096) {
44687                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44688                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44690                 ret_ref = (uintptr_t)ret_var.inner;
44691                 if (ret_var.is_owned) {
44692                         ret_ref |= 1;
44693                 }
44694         }
44695         return ret_ref;
44696 }
44697
44698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
44699         LDKReadOnlyNetworkGraph this_arg_conv;
44700         this_arg_conv.inner = (void*)(this_arg & (~1));
44701         this_arg_conv.is_owned = false;
44702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44703         LDKPublicKey pubkey_ref;
44704         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
44705         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
44706         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
44707         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
44708         int64_t ret_ref = (uintptr_t)ret_copy;
44709         return ret_ref;
44710 }
44711
44712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44713         LDKRouteHop this_obj_conv;
44714         this_obj_conv.inner = (void*)(this_obj & (~1));
44715         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44717         RouteHop_free(this_obj_conv);
44718 }
44719
44720 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
44721         LDKRouteHop this_ptr_conv;
44722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44723         this_ptr_conv.is_owned = false;
44724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44725         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44726         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
44727         return ret_arr;
44728 }
44729
44730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44731         LDKRouteHop this_ptr_conv;
44732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44733         this_ptr_conv.is_owned = false;
44734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44735         LDKPublicKey val_ref;
44736         CHECK((*env)->GetArrayLength(env, val) == 33);
44737         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
44738         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
44739 }
44740
44741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
44742         LDKRouteHop this_ptr_conv;
44743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44744         this_ptr_conv.is_owned = false;
44745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44746         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
44747         int64_t ret_ref = 0;
44748         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44749         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44751         ret_ref = (uintptr_t)ret_var.inner;
44752         if (ret_var.is_owned) {
44753                 ret_ref |= 1;
44754         }
44755         return ret_ref;
44756 }
44757
44758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44759         LDKRouteHop this_ptr_conv;
44760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44761         this_ptr_conv.is_owned = false;
44762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44763         LDKNodeFeatures val_conv;
44764         val_conv.inner = (void*)(val & (~1));
44765         val_conv.is_owned = (val & 1) || (val == 0);
44766         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44767         val_conv = NodeFeatures_clone(&val_conv);
44768         RouteHop_set_node_features(&this_ptr_conv, val_conv);
44769 }
44770
44771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
44772         LDKRouteHop this_ptr_conv;
44773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44774         this_ptr_conv.is_owned = false;
44775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44776         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
44777         return ret_conv;
44778 }
44779
44780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44781         LDKRouteHop this_ptr_conv;
44782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44783         this_ptr_conv.is_owned = false;
44784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44785         RouteHop_set_short_channel_id(&this_ptr_conv, val);
44786 }
44787
44788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
44789         LDKRouteHop this_ptr_conv;
44790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44791         this_ptr_conv.is_owned = false;
44792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44793         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
44794         int64_t ret_ref = 0;
44795         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44796         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44798         ret_ref = (uintptr_t)ret_var.inner;
44799         if (ret_var.is_owned) {
44800                 ret_ref |= 1;
44801         }
44802         return ret_ref;
44803 }
44804
44805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44806         LDKRouteHop this_ptr_conv;
44807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44808         this_ptr_conv.is_owned = false;
44809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44810         LDKChannelFeatures val_conv;
44811         val_conv.inner = (void*)(val & (~1));
44812         val_conv.is_owned = (val & 1) || (val == 0);
44813         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44814         val_conv = ChannelFeatures_clone(&val_conv);
44815         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
44816 }
44817
44818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44819         LDKRouteHop this_ptr_conv;
44820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44821         this_ptr_conv.is_owned = false;
44822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44823         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
44824         return ret_conv;
44825 }
44826
44827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44828         LDKRouteHop this_ptr_conv;
44829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44830         this_ptr_conv.is_owned = false;
44831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44832         RouteHop_set_fee_msat(&this_ptr_conv, val);
44833 }
44834
44835 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
44836         LDKRouteHop this_ptr_conv;
44837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44838         this_ptr_conv.is_owned = false;
44839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44840         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
44841         return ret_conv;
44842 }
44843
44844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
44845         LDKRouteHop this_ptr_conv;
44846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44847         this_ptr_conv.is_owned = false;
44848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44849         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
44850 }
44851
44852 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) {
44853         LDKPublicKey pubkey_arg_ref;
44854         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
44855         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
44856         LDKNodeFeatures node_features_arg_conv;
44857         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
44858         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
44859         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
44860         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
44861         LDKChannelFeatures channel_features_arg_conv;
44862         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
44863         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
44864         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
44865         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
44866         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);
44867         int64_t ret_ref = 0;
44868         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44869         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44871         ret_ref = (uintptr_t)ret_var.inner;
44872         if (ret_var.is_owned) {
44873                 ret_ref |= 1;
44874         }
44875         return ret_ref;
44876 }
44877
44878 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
44879         LDKRouteHop ret_var = RouteHop_clone(arg);
44880 int64_t ret_ref = 0;
44881 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44882 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44883 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44884 ret_ref = (uintptr_t)ret_var.inner;
44885 if (ret_var.is_owned) {
44886         ret_ref |= 1;
44887 }
44888         return ret_ref;
44889 }
44890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44891         LDKRouteHop arg_conv;
44892         arg_conv.inner = (void*)(arg & (~1));
44893         arg_conv.is_owned = false;
44894         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44895         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
44896         return ret_conv;
44897 }
44898
44899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44900         LDKRouteHop orig_conv;
44901         orig_conv.inner = (void*)(orig & (~1));
44902         orig_conv.is_owned = false;
44903         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44904         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
44905         int64_t ret_ref = 0;
44906         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44907         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44909         ret_ref = (uintptr_t)ret_var.inner;
44910         if (ret_var.is_owned) {
44911                 ret_ref |= 1;
44912         }
44913         return ret_ref;
44914 }
44915
44916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
44917         LDKRouteHop o_conv;
44918         o_conv.inner = (void*)(o & (~1));
44919         o_conv.is_owned = false;
44920         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44921         int64_t ret_conv = RouteHop_hash(&o_conv);
44922         return ret_conv;
44923 }
44924
44925 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44926         LDKRouteHop a_conv;
44927         a_conv.inner = (void*)(a & (~1));
44928         a_conv.is_owned = false;
44929         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44930         LDKRouteHop b_conv;
44931         b_conv.inner = (void*)(b & (~1));
44932         b_conv.is_owned = false;
44933         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44934         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
44935         return ret_conv;
44936 }
44937
44938 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
44939         LDKRouteHop obj_conv;
44940         obj_conv.inner = (void*)(obj & (~1));
44941         obj_conv.is_owned = false;
44942         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44943         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
44944         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44945         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44946         CVec_u8Z_free(ret_var);
44947         return ret_arr;
44948 }
44949
44950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44951         LDKu8slice ser_ref;
44952         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44953         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44954         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
44955         *ret_conv = RouteHop_read(ser_ref);
44956         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44957         return (int64_t)ret_conv;
44958 }
44959
44960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44961         LDKRoute this_obj_conv;
44962         this_obj_conv.inner = (void*)(this_obj & (~1));
44963         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44965         Route_free(this_obj_conv);
44966 }
44967
44968 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
44969         LDKRoute this_ptr_conv;
44970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44971         this_ptr_conv.is_owned = false;
44972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44973         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
44974         jobjectArray ret_arr = NULL;
44975         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
44976         ;
44977         for (size_t m = 0; m < ret_var.datalen; m++) {
44978                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
44979                 int64_tArray ret_conv_12_arr = NULL;
44980                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
44981                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
44982                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
44983                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
44984                         int64_t ret_conv_12_conv_10_ref = 0;
44985                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44986                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44987                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
44988                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
44989                         if (ret_conv_12_conv_10_var.is_owned) {
44990                                 ret_conv_12_conv_10_ref |= 1;
44991                         }
44992                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
44993                 }
44994                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
44995                 FREE(ret_conv_12_var.data);
44996                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
44997         }
44998         
44999         FREE(ret_var.data);
45000         return ret_arr;
45001 }
45002
45003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
45004         LDKRoute this_ptr_conv;
45005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45006         this_ptr_conv.is_owned = false;
45007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45008         LDKCVec_CVec_RouteHopZZ val_constr;
45009         val_constr.datalen = (*env)->GetArrayLength(env, val);
45010         if (val_constr.datalen > 0)
45011                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
45012         else
45013                 val_constr.data = NULL;
45014         for (size_t m = 0; m < val_constr.datalen; m++) {
45015                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
45016                 LDKCVec_RouteHopZ val_conv_12_constr;
45017                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
45018                 if (val_conv_12_constr.datalen > 0)
45019                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
45020                 else
45021                         val_conv_12_constr.data = NULL;
45022                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
45023                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
45024                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
45025                         LDKRouteHop val_conv_12_conv_10_conv;
45026                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
45027                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
45028                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
45029                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
45030                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
45031                 }
45032                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
45033                 val_constr.data[m] = val_conv_12_constr;
45034         }
45035         Route_set_paths(&this_ptr_conv, val_constr);
45036 }
45037
45038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
45039         LDKRoute this_ptr_conv;
45040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45041         this_ptr_conv.is_owned = false;
45042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45043         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
45044         int64_t ret_ref = 0;
45045         if ((uintptr_t)ret_var.inner > 4096) {
45046                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45047                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45049                 ret_ref = (uintptr_t)ret_var.inner;
45050                 if (ret_var.is_owned) {
45051                         ret_ref |= 1;
45052                 }
45053         }
45054         return ret_ref;
45055 }
45056
45057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45058         LDKRoute this_ptr_conv;
45059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45060         this_ptr_conv.is_owned = false;
45061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45062         LDKPaymentParameters val_conv;
45063         val_conv.inner = (void*)(val & (~1));
45064         val_conv.is_owned = (val & 1) || (val == 0);
45065         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45066         val_conv = PaymentParameters_clone(&val_conv);
45067         Route_set_payment_params(&this_ptr_conv, val_conv);
45068 }
45069
45070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
45071         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
45072         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
45073         if (paths_arg_constr.datalen > 0)
45074                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
45075         else
45076                 paths_arg_constr.data = NULL;
45077         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
45078                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
45079                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
45080                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
45081                 if (paths_arg_conv_12_constr.datalen > 0)
45082                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
45083                 else
45084                         paths_arg_conv_12_constr.data = NULL;
45085                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
45086                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
45087                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
45088                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
45089                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
45090                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
45091                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
45092                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
45093                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
45094                 }
45095                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
45096                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
45097         }
45098         LDKPaymentParameters payment_params_arg_conv;
45099         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
45100         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
45101         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
45102         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
45103         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
45104         int64_t ret_ref = 0;
45105         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45106         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45108         ret_ref = (uintptr_t)ret_var.inner;
45109         if (ret_var.is_owned) {
45110                 ret_ref |= 1;
45111         }
45112         return ret_ref;
45113 }
45114
45115 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
45116         LDKRoute ret_var = Route_clone(arg);
45117 int64_t ret_ref = 0;
45118 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45119 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45120 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45121 ret_ref = (uintptr_t)ret_var.inner;
45122 if (ret_var.is_owned) {
45123         ret_ref |= 1;
45124 }
45125         return ret_ref;
45126 }
45127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45128         LDKRoute arg_conv;
45129         arg_conv.inner = (void*)(arg & (~1));
45130         arg_conv.is_owned = false;
45131         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45132         int64_t ret_conv = Route_clone_ptr(&arg_conv);
45133         return ret_conv;
45134 }
45135
45136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45137         LDKRoute orig_conv;
45138         orig_conv.inner = (void*)(orig & (~1));
45139         orig_conv.is_owned = false;
45140         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45141         LDKRoute ret_var = Route_clone(&orig_conv);
45142         int64_t ret_ref = 0;
45143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45146         ret_ref = (uintptr_t)ret_var.inner;
45147         if (ret_var.is_owned) {
45148                 ret_ref |= 1;
45149         }
45150         return ret_ref;
45151 }
45152
45153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
45154         LDKRoute o_conv;
45155         o_conv.inner = (void*)(o & (~1));
45156         o_conv.is_owned = false;
45157         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45158         int64_t ret_conv = Route_hash(&o_conv);
45159         return ret_conv;
45160 }
45161
45162 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45163         LDKRoute a_conv;
45164         a_conv.inner = (void*)(a & (~1));
45165         a_conv.is_owned = false;
45166         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45167         LDKRoute b_conv;
45168         b_conv.inner = (void*)(b & (~1));
45169         b_conv.is_owned = false;
45170         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45171         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
45172         return ret_conv;
45173 }
45174
45175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
45176         LDKRoute this_arg_conv;
45177         this_arg_conv.inner = (void*)(this_arg & (~1));
45178         this_arg_conv.is_owned = false;
45179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45180         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
45181         return ret_conv;
45182 }
45183
45184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
45185         LDKRoute this_arg_conv;
45186         this_arg_conv.inner = (void*)(this_arg & (~1));
45187         this_arg_conv.is_owned = false;
45188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45189         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
45190         return ret_conv;
45191 }
45192
45193 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
45194         LDKRoute obj_conv;
45195         obj_conv.inner = (void*)(obj & (~1));
45196         obj_conv.is_owned = false;
45197         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45198         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
45199         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45200         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45201         CVec_u8Z_free(ret_var);
45202         return ret_arr;
45203 }
45204
45205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45206         LDKu8slice ser_ref;
45207         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45208         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45209         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
45210         *ret_conv = Route_read(ser_ref);
45211         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45212         return (int64_t)ret_conv;
45213 }
45214
45215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45216         LDKRouteParameters this_obj_conv;
45217         this_obj_conv.inner = (void*)(this_obj & (~1));
45218         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45220         RouteParameters_free(this_obj_conv);
45221 }
45222
45223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
45224         LDKRouteParameters this_ptr_conv;
45225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45226         this_ptr_conv.is_owned = false;
45227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45228         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
45229         int64_t ret_ref = 0;
45230         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45231         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45233         ret_ref = (uintptr_t)ret_var.inner;
45234         if (ret_var.is_owned) {
45235                 ret_ref |= 1;
45236         }
45237         return ret_ref;
45238 }
45239
45240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45241         LDKRouteParameters this_ptr_conv;
45242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45243         this_ptr_conv.is_owned = false;
45244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45245         LDKPaymentParameters val_conv;
45246         val_conv.inner = (void*)(val & (~1));
45247         val_conv.is_owned = (val & 1) || (val == 0);
45248         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45249         val_conv = PaymentParameters_clone(&val_conv);
45250         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
45251 }
45252
45253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45254         LDKRouteParameters this_ptr_conv;
45255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45256         this_ptr_conv.is_owned = false;
45257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45258         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
45259         return ret_conv;
45260 }
45261
45262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45263         LDKRouteParameters this_ptr_conv;
45264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45265         this_ptr_conv.is_owned = false;
45266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45267         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
45268 }
45269
45270 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
45271         LDKRouteParameters this_ptr_conv;
45272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45273         this_ptr_conv.is_owned = false;
45274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45275         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
45276         return ret_conv;
45277 }
45278
45279 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) {
45280         LDKRouteParameters this_ptr_conv;
45281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45282         this_ptr_conv.is_owned = false;
45283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45284         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
45285 }
45286
45287 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) {
45288         LDKPaymentParameters payment_params_arg_conv;
45289         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
45290         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
45291         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
45292         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
45293         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
45294         int64_t ret_ref = 0;
45295         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45296         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45298         ret_ref = (uintptr_t)ret_var.inner;
45299         if (ret_var.is_owned) {
45300                 ret_ref |= 1;
45301         }
45302         return ret_ref;
45303 }
45304
45305 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
45306         LDKRouteParameters ret_var = RouteParameters_clone(arg);
45307 int64_t ret_ref = 0;
45308 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45309 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45310 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45311 ret_ref = (uintptr_t)ret_var.inner;
45312 if (ret_var.is_owned) {
45313         ret_ref |= 1;
45314 }
45315         return ret_ref;
45316 }
45317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45318         LDKRouteParameters arg_conv;
45319         arg_conv.inner = (void*)(arg & (~1));
45320         arg_conv.is_owned = false;
45321         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45322         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
45323         return ret_conv;
45324 }
45325
45326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45327         LDKRouteParameters orig_conv;
45328         orig_conv.inner = (void*)(orig & (~1));
45329         orig_conv.is_owned = false;
45330         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45331         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
45332         int64_t ret_ref = 0;
45333         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45334         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45336         ret_ref = (uintptr_t)ret_var.inner;
45337         if (ret_var.is_owned) {
45338                 ret_ref |= 1;
45339         }
45340         return ret_ref;
45341 }
45342
45343 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
45344         LDKRouteParameters obj_conv;
45345         obj_conv.inner = (void*)(obj & (~1));
45346         obj_conv.is_owned = false;
45347         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45348         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
45349         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45350         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45351         CVec_u8Z_free(ret_var);
45352         return ret_arr;
45353 }
45354
45355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45356         LDKu8slice ser_ref;
45357         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45358         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45359         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
45360         *ret_conv = RouteParameters_read(ser_ref);
45361         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45362         return (int64_t)ret_conv;
45363 }
45364
45365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45366         LDKPaymentParameters this_obj_conv;
45367         this_obj_conv.inner = (void*)(this_obj & (~1));
45368         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45370         PaymentParameters_free(this_obj_conv);
45371 }
45372
45373 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
45374         LDKPaymentParameters this_ptr_conv;
45375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45376         this_ptr_conv.is_owned = false;
45377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45378         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45379         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
45380         return ret_arr;
45381 }
45382
45383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
45384         LDKPaymentParameters this_ptr_conv;
45385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45386         this_ptr_conv.is_owned = false;
45387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45388         LDKPublicKey val_ref;
45389         CHECK((*env)->GetArrayLength(env, val) == 33);
45390         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
45391         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
45392 }
45393
45394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
45395         LDKPaymentParameters this_ptr_conv;
45396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45397         this_ptr_conv.is_owned = false;
45398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45399         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
45400         int64_t ret_ref = 0;
45401         if ((uintptr_t)ret_var.inner > 4096) {
45402                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45403                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45405                 ret_ref = (uintptr_t)ret_var.inner;
45406                 if (ret_var.is_owned) {
45407                         ret_ref |= 1;
45408                 }
45409         }
45410         return ret_ref;
45411 }
45412
45413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45414         LDKPaymentParameters this_ptr_conv;
45415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45416         this_ptr_conv.is_owned = false;
45417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45418         LDKInvoiceFeatures val_conv;
45419         val_conv.inner = (void*)(val & (~1));
45420         val_conv.is_owned = (val & 1) || (val == 0);
45421         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45422         val_conv = InvoiceFeatures_clone(&val_conv);
45423         PaymentParameters_set_features(&this_ptr_conv, val_conv);
45424 }
45425
45426 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
45427         LDKPaymentParameters this_ptr_conv;
45428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45429         this_ptr_conv.is_owned = false;
45430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45431         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
45432         int64_tArray ret_arr = NULL;
45433         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45434         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45435         for (size_t l = 0; l < ret_var.datalen; l++) {
45436                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
45437                 int64_t ret_conv_11_ref = 0;
45438                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45439                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45440                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
45441                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
45442                 if (ret_conv_11_var.is_owned) {
45443                         ret_conv_11_ref |= 1;
45444                 }
45445                 ret_arr_ptr[l] = ret_conv_11_ref;
45446         }
45447         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45448         FREE(ret_var.data);
45449         return ret_arr;
45450 }
45451
45452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
45453         LDKPaymentParameters this_ptr_conv;
45454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45455         this_ptr_conv.is_owned = false;
45456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45457         LDKCVec_RouteHintZ val_constr;
45458         val_constr.datalen = (*env)->GetArrayLength(env, val);
45459         if (val_constr.datalen > 0)
45460                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
45461         else
45462                 val_constr.data = NULL;
45463         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
45464         for (size_t l = 0; l < val_constr.datalen; l++) {
45465                 int64_t val_conv_11 = val_vals[l];
45466                 LDKRouteHint val_conv_11_conv;
45467                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
45468                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
45469                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
45470                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
45471                 val_constr.data[l] = val_conv_11_conv;
45472         }
45473         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
45474         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
45475 }
45476
45477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
45478         LDKPaymentParameters this_ptr_conv;
45479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45480         this_ptr_conv.is_owned = false;
45481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45482         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45483         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
45484         int64_t ret_ref = (uintptr_t)ret_copy;
45485         return ret_ref;
45486 }
45487
45488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45489         LDKPaymentParameters this_ptr_conv;
45490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45491         this_ptr_conv.is_owned = false;
45492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45493         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
45494         CHECK_ACCESS(val_ptr);
45495         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
45496         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
45497         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
45498 }
45499
45500 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
45501         LDKPaymentParameters this_ptr_conv;
45502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45503         this_ptr_conv.is_owned = false;
45504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45505         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
45506         return ret_conv;
45507 }
45508
45509 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) {
45510         LDKPaymentParameters this_ptr_conv;
45511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45512         this_ptr_conv.is_owned = false;
45513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45514         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
45515 }
45516
45517 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr) {
45518         LDKPaymentParameters this_ptr_conv;
45519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45520         this_ptr_conv.is_owned = false;
45521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45522         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
45523         return ret_conv;
45524 }
45525
45526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
45527         LDKPaymentParameters this_ptr_conv;
45528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45529         this_ptr_conv.is_owned = false;
45530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45531         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
45532 }
45533
45534 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1channel_1saturation_1power_1of_1half(JNIEnv *env, jclass clz, int64_t this_ptr) {
45535         LDKPaymentParameters this_ptr_conv;
45536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45537         this_ptr_conv.is_owned = false;
45538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45539         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
45540         return ret_conv;
45541 }
45542
45543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1channel_1saturation_1power_1of_1half(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
45544         LDKPaymentParameters this_ptr_conv;
45545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45546         this_ptr_conv.is_owned = false;
45547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45548         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
45549 }
45550
45551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
45552         LDKPaymentParameters this_ptr_conv;
45553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45554         this_ptr_conv.is_owned = false;
45555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45556         LDKCVec_u64Z val_constr;
45557         val_constr.datalen = (*env)->GetArrayLength(env, val);
45558         if (val_constr.datalen > 0)
45559                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
45560         else
45561                 val_constr.data = NULL;
45562         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
45563         for (size_t g = 0; g < val_constr.datalen; g++) {
45564                 int64_t val_conv_6 = val_vals[g];
45565                 val_constr.data[g] = val_conv_6;
45566         }
45567         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
45568         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
45569 }
45570
45571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1new(JNIEnv *env, jclass clz, int8_tArray payee_pubkey_arg, int64_t features_arg, int64_tArray route_hints_arg, int64_t expiry_time_arg, int32_t max_total_cltv_expiry_delta_arg, int8_t max_path_count_arg, int8_t max_channel_saturation_power_of_half_arg, int64_tArray previously_failed_channels_arg) {
45572         LDKPublicKey payee_pubkey_arg_ref;
45573         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
45574         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
45575         LDKInvoiceFeatures features_arg_conv;
45576         features_arg_conv.inner = (void*)(features_arg & (~1));
45577         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
45578         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
45579         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
45580         LDKCVec_RouteHintZ route_hints_arg_constr;
45581         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
45582         if (route_hints_arg_constr.datalen > 0)
45583                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
45584         else
45585                 route_hints_arg_constr.data = NULL;
45586         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
45587         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
45588                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
45589                 LDKRouteHint route_hints_arg_conv_11_conv;
45590                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
45591                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
45592                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
45593                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
45594                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
45595         }
45596         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
45597         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
45598         CHECK_ACCESS(expiry_time_arg_ptr);
45599         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
45600         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
45601         LDKCVec_u64Z previously_failed_channels_arg_constr;
45602         previously_failed_channels_arg_constr.datalen = (*env)->GetArrayLength(env, previously_failed_channels_arg);
45603         if (previously_failed_channels_arg_constr.datalen > 0)
45604                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
45605         else
45606                 previously_failed_channels_arg_constr.data = NULL;
45607         int64_t* previously_failed_channels_arg_vals = (*env)->GetLongArrayElements (env, previously_failed_channels_arg, NULL);
45608         for (size_t g = 0; g < previously_failed_channels_arg_constr.datalen; g++) {
45609                 int64_t previously_failed_channels_arg_conv_6 = previously_failed_channels_arg_vals[g];
45610                 previously_failed_channels_arg_constr.data[g] = previously_failed_channels_arg_conv_6;
45611         }
45612         (*env)->ReleaseLongArrayElements(env, previously_failed_channels_arg, previously_failed_channels_arg_vals, 0);
45613         LDKPaymentParameters ret_var = PaymentParameters_new(payee_pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv, max_total_cltv_expiry_delta_arg, max_path_count_arg, max_channel_saturation_power_of_half_arg, previously_failed_channels_arg_constr);
45614         int64_t ret_ref = 0;
45615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45618         ret_ref = (uintptr_t)ret_var.inner;
45619         if (ret_var.is_owned) {
45620                 ret_ref |= 1;
45621         }
45622         return ret_ref;
45623 }
45624
45625 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
45626         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
45627 int64_t ret_ref = 0;
45628 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45629 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45630 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45631 ret_ref = (uintptr_t)ret_var.inner;
45632 if (ret_var.is_owned) {
45633         ret_ref |= 1;
45634 }
45635         return ret_ref;
45636 }
45637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45638         LDKPaymentParameters arg_conv;
45639         arg_conv.inner = (void*)(arg & (~1));
45640         arg_conv.is_owned = false;
45641         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45642         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
45643         return ret_conv;
45644 }
45645
45646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45647         LDKPaymentParameters orig_conv;
45648         orig_conv.inner = (void*)(orig & (~1));
45649         orig_conv.is_owned = false;
45650         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45651         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
45652         int64_t ret_ref = 0;
45653         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45654         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45656         ret_ref = (uintptr_t)ret_var.inner;
45657         if (ret_var.is_owned) {
45658                 ret_ref |= 1;
45659         }
45660         return ret_ref;
45661 }
45662
45663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
45664         LDKPaymentParameters o_conv;
45665         o_conv.inner = (void*)(o & (~1));
45666         o_conv.is_owned = false;
45667         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45668         int64_t ret_conv = PaymentParameters_hash(&o_conv);
45669         return ret_conv;
45670 }
45671
45672 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45673         LDKPaymentParameters a_conv;
45674         a_conv.inner = (void*)(a & (~1));
45675         a_conv.is_owned = false;
45676         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45677         LDKPaymentParameters b_conv;
45678         b_conv.inner = (void*)(b & (~1));
45679         b_conv.is_owned = false;
45680         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45681         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
45682         return ret_conv;
45683 }
45684
45685 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
45686         LDKPaymentParameters obj_conv;
45687         obj_conv.inner = (void*)(obj & (~1));
45688         obj_conv.is_owned = false;
45689         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45690         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
45691         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45692         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45693         CVec_u8Z_free(ret_var);
45694         return ret_arr;
45695 }
45696
45697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45698         LDKu8slice ser_ref;
45699         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45700         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45701         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
45702         *ret_conv = PaymentParameters_read(ser_ref);
45703         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45704         return (int64_t)ret_conv;
45705 }
45706
45707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
45708         LDKPublicKey payee_pubkey_ref;
45709         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
45710         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
45711         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
45712         int64_t ret_ref = 0;
45713         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45714         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45715         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45716         ret_ref = (uintptr_t)ret_var.inner;
45717         if (ret_var.is_owned) {
45718                 ret_ref |= 1;
45719         }
45720         return ret_ref;
45721 }
45722
45723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
45724         LDKPublicKey payee_pubkey_ref;
45725         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
45726         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
45727         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
45728         int64_t ret_ref = 0;
45729         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45730         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45732         ret_ref = (uintptr_t)ret_var.inner;
45733         if (ret_var.is_owned) {
45734                 ret_ref |= 1;
45735         }
45736         return ret_ref;
45737 }
45738
45739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45740         LDKRouteHint this_obj_conv;
45741         this_obj_conv.inner = (void*)(this_obj & (~1));
45742         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45744         RouteHint_free(this_obj_conv);
45745 }
45746
45747 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
45748         LDKRouteHint this_ptr_conv;
45749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45750         this_ptr_conv.is_owned = false;
45751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45752         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
45753         int64_tArray ret_arr = NULL;
45754         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45755         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45756         for (size_t o = 0; o < ret_var.datalen; o++) {
45757                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
45758                 int64_t ret_conv_14_ref = 0;
45759                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45760                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45761                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
45762                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
45763                 if (ret_conv_14_var.is_owned) {
45764                         ret_conv_14_ref |= 1;
45765                 }
45766                 ret_arr_ptr[o] = ret_conv_14_ref;
45767         }
45768         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45769         FREE(ret_var.data);
45770         return ret_arr;
45771 }
45772
45773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
45774         LDKRouteHint this_ptr_conv;
45775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45776         this_ptr_conv.is_owned = false;
45777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45778         LDKCVec_RouteHintHopZ val_constr;
45779         val_constr.datalen = (*env)->GetArrayLength(env, val);
45780         if (val_constr.datalen > 0)
45781                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
45782         else
45783                 val_constr.data = NULL;
45784         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
45785         for (size_t o = 0; o < val_constr.datalen; o++) {
45786                 int64_t val_conv_14 = val_vals[o];
45787                 LDKRouteHintHop val_conv_14_conv;
45788                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
45789                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
45790                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
45791                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
45792                 val_constr.data[o] = val_conv_14_conv;
45793         }
45794         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
45795         RouteHint_set_a(&this_ptr_conv, val_constr);
45796 }
45797
45798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
45799         LDKCVec_RouteHintHopZ a_arg_constr;
45800         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
45801         if (a_arg_constr.datalen > 0)
45802                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
45803         else
45804                 a_arg_constr.data = NULL;
45805         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
45806         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
45807                 int64_t a_arg_conv_14 = a_arg_vals[o];
45808                 LDKRouteHintHop a_arg_conv_14_conv;
45809                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
45810                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
45811                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
45812                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
45813                 a_arg_constr.data[o] = a_arg_conv_14_conv;
45814         }
45815         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
45816         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
45817         int64_t ret_ref = 0;
45818         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45819         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45821         ret_ref = (uintptr_t)ret_var.inner;
45822         if (ret_var.is_owned) {
45823                 ret_ref |= 1;
45824         }
45825         return ret_ref;
45826 }
45827
45828 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
45829         LDKRouteHint ret_var = RouteHint_clone(arg);
45830 int64_t ret_ref = 0;
45831 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45832 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45833 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45834 ret_ref = (uintptr_t)ret_var.inner;
45835 if (ret_var.is_owned) {
45836         ret_ref |= 1;
45837 }
45838         return ret_ref;
45839 }
45840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45841         LDKRouteHint arg_conv;
45842         arg_conv.inner = (void*)(arg & (~1));
45843         arg_conv.is_owned = false;
45844         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45845         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
45846         return ret_conv;
45847 }
45848
45849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45850         LDKRouteHint orig_conv;
45851         orig_conv.inner = (void*)(orig & (~1));
45852         orig_conv.is_owned = false;
45853         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45854         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
45855         int64_t ret_ref = 0;
45856         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45857         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45859         ret_ref = (uintptr_t)ret_var.inner;
45860         if (ret_var.is_owned) {
45861                 ret_ref |= 1;
45862         }
45863         return ret_ref;
45864 }
45865
45866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
45867         LDKRouteHint o_conv;
45868         o_conv.inner = (void*)(o & (~1));
45869         o_conv.is_owned = false;
45870         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45871         int64_t ret_conv = RouteHint_hash(&o_conv);
45872         return ret_conv;
45873 }
45874
45875 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45876         LDKRouteHint a_conv;
45877         a_conv.inner = (void*)(a & (~1));
45878         a_conv.is_owned = false;
45879         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45880         LDKRouteHint b_conv;
45881         b_conv.inner = (void*)(b & (~1));
45882         b_conv.is_owned = false;
45883         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45884         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
45885         return ret_conv;
45886 }
45887
45888 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
45889         LDKRouteHint obj_conv;
45890         obj_conv.inner = (void*)(obj & (~1));
45891         obj_conv.is_owned = false;
45892         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45893         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
45894         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45895         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45896         CVec_u8Z_free(ret_var);
45897         return ret_arr;
45898 }
45899
45900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45901         LDKu8slice ser_ref;
45902         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45903         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45904         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
45905         *ret_conv = RouteHint_read(ser_ref);
45906         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45907         return (int64_t)ret_conv;
45908 }
45909
45910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45911         LDKRouteHintHop this_obj_conv;
45912         this_obj_conv.inner = (void*)(this_obj & (~1));
45913         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45915         RouteHintHop_free(this_obj_conv);
45916 }
45917
45918 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
45919         LDKRouteHintHop this_ptr_conv;
45920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45921         this_ptr_conv.is_owned = false;
45922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45923         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45924         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
45925         return ret_arr;
45926 }
45927
45928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
45929         LDKRouteHintHop this_ptr_conv;
45930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45931         this_ptr_conv.is_owned = false;
45932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45933         LDKPublicKey val_ref;
45934         CHECK((*env)->GetArrayLength(env, val) == 33);
45935         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
45936         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
45937 }
45938
45939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
45940         LDKRouteHintHop this_ptr_conv;
45941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45942         this_ptr_conv.is_owned = false;
45943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45944         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
45945         return ret_conv;
45946 }
45947
45948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45949         LDKRouteHintHop this_ptr_conv;
45950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45951         this_ptr_conv.is_owned = false;
45952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45953         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
45954 }
45955
45956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
45957         LDKRouteHintHop this_ptr_conv;
45958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45959         this_ptr_conv.is_owned = false;
45960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45961         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
45962         int64_t ret_ref = 0;
45963         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45964         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45966         ret_ref = (uintptr_t)ret_var.inner;
45967         if (ret_var.is_owned) {
45968                 ret_ref |= 1;
45969         }
45970         return ret_ref;
45971 }
45972
45973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45974         LDKRouteHintHop this_ptr_conv;
45975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45976         this_ptr_conv.is_owned = false;
45977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45978         LDKRoutingFees val_conv;
45979         val_conv.inner = (void*)(val & (~1));
45980         val_conv.is_owned = (val & 1) || (val == 0);
45981         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45982         val_conv = RoutingFees_clone(&val_conv);
45983         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
45984 }
45985
45986 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
45987         LDKRouteHintHop this_ptr_conv;
45988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45989         this_ptr_conv.is_owned = false;
45990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45991         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
45992         return ret_conv;
45993 }
45994
45995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
45996         LDKRouteHintHop this_ptr_conv;
45997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45998         this_ptr_conv.is_owned = false;
45999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46000         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
46001 }
46002
46003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46004         LDKRouteHintHop this_ptr_conv;
46005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46006         this_ptr_conv.is_owned = false;
46007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46008         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
46009         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
46010         int64_t ret_ref = (uintptr_t)ret_copy;
46011         return ret_ref;
46012 }
46013
46014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46015         LDKRouteHintHop this_ptr_conv;
46016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46017         this_ptr_conv.is_owned = false;
46018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46019         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
46020         CHECK_ACCESS(val_ptr);
46021         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
46022         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
46023         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
46024 }
46025
46026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46027         LDKRouteHintHop this_ptr_conv;
46028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46029         this_ptr_conv.is_owned = false;
46030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46031         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
46032         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
46033         int64_t ret_ref = (uintptr_t)ret_copy;
46034         return ret_ref;
46035 }
46036
46037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46038         LDKRouteHintHop this_ptr_conv;
46039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46040         this_ptr_conv.is_owned = false;
46041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46042         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
46043         CHECK_ACCESS(val_ptr);
46044         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
46045         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
46046         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
46047 }
46048
46049 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) {
46050         LDKPublicKey src_node_id_arg_ref;
46051         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
46052         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
46053         LDKRoutingFees fees_arg_conv;
46054         fees_arg_conv.inner = (void*)(fees_arg & (~1));
46055         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
46056         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
46057         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
46058         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
46059         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
46060         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
46061         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
46062         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
46063         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
46064         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
46065         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
46066         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);
46067         int64_t ret_ref = 0;
46068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46071         ret_ref = (uintptr_t)ret_var.inner;
46072         if (ret_var.is_owned) {
46073                 ret_ref |= 1;
46074         }
46075         return ret_ref;
46076 }
46077
46078 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
46079         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
46080 int64_t ret_ref = 0;
46081 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46082 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46083 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46084 ret_ref = (uintptr_t)ret_var.inner;
46085 if (ret_var.is_owned) {
46086         ret_ref |= 1;
46087 }
46088         return ret_ref;
46089 }
46090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46091         LDKRouteHintHop arg_conv;
46092         arg_conv.inner = (void*)(arg & (~1));
46093         arg_conv.is_owned = false;
46094         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46095         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
46096         return ret_conv;
46097 }
46098
46099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46100         LDKRouteHintHop orig_conv;
46101         orig_conv.inner = (void*)(orig & (~1));
46102         orig_conv.is_owned = false;
46103         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46104         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
46105         int64_t ret_ref = 0;
46106         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46107         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46109         ret_ref = (uintptr_t)ret_var.inner;
46110         if (ret_var.is_owned) {
46111                 ret_ref |= 1;
46112         }
46113         return ret_ref;
46114 }
46115
46116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
46117         LDKRouteHintHop o_conv;
46118         o_conv.inner = (void*)(o & (~1));
46119         o_conv.is_owned = false;
46120         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46121         int64_t ret_conv = RouteHintHop_hash(&o_conv);
46122         return ret_conv;
46123 }
46124
46125 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46126         LDKRouteHintHop a_conv;
46127         a_conv.inner = (void*)(a & (~1));
46128         a_conv.is_owned = false;
46129         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46130         LDKRouteHintHop b_conv;
46131         b_conv.inner = (void*)(b & (~1));
46132         b_conv.is_owned = false;
46133         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46134         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
46135         return ret_conv;
46136 }
46137
46138 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
46139         LDKRouteHintHop obj_conv;
46140         obj_conv.inner = (void*)(obj & (~1));
46141         obj_conv.is_owned = false;
46142         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46143         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
46144         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46145         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46146         CVec_u8Z_free(ret_var);
46147         return ret_arr;
46148 }
46149
46150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46151         LDKu8slice ser_ref;
46152         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46153         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46154         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
46155         *ret_conv = RouteHintHop_read(ser_ref);
46156         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46157         return (int64_t)ret_conv;
46158 }
46159
46160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_find_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t route_params, int64_t network_graph, int64_tArray first_hops, int64_t logger, int64_t scorer, int8_tArray random_seed_bytes) {
46161         LDKPublicKey our_node_pubkey_ref;
46162         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
46163         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
46164         LDKRouteParameters route_params_conv;
46165         route_params_conv.inner = (void*)(route_params & (~1));
46166         route_params_conv.is_owned = false;
46167         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
46168         LDKNetworkGraph network_graph_conv;
46169         network_graph_conv.inner = (void*)(network_graph & (~1));
46170         network_graph_conv.is_owned = false;
46171         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46172         LDKCVec_ChannelDetailsZ first_hops_constr;
46173         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
46174         if (first_hops != NULL) {
46175                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
46176                 if (first_hops_constr.datalen > 0)
46177                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
46178                 else
46179                         first_hops_constr.data = NULL;
46180                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
46181                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
46182                         int64_t first_hops_conv_16 = first_hops_vals[q];
46183                         LDKChannelDetails first_hops_conv_16_conv;
46184                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
46185                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
46186                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
46187                         first_hops_constr.data[q] = first_hops_conv_16_conv;
46188                 }
46189                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
46190                 first_hops_ptr = &first_hops_constr;
46191         }
46192         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
46193         CHECK_ACCESS(logger_ptr);
46194         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46195         if (logger_conv.free == LDKLogger_JCalls_free) {
46196                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46197                 LDKLogger_JCalls_cloned(&logger_conv);
46198         }
46199         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
46200         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
46201         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
46202         unsigned char random_seed_bytes_arr[32];
46203         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
46204         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
46205         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
46206         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
46207         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_graph_conv, first_hops_ptr, logger_conv, scorer_conv, random_seed_bytes_ref);
46208         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
46209         return (int64_t)ret_conv;
46210 }
46211
46212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_build_1route_1from_1hops(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, jobjectArray hops, int64_t route_params, int64_t network_graph, int64_t logger, int8_tArray random_seed_bytes) {
46213         LDKPublicKey our_node_pubkey_ref;
46214         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
46215         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
46216         LDKCVec_PublicKeyZ hops_constr;
46217         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
46218         if (hops_constr.datalen > 0)
46219                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
46220         else
46221                 hops_constr.data = NULL;
46222         for (size_t i = 0; i < hops_constr.datalen; i++) {
46223                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
46224                 LDKPublicKey hops_conv_8_ref;
46225                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
46226                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
46227                 hops_constr.data[i] = hops_conv_8_ref;
46228         }
46229         LDKRouteParameters route_params_conv;
46230         route_params_conv.inner = (void*)(route_params & (~1));
46231         route_params_conv.is_owned = false;
46232         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
46233         LDKNetworkGraph network_graph_conv;
46234         network_graph_conv.inner = (void*)(network_graph & (~1));
46235         network_graph_conv.is_owned = false;
46236         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46237         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
46238         CHECK_ACCESS(logger_ptr);
46239         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46240         if (logger_conv.free == LDKLogger_JCalls_free) {
46241                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46242                 LDKLogger_JCalls_cloned(&logger_conv);
46243         }
46244         unsigned char random_seed_bytes_arr[32];
46245         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
46246         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
46247         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
46248         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
46249         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
46250         return (int64_t)ret_conv;
46251 }
46252
46253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46254         if ((this_ptr & 1) != 0) return;
46255         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
46256         CHECK_ACCESS(this_ptr_ptr);
46257         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
46258         FREE((void*)this_ptr);
46259         Score_free(this_ptr_conv);
46260 }
46261
46262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46263         if ((this_ptr & 1) != 0) return;
46264         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
46265         CHECK_ACCESS(this_ptr_ptr);
46266         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
46267         FREE((void*)this_ptr);
46268         LockableScore_free(this_ptr_conv);
46269 }
46270
46271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46272         LDKMultiThreadedLockableScore this_obj_conv;
46273         this_obj_conv.inner = (void*)(this_obj & (~1));
46274         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46276         MultiThreadedLockableScore_free(this_obj_conv);
46277 }
46278
46279 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
46280         LDKMultiThreadedLockableScore obj_conv;
46281         obj_conv.inner = (void*)(obj & (~1));
46282         obj_conv.is_owned = false;
46283         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46284         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
46285         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46286         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46287         CVec_u8Z_free(ret_var);
46288         return ret_arr;
46289 }
46290
46291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
46292         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
46293         CHECK_ACCESS(score_ptr);
46294         LDKScore score_conv = *(LDKScore*)(score_ptr);
46295         if (score_conv.free == LDKScore_JCalls_free) {
46296                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46297                 LDKScore_JCalls_cloned(&score_conv);
46298         }
46299         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
46300         int64_t ret_ref = 0;
46301         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46302         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46304         ret_ref = (uintptr_t)ret_var.inner;
46305         if (ret_var.is_owned) {
46306                 ret_ref |= 1;
46307         }
46308         return ret_ref;
46309 }
46310
46311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46312         LDKChannelUsage this_obj_conv;
46313         this_obj_conv.inner = (void*)(this_obj & (~1));
46314         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46316         ChannelUsage_free(this_obj_conv);
46317 }
46318
46319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46320         LDKChannelUsage this_ptr_conv;
46321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46322         this_ptr_conv.is_owned = false;
46323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46324         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
46325         return ret_conv;
46326 }
46327
46328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46329         LDKChannelUsage this_ptr_conv;
46330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46331         this_ptr_conv.is_owned = false;
46332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46333         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
46334 }
46335
46336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46337         LDKChannelUsage this_ptr_conv;
46338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46339         this_ptr_conv.is_owned = false;
46340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46341         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
46342         return ret_conv;
46343 }
46344
46345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46346         LDKChannelUsage this_ptr_conv;
46347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46348         this_ptr_conv.is_owned = false;
46349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46350         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
46351 }
46352
46353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
46354         LDKChannelUsage this_ptr_conv;
46355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46356         this_ptr_conv.is_owned = false;
46357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46358         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46359         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
46360         int64_t ret_ref = (uintptr_t)ret_copy;
46361         return ret_ref;
46362 }
46363
46364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46365         LDKChannelUsage this_ptr_conv;
46366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46367         this_ptr_conv.is_owned = false;
46368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46369         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
46370         CHECK_ACCESS(val_ptr);
46371         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
46372         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)val) & ~1));
46373         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
46374 }
46375
46376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1new(JNIEnv *env, jclass clz, int64_t amount_msat_arg, int64_t inflight_htlc_msat_arg, int64_t effective_capacity_arg) {
46377         void* effective_capacity_arg_ptr = (void*)(((uintptr_t)effective_capacity_arg) & ~1);
46378         CHECK_ACCESS(effective_capacity_arg_ptr);
46379         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
46380         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)effective_capacity_arg) & ~1));
46381         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
46382         int64_t ret_ref = 0;
46383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46386         ret_ref = (uintptr_t)ret_var.inner;
46387         if (ret_var.is_owned) {
46388                 ret_ref |= 1;
46389         }
46390         return ret_ref;
46391 }
46392
46393 static inline uintptr_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
46394         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
46395 int64_t ret_ref = 0;
46396 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46397 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46398 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46399 ret_ref = (uintptr_t)ret_var.inner;
46400 if (ret_var.is_owned) {
46401         ret_ref |= 1;
46402 }
46403         return ret_ref;
46404 }
46405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46406         LDKChannelUsage arg_conv;
46407         arg_conv.inner = (void*)(arg & (~1));
46408         arg_conv.is_owned = false;
46409         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46410         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
46411         return ret_conv;
46412 }
46413
46414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46415         LDKChannelUsage orig_conv;
46416         orig_conv.inner = (void*)(orig & (~1));
46417         orig_conv.is_owned = false;
46418         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46419         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
46420         int64_t ret_ref = 0;
46421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46424         ret_ref = (uintptr_t)ret_var.inner;
46425         if (ret_var.is_owned) {
46426                 ret_ref |= 1;
46427         }
46428         return ret_ref;
46429 }
46430
46431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46432         LDKFixedPenaltyScorer this_obj_conv;
46433         this_obj_conv.inner = (void*)(this_obj & (~1));
46434         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46436         FixedPenaltyScorer_free(this_obj_conv);
46437 }
46438
46439 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
46440         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
46441 int64_t ret_ref = 0;
46442 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46443 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46444 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46445 ret_ref = (uintptr_t)ret_var.inner;
46446 if (ret_var.is_owned) {
46447         ret_ref |= 1;
46448 }
46449         return ret_ref;
46450 }
46451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46452         LDKFixedPenaltyScorer arg_conv;
46453         arg_conv.inner = (void*)(arg & (~1));
46454         arg_conv.is_owned = false;
46455         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46456         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
46457         return ret_conv;
46458 }
46459
46460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46461         LDKFixedPenaltyScorer orig_conv;
46462         orig_conv.inner = (void*)(orig & (~1));
46463         orig_conv.is_owned = false;
46464         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46465         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
46466         int64_t ret_ref = 0;
46467         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46468         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46470         ret_ref = (uintptr_t)ret_var.inner;
46471         if (ret_var.is_owned) {
46472                 ret_ref |= 1;
46473         }
46474         return ret_ref;
46475 }
46476
46477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
46478         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
46479         int64_t ret_ref = 0;
46480         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46481         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46483         ret_ref = (uintptr_t)ret_var.inner;
46484         if (ret_var.is_owned) {
46485                 ret_ref |= 1;
46486         }
46487         return ret_ref;
46488 }
46489
46490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
46491         LDKFixedPenaltyScorer this_arg_conv;
46492         this_arg_conv.inner = (void*)(this_arg & (~1));
46493         this_arg_conv.is_owned = false;
46494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46495         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
46496         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
46497         return (int64_t)ret_ret;
46498 }
46499
46500 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
46501         LDKFixedPenaltyScorer obj_conv;
46502         obj_conv.inner = (void*)(obj & (~1));
46503         obj_conv.is_owned = false;
46504         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46505         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
46506         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46507         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46508         CVec_u8Z_free(ret_var);
46509         return ret_arr;
46510 }
46511
46512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
46513         LDKu8slice ser_ref;
46514         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46515         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46516         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
46517         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
46518         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46519         return (int64_t)ret_conv;
46520 }
46521
46522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46523         LDKProbabilisticScorer this_obj_conv;
46524         this_obj_conv.inner = (void*)(this_obj & (~1));
46525         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46527         ProbabilisticScorer_free(this_obj_conv);
46528 }
46529
46530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46531         LDKProbabilisticScoringParameters this_obj_conv;
46532         this_obj_conv.inner = (void*)(this_obj & (~1));
46533         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46535         ProbabilisticScoringParameters_free(this_obj_conv);
46536 }
46537
46538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46539         LDKProbabilisticScoringParameters this_ptr_conv;
46540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46541         this_ptr_conv.is_owned = false;
46542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46543         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
46544         return ret_conv;
46545 }
46546
46547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46548         LDKProbabilisticScoringParameters this_ptr_conv;
46549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46550         this_ptr_conv.is_owned = false;
46551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46552         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
46553 }
46554
46555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46556         LDKProbabilisticScoringParameters this_ptr_conv;
46557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46558         this_ptr_conv.is_owned = false;
46559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46560         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
46561         return ret_conv;
46562 }
46563
46564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46565         LDKProbabilisticScoringParameters this_ptr_conv;
46566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46567         this_ptr_conv.is_owned = false;
46568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46569         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
46570 }
46571
46572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46573         LDKProbabilisticScoringParameters this_ptr_conv;
46574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46575         this_ptr_conv.is_owned = false;
46576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46577         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
46578         return ret_conv;
46579 }
46580
46581 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) {
46582         LDKProbabilisticScoringParameters this_ptr_conv;
46583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46584         this_ptr_conv.is_owned = false;
46585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46586         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
46587 }
46588
46589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
46590         LDKProbabilisticScoringParameters this_ptr_conv;
46591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46592         this_ptr_conv.is_owned = false;
46593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46594         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
46595         return ret_conv;
46596 }
46597
46598 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) {
46599         LDKProbabilisticScoringParameters this_ptr_conv;
46600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46601         this_ptr_conv.is_owned = false;
46602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46603         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
46604 }
46605
46606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46607         LDKProbabilisticScoringParameters this_ptr_conv;
46608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46609         this_ptr_conv.is_owned = false;
46610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46611         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
46612         return ret_conv;
46613 }
46614
46615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46616         LDKProbabilisticScoringParameters this_ptr_conv;
46617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46618         this_ptr_conv.is_owned = false;
46619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46620         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
46621 }
46622
46623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46624         LDKProbabilisticScoringParameters this_ptr_conv;
46625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46626         this_ptr_conv.is_owned = false;
46627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46628         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
46629         return ret_conv;
46630 }
46631
46632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46633         LDKProbabilisticScoringParameters this_ptr_conv;
46634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46635         this_ptr_conv.is_owned = false;
46636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46637         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
46638 }
46639
46640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46641         LDKProbabilisticScoringParameters this_ptr_conv;
46642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46643         this_ptr_conv.is_owned = false;
46644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46645         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
46646         return ret_conv;
46647 }
46648
46649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46650         LDKProbabilisticScoringParameters this_ptr_conv;
46651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46652         this_ptr_conv.is_owned = false;
46653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46654         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
46655 }
46656
46657 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
46658         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
46659 int64_t ret_ref = 0;
46660 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46661 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46662 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46663 ret_ref = (uintptr_t)ret_var.inner;
46664 if (ret_var.is_owned) {
46665         ret_ref |= 1;
46666 }
46667         return ret_ref;
46668 }
46669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46670         LDKProbabilisticScoringParameters arg_conv;
46671         arg_conv.inner = (void*)(arg & (~1));
46672         arg_conv.is_owned = false;
46673         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46674         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
46675         return ret_conv;
46676 }
46677
46678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46679         LDKProbabilisticScoringParameters orig_conv;
46680         orig_conv.inner = (void*)(orig & (~1));
46681         orig_conv.is_owned = false;
46682         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46683         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
46684         int64_t ret_ref = 0;
46685         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46686         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46688         ret_ref = (uintptr_t)ret_var.inner;
46689         if (ret_var.is_owned) {
46690                 ret_ref |= 1;
46691         }
46692         return ret_ref;
46693 }
46694
46695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1new(JNIEnv *env, jclass clz, int64_t params, int64_t network_graph, int64_t logger) {
46696         LDKProbabilisticScoringParameters params_conv;
46697         params_conv.inner = (void*)(params & (~1));
46698         params_conv.is_owned = (params & 1) || (params == 0);
46699         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
46700         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
46701         LDKNetworkGraph network_graph_conv;
46702         network_graph_conv.inner = (void*)(network_graph & (~1));
46703         network_graph_conv.is_owned = false;
46704         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46705         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
46706         CHECK_ACCESS(logger_ptr);
46707         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46708         if (logger_conv.free == LDKLogger_JCalls_free) {
46709                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46710                 LDKLogger_JCalls_cloned(&logger_conv);
46711         }
46712         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
46713         int64_t ret_ref = 0;
46714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46717         ret_ref = (uintptr_t)ret_var.inner;
46718         if (ret_var.is_owned) {
46719                 ret_ref |= 1;
46720         }
46721         return ret_ref;
46722 }
46723
46724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
46725         LDKProbabilisticScorer this_arg_conv;
46726         this_arg_conv.inner = (void*)(this_arg & (~1));
46727         this_arg_conv.is_owned = false;
46728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46729         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
46730 }
46731
46732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1estimated_1channel_1liquidity_1range(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scid, int64_t target) {
46733         LDKProbabilisticScorer this_arg_conv;
46734         this_arg_conv.inner = (void*)(this_arg & (~1));
46735         this_arg_conv.is_owned = false;
46736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46737         LDKNodeId target_conv;
46738         target_conv.inner = (void*)(target & (~1));
46739         target_conv.is_owned = false;
46740         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
46741         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
46742         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
46743         int64_t ret_ref = (uintptr_t)ret_copy;
46744         return ret_ref;
46745 }
46746
46747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1add_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
46748         LDKProbabilisticScorer this_arg_conv;
46749         this_arg_conv.inner = (void*)(this_arg & (~1));
46750         this_arg_conv.is_owned = false;
46751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46752         LDKNodeId node_id_conv;
46753         node_id_conv.inner = (void*)(node_id & (~1));
46754         node_id_conv.is_owned = false;
46755         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
46756         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
46757 }
46758
46759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
46760         LDKProbabilisticScorer this_arg_conv;
46761         this_arg_conv.inner = (void*)(this_arg & (~1));
46762         this_arg_conv.is_owned = false;
46763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46764         LDKNodeId node_id_conv;
46765         node_id_conv.inner = (void*)(node_id & (~1));
46766         node_id_conv.is_owned = false;
46767         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
46768         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
46769 }
46770
46771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1set_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id, int64_t penalty) {
46772         LDKProbabilisticScorer this_arg_conv;
46773         this_arg_conv.inner = (void*)(this_arg & (~1));
46774         this_arg_conv.is_owned = false;
46775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46776         LDKNodeId node_id_conv;
46777         node_id_conv.inner = (void*)(node_id & (~1));
46778         node_id_conv.is_owned = false;
46779         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
46780         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
46781 }
46782
46783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
46784         LDKProbabilisticScorer this_arg_conv;
46785         this_arg_conv.inner = (void*)(this_arg & (~1));
46786         this_arg_conv.is_owned = false;
46787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46788         LDKNodeId node_id_conv;
46789         node_id_conv.inner = (void*)(node_id & (~1));
46790         node_id_conv.is_owned = false;
46791         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
46792         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
46793 }
46794
46795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1clear_1manual_1penalties(JNIEnv *env, jclass clz, int64_t this_arg) {
46796         LDKProbabilisticScorer this_arg_conv;
46797         this_arg_conv.inner = (void*)(this_arg & (~1));
46798         this_arg_conv.is_owned = false;
46799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46800         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
46801 }
46802
46803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1add_1banned_1from_1list(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray node_ids) {
46804         LDKProbabilisticScoringParameters this_arg_conv;
46805         this_arg_conv.inner = (void*)(this_arg & (~1));
46806         this_arg_conv.is_owned = false;
46807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46808         LDKCVec_NodeIdZ node_ids_constr;
46809         node_ids_constr.datalen = (*env)->GetArrayLength(env, node_ids);
46810         if (node_ids_constr.datalen > 0)
46811                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
46812         else
46813                 node_ids_constr.data = NULL;
46814         int64_t* node_ids_vals = (*env)->GetLongArrayElements (env, node_ids, NULL);
46815         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
46816                 int64_t node_ids_conv_8 = node_ids_vals[i];
46817                 LDKNodeId node_ids_conv_8_conv;
46818                 node_ids_conv_8_conv.inner = (void*)(node_ids_conv_8 & (~1));
46819                 node_ids_conv_8_conv.is_owned = (node_ids_conv_8 & 1) || (node_ids_conv_8 == 0);
46820                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
46821                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
46822                 node_ids_constr.data[i] = node_ids_conv_8_conv;
46823         }
46824         (*env)->ReleaseLongArrayElements(env, node_ids, node_ids_vals, 0);
46825         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
46826 }
46827
46828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
46829         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
46830         int64_t ret_ref = 0;
46831         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46832         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46834         ret_ref = (uintptr_t)ret_var.inner;
46835         if (ret_var.is_owned) {
46836                 ret_ref |= 1;
46837         }
46838         return ret_ref;
46839 }
46840
46841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
46842         LDKProbabilisticScorer this_arg_conv;
46843         this_arg_conv.inner = (void*)(this_arg & (~1));
46844         this_arg_conv.is_owned = false;
46845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46846         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
46847         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
46848         return (int64_t)ret_ret;
46849 }
46850
46851 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
46852         LDKProbabilisticScorer obj_conv;
46853         obj_conv.inner = (void*)(obj & (~1));
46854         obj_conv.is_owned = false;
46855         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46856         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
46857         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46858         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46859         CVec_u8Z_free(ret_var);
46860         return ret_arr;
46861 }
46862
46863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg_a, int64_t arg_b, int64_t arg_c) {
46864         LDKu8slice ser_ref;
46865         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46866         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46867         LDKProbabilisticScoringParameters arg_a_conv;
46868         arg_a_conv.inner = (void*)(arg_a & (~1));
46869         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
46870         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
46871         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
46872         LDKNetworkGraph arg_b_conv;
46873         arg_b_conv.inner = (void*)(arg_b & (~1));
46874         arg_b_conv.is_owned = false;
46875         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
46876         void* arg_c_ptr = (void*)(((uintptr_t)arg_c) & ~1);
46877         CHECK_ACCESS(arg_c_ptr);
46878         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
46879         if (arg_c_conv.free == LDKLogger_JCalls_free) {
46880                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46881                 LDKLogger_JCalls_cloned(&arg_c_conv);
46882         }
46883         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
46884         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
46885         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46886         return (int64_t)ret_conv;
46887 }
46888
46889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46890         LDKFilesystemPersister this_obj_conv;
46891         this_obj_conv.inner = (void*)(this_obj & (~1));
46892         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46894         FilesystemPersister_free(this_obj_conv);
46895 }
46896
46897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
46898         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
46899         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
46900         int64_t ret_ref = 0;
46901         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46902         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46904         ret_ref = (uintptr_t)ret_var.inner;
46905         if (ret_var.is_owned) {
46906                 ret_ref |= 1;
46907         }
46908         return ret_ref;
46909 }
46910
46911 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
46912         LDKFilesystemPersister this_arg_conv;
46913         this_arg_conv.inner = (void*)(this_arg & (~1));
46914         this_arg_conv.is_owned = false;
46915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46916         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
46917         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46918         Str_free(ret_str);
46919         return ret_conv;
46920 }
46921
46922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
46923         LDKFilesystemPersister this_arg_conv;
46924         this_arg_conv.inner = (void*)(this_arg & (~1));
46925         this_arg_conv.is_owned = false;
46926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46927         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46928         CHECK_ACCESS(keys_manager_ptr);
46929         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46930         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46931                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46932                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46933         }
46934         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
46935         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
46936         return (int64_t)ret_conv;
46937 }
46938
46939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46940         LDKBackgroundProcessor this_obj_conv;
46941         this_obj_conv.inner = (void*)(this_obj & (~1));
46942         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46944         BackgroundProcessor_free(this_obj_conv);
46945 }
46946
46947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46948         if ((this_ptr & 1) != 0) return;
46949         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
46950         CHECK_ACCESS(this_ptr_ptr);
46951         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
46952         FREE((void*)this_ptr);
46953         GossipSync_free(this_ptr_conv);
46954 }
46955
46956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
46957         LDKP2PGossipSync a_conv;
46958         a_conv.inner = (void*)(a & (~1));
46959         a_conv.is_owned = false;
46960         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46961         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
46962         *ret_copy = GossipSync_p2_p(&a_conv);
46963         int64_t ret_ref = (uintptr_t)ret_copy;
46964         return ret_ref;
46965 }
46966
46967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
46968         LDKRapidGossipSync a_conv;
46969         a_conv.inner = (void*)(a & (~1));
46970         a_conv.is_owned = false;
46971         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46972         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
46973         *ret_copy = GossipSync_rapid(&a_conv);
46974         int64_t ret_ref = (uintptr_t)ret_copy;
46975         return ret_ref;
46976 }
46977
46978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
46979         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
46980         *ret_copy = GossipSync_none();
46981         int64_t ret_ref = (uintptr_t)ret_copy;
46982         return ret_ref;
46983 }
46984
46985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(JNIEnv *env, jclass clz, int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t gossip_sync, int64_t peer_manager, int64_t logger, int64_t scorer) {
46986         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
46987         CHECK_ACCESS(persister_ptr);
46988         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
46989         if (persister_conv.free == LDKPersister_JCalls_free) {
46990                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46991                 LDKPersister_JCalls_cloned(&persister_conv);
46992         }
46993         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
46994         CHECK_ACCESS(event_handler_ptr);
46995         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
46996         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
46997                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46998                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
46999         }
47000         LDKChainMonitor chain_monitor_conv;
47001         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
47002         chain_monitor_conv.is_owned = false;
47003         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
47004         LDKChannelManager channel_manager_conv;
47005         channel_manager_conv.inner = (void*)(channel_manager & (~1));
47006         channel_manager_conv.is_owned = false;
47007         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
47008         void* gossip_sync_ptr = (void*)(((uintptr_t)gossip_sync) & ~1);
47009         CHECK_ACCESS(gossip_sync_ptr);
47010         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
47011         // WARNING: we may need a move here but no clone is available for LDKGossipSync
47012         LDKPeerManager peer_manager_conv;
47013         peer_manager_conv.inner = (void*)(peer_manager & (~1));
47014         peer_manager_conv.is_owned = false;
47015         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
47016         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
47017         CHECK_ACCESS(logger_ptr);
47018         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47019         if (logger_conv.free == LDKLogger_JCalls_free) {
47020                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47021                 LDKLogger_JCalls_cloned(&logger_conv);
47022         }
47023         LDKMultiThreadedLockableScore scorer_conv;
47024         scorer_conv.inner = (void*)(scorer & (~1));
47025         scorer_conv.is_owned = (scorer & 1) || (scorer == 0);
47026         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
47027         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, gossip_sync_conv, &peer_manager_conv, logger_conv, scorer_conv);
47028         int64_t ret_ref = 0;
47029         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47030         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47031         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47032         ret_ref = (uintptr_t)ret_var.inner;
47033         if (ret_var.is_owned) {
47034                 ret_ref |= 1;
47035         }
47036         return ret_ref;
47037 }
47038
47039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
47040         LDKBackgroundProcessor this_arg_conv;
47041         this_arg_conv.inner = (void*)(this_arg & (~1));
47042         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
47043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47044         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
47045         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
47046         *ret_conv = BackgroundProcessor_join(this_arg_conv);
47047         return (int64_t)ret_conv;
47048 }
47049
47050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
47051         LDKBackgroundProcessor this_arg_conv;
47052         this_arg_conv.inner = (void*)(this_arg & (~1));
47053         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
47054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47055         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
47056         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
47057         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
47058         return (int64_t)ret_conv;
47059 }
47060
47061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47062         if ((this_ptr & 1) != 0) return;
47063         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
47064         CHECK_ACCESS(this_ptr_ptr);
47065         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
47066         FREE((void*)this_ptr);
47067         ParseError_free(this_ptr_conv);
47068 }
47069
47070 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
47071         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47072         *ret_copy = ParseError_clone(arg);
47073 int64_t ret_ref = (uintptr_t)ret_copy;
47074         return ret_ref;
47075 }
47076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47077         LDKParseError* arg_conv = (LDKParseError*)arg;
47078         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
47079         return ret_conv;
47080 }
47081
47082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47083         LDKParseError* orig_conv = (LDKParseError*)orig;
47084         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47085         *ret_copy = ParseError_clone(orig_conv);
47086         int64_t ret_ref = (uintptr_t)ret_copy;
47087         return ret_ref;
47088 }
47089
47090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
47091         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
47092         CHECK_ACCESS(a_ptr);
47093         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
47094         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
47095         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47096         *ret_copy = ParseError_bech32_error(a_conv);
47097         int64_t ret_ref = (uintptr_t)ret_copy;
47098         return ret_ref;
47099 }
47100
47101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
47102         
47103         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47104         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
47105         int64_t ret_ref = (uintptr_t)ret_copy;
47106         return ret_ref;
47107 }
47108
47109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
47110         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
47111         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47112         *ret_copy = ParseError_malformed_signature(a_conv);
47113         int64_t ret_ref = (uintptr_t)ret_copy;
47114         return ret_ref;
47115 }
47116
47117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
47118         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47119         *ret_copy = ParseError_bad_prefix();
47120         int64_t ret_ref = (uintptr_t)ret_copy;
47121         return ret_ref;
47122 }
47123
47124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
47125         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47126         *ret_copy = ParseError_unknown_currency();
47127         int64_t ret_ref = (uintptr_t)ret_copy;
47128         return ret_ref;
47129 }
47130
47131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
47132         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47133         *ret_copy = ParseError_unknown_si_prefix();
47134         int64_t ret_ref = (uintptr_t)ret_copy;
47135         return ret_ref;
47136 }
47137
47138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
47139         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47140         *ret_copy = ParseError_malformed_hrp();
47141         int64_t ret_ref = (uintptr_t)ret_copy;
47142         return ret_ref;
47143 }
47144
47145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
47146         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47147         *ret_copy = ParseError_too_short_data_part();
47148         int64_t ret_ref = (uintptr_t)ret_copy;
47149         return ret_ref;
47150 }
47151
47152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
47153         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47154         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
47155         int64_t ret_ref = (uintptr_t)ret_copy;
47156         return ret_ref;
47157 }
47158
47159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
47160         
47161         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47162         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
47163         int64_t ret_ref = (uintptr_t)ret_copy;
47164         return ret_ref;
47165 }
47166
47167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
47168         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47169         *ret_copy = ParseError_padding_error();
47170         int64_t ret_ref = (uintptr_t)ret_copy;
47171         return ret_ref;
47172 }
47173
47174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
47175         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47176         *ret_copy = ParseError_integer_overflow_error();
47177         int64_t ret_ref = (uintptr_t)ret_copy;
47178         return ret_ref;
47179 }
47180
47181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
47182         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47183         *ret_copy = ParseError_invalid_seg_wit_program_length();
47184         int64_t ret_ref = (uintptr_t)ret_copy;
47185         return ret_ref;
47186 }
47187
47188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
47189         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47190         *ret_copy = ParseError_invalid_pub_key_hash_length();
47191         int64_t ret_ref = (uintptr_t)ret_copy;
47192         return ret_ref;
47193 }
47194
47195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
47196         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47197         *ret_copy = ParseError_invalid_script_hash_length();
47198         int64_t ret_ref = (uintptr_t)ret_copy;
47199         return ret_ref;
47200 }
47201
47202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
47203         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47204         *ret_copy = ParseError_invalid_recovery_id();
47205         int64_t ret_ref = (uintptr_t)ret_copy;
47206         return ret_ref;
47207 }
47208
47209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
47210         LDKStr a_conv = java_to_owned_str(env, a);
47211         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47212         *ret_copy = ParseError_invalid_slice_length(a_conv);
47213         int64_t ret_ref = (uintptr_t)ret_copy;
47214         return ret_ref;
47215 }
47216
47217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
47218         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47219         *ret_copy = ParseError_skip();
47220         int64_t ret_ref = (uintptr_t)ret_copy;
47221         return ret_ref;
47222 }
47223
47224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47225         if ((this_ptr & 1) != 0) return;
47226         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
47227         CHECK_ACCESS(this_ptr_ptr);
47228         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
47229         FREE((void*)this_ptr);
47230         ParseOrSemanticError_free(this_ptr_conv);
47231 }
47232
47233 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
47234         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
47235         *ret_copy = ParseOrSemanticError_clone(arg);
47236 int64_t ret_ref = (uintptr_t)ret_copy;
47237         return ret_ref;
47238 }
47239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47240         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
47241         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
47242         return ret_conv;
47243 }
47244
47245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47246         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
47247         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
47248         *ret_copy = ParseOrSemanticError_clone(orig_conv);
47249         int64_t ret_ref = (uintptr_t)ret_copy;
47250         return ret_ref;
47251 }
47252
47253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
47254         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
47255         CHECK_ACCESS(a_ptr);
47256         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
47257         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
47258         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
47259         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
47260         int64_t ret_ref = (uintptr_t)ret_copy;
47261         return ret_ref;
47262 }
47263
47264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
47265         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
47266         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
47267         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
47268         int64_t ret_ref = (uintptr_t)ret_copy;
47269         return ret_ref;
47270 }
47271
47272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47273         LDKInvoice this_obj_conv;
47274         this_obj_conv.inner = (void*)(this_obj & (~1));
47275         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47277         Invoice_free(this_obj_conv);
47278 }
47279
47280 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47281         LDKInvoice a_conv;
47282         a_conv.inner = (void*)(a & (~1));
47283         a_conv.is_owned = false;
47284         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47285         LDKInvoice b_conv;
47286         b_conv.inner = (void*)(b & (~1));
47287         b_conv.is_owned = false;
47288         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47289         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
47290         return ret_conv;
47291 }
47292
47293 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
47294         LDKInvoice ret_var = Invoice_clone(arg);
47295 int64_t ret_ref = 0;
47296 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47297 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47298 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47299 ret_ref = (uintptr_t)ret_var.inner;
47300 if (ret_var.is_owned) {
47301         ret_ref |= 1;
47302 }
47303         return ret_ref;
47304 }
47305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47306         LDKInvoice arg_conv;
47307         arg_conv.inner = (void*)(arg & (~1));
47308         arg_conv.is_owned = false;
47309         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47310         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
47311         return ret_conv;
47312 }
47313
47314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47315         LDKInvoice orig_conv;
47316         orig_conv.inner = (void*)(orig & (~1));
47317         orig_conv.is_owned = false;
47318         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47319         LDKInvoice ret_var = Invoice_clone(&orig_conv);
47320         int64_t ret_ref = 0;
47321         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47322         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47324         ret_ref = (uintptr_t)ret_var.inner;
47325         if (ret_var.is_owned) {
47326                 ret_ref |= 1;
47327         }
47328         return ret_ref;
47329 }
47330
47331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47332         LDKSignedRawInvoice this_obj_conv;
47333         this_obj_conv.inner = (void*)(this_obj & (~1));
47334         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47336         SignedRawInvoice_free(this_obj_conv);
47337 }
47338
47339 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47340         LDKSignedRawInvoice a_conv;
47341         a_conv.inner = (void*)(a & (~1));
47342         a_conv.is_owned = false;
47343         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47344         LDKSignedRawInvoice b_conv;
47345         b_conv.inner = (void*)(b & (~1));
47346         b_conv.is_owned = false;
47347         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47348         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
47349         return ret_conv;
47350 }
47351
47352 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
47353         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
47354 int64_t ret_ref = 0;
47355 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47356 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47357 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47358 ret_ref = (uintptr_t)ret_var.inner;
47359 if (ret_var.is_owned) {
47360         ret_ref |= 1;
47361 }
47362         return ret_ref;
47363 }
47364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47365         LDKSignedRawInvoice arg_conv;
47366         arg_conv.inner = (void*)(arg & (~1));
47367         arg_conv.is_owned = false;
47368         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47369         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
47370         return ret_conv;
47371 }
47372
47373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47374         LDKSignedRawInvoice orig_conv;
47375         orig_conv.inner = (void*)(orig & (~1));
47376         orig_conv.is_owned = false;
47377         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47378         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
47379         int64_t ret_ref = 0;
47380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47383         ret_ref = (uintptr_t)ret_var.inner;
47384         if (ret_var.is_owned) {
47385                 ret_ref |= 1;
47386         }
47387         return ret_ref;
47388 }
47389
47390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47391         LDKRawInvoice this_obj_conv;
47392         this_obj_conv.inner = (void*)(this_obj & (~1));
47393         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47395         RawInvoice_free(this_obj_conv);
47396 }
47397
47398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
47399         LDKRawInvoice this_ptr_conv;
47400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47401         this_ptr_conv.is_owned = false;
47402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47403         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
47404         int64_t ret_ref = 0;
47405         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47406         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47408         ret_ref = (uintptr_t)ret_var.inner;
47409         if (ret_var.is_owned) {
47410                 ret_ref |= 1;
47411         }
47412         return ret_ref;
47413 }
47414
47415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47416         LDKRawInvoice this_ptr_conv;
47417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47418         this_ptr_conv.is_owned = false;
47419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47420         LDKRawDataPart val_conv;
47421         val_conv.inner = (void*)(val & (~1));
47422         val_conv.is_owned = (val & 1) || (val == 0);
47423         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47424         val_conv = RawDataPart_clone(&val_conv);
47425         RawInvoice_set_data(&this_ptr_conv, val_conv);
47426 }
47427
47428 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47429         LDKRawInvoice a_conv;
47430         a_conv.inner = (void*)(a & (~1));
47431         a_conv.is_owned = false;
47432         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47433         LDKRawInvoice b_conv;
47434         b_conv.inner = (void*)(b & (~1));
47435         b_conv.is_owned = false;
47436         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47437         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
47438         return ret_conv;
47439 }
47440
47441 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
47442         LDKRawInvoice ret_var = RawInvoice_clone(arg);
47443 int64_t ret_ref = 0;
47444 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47445 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47446 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47447 ret_ref = (uintptr_t)ret_var.inner;
47448 if (ret_var.is_owned) {
47449         ret_ref |= 1;
47450 }
47451         return ret_ref;
47452 }
47453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47454         LDKRawInvoice arg_conv;
47455         arg_conv.inner = (void*)(arg & (~1));
47456         arg_conv.is_owned = false;
47457         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47458         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
47459         return ret_conv;
47460 }
47461
47462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47463         LDKRawInvoice orig_conv;
47464         orig_conv.inner = (void*)(orig & (~1));
47465         orig_conv.is_owned = false;
47466         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47467         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
47468         int64_t ret_ref = 0;
47469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47472         ret_ref = (uintptr_t)ret_var.inner;
47473         if (ret_var.is_owned) {
47474                 ret_ref |= 1;
47475         }
47476         return ret_ref;
47477 }
47478
47479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47480         LDKRawDataPart this_obj_conv;
47481         this_obj_conv.inner = (void*)(this_obj & (~1));
47482         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47484         RawDataPart_free(this_obj_conv);
47485 }
47486
47487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
47488         LDKRawDataPart this_ptr_conv;
47489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47490         this_ptr_conv.is_owned = false;
47491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47492         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
47493         int64_t ret_ref = 0;
47494         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47495         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47497         ret_ref = (uintptr_t)ret_var.inner;
47498         if (ret_var.is_owned) {
47499                 ret_ref |= 1;
47500         }
47501         return ret_ref;
47502 }
47503
47504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47505         LDKRawDataPart this_ptr_conv;
47506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47507         this_ptr_conv.is_owned = false;
47508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47509         LDKPositiveTimestamp val_conv;
47510         val_conv.inner = (void*)(val & (~1));
47511         val_conv.is_owned = (val & 1) || (val == 0);
47512         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47513         val_conv = PositiveTimestamp_clone(&val_conv);
47514         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
47515 }
47516
47517 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47518         LDKRawDataPart a_conv;
47519         a_conv.inner = (void*)(a & (~1));
47520         a_conv.is_owned = false;
47521         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47522         LDKRawDataPart b_conv;
47523         b_conv.inner = (void*)(b & (~1));
47524         b_conv.is_owned = false;
47525         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47526         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
47527         return ret_conv;
47528 }
47529
47530 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
47531         LDKRawDataPart ret_var = RawDataPart_clone(arg);
47532 int64_t ret_ref = 0;
47533 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47534 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47535 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47536 ret_ref = (uintptr_t)ret_var.inner;
47537 if (ret_var.is_owned) {
47538         ret_ref |= 1;
47539 }
47540         return ret_ref;
47541 }
47542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47543         LDKRawDataPart arg_conv;
47544         arg_conv.inner = (void*)(arg & (~1));
47545         arg_conv.is_owned = false;
47546         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47547         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
47548         return ret_conv;
47549 }
47550
47551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47552         LDKRawDataPart orig_conv;
47553         orig_conv.inner = (void*)(orig & (~1));
47554         orig_conv.is_owned = false;
47555         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47556         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
47557         int64_t ret_ref = 0;
47558         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47559         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47561         ret_ref = (uintptr_t)ret_var.inner;
47562         if (ret_var.is_owned) {
47563                 ret_ref |= 1;
47564         }
47565         return ret_ref;
47566 }
47567
47568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47569         LDKPositiveTimestamp this_obj_conv;
47570         this_obj_conv.inner = (void*)(this_obj & (~1));
47571         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47573         PositiveTimestamp_free(this_obj_conv);
47574 }
47575
47576 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47577         LDKPositiveTimestamp a_conv;
47578         a_conv.inner = (void*)(a & (~1));
47579         a_conv.is_owned = false;
47580         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47581         LDKPositiveTimestamp b_conv;
47582         b_conv.inner = (void*)(b & (~1));
47583         b_conv.is_owned = false;
47584         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47585         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
47586         return ret_conv;
47587 }
47588
47589 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
47590         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
47591 int64_t ret_ref = 0;
47592 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47593 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47594 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47595 ret_ref = (uintptr_t)ret_var.inner;
47596 if (ret_var.is_owned) {
47597         ret_ref |= 1;
47598 }
47599         return ret_ref;
47600 }
47601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47602         LDKPositiveTimestamp arg_conv;
47603         arg_conv.inner = (void*)(arg & (~1));
47604         arg_conv.is_owned = false;
47605         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47606         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
47607         return ret_conv;
47608 }
47609
47610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47611         LDKPositiveTimestamp orig_conv;
47612         orig_conv.inner = (void*)(orig & (~1));
47613         orig_conv.is_owned = false;
47614         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47615         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
47616         int64_t ret_ref = 0;
47617         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47618         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47620         ret_ref = (uintptr_t)ret_var.inner;
47621         if (ret_var.is_owned) {
47622                 ret_ref |= 1;
47623         }
47624         return ret_ref;
47625 }
47626
47627 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47628         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
47629         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
47630         return ret_conv;
47631 }
47632
47633 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
47634         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
47635         return ret_conv;
47636 }
47637
47638 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
47639         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
47640         return ret_conv;
47641 }
47642
47643 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
47644         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
47645         return ret_conv;
47646 }
47647
47648 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
47649         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
47650         return ret_conv;
47651 }
47652
47653 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47654         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
47655         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
47656         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
47657         return ret_conv;
47658 }
47659
47660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
47661         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
47662         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
47663         return ret_conv;
47664 }
47665
47666 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47667         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
47668         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
47669         return ret_conv;
47670 }
47671
47672 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
47673         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
47674         return ret_conv;
47675 }
47676
47677 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
47678         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
47679         return ret_conv;
47680 }
47681
47682 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
47683         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
47684         return ret_conv;
47685 }
47686
47687 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
47688         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
47689         return ret_conv;
47690 }
47691
47692 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
47693         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
47694         return ret_conv;
47695 }
47696
47697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
47698         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
47699         int64_t ret_conv = Currency_hash(o_conv);
47700         return ret_conv;
47701 }
47702
47703 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47704         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
47705         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
47706         jboolean ret_conv = Currency_eq(a_conv, b_conv);
47707         return ret_conv;
47708 }
47709
47710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47711         LDKSha256 this_obj_conv;
47712         this_obj_conv.inner = (void*)(this_obj & (~1));
47713         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47715         Sha256_free(this_obj_conv);
47716 }
47717
47718 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
47719         LDKSha256 ret_var = Sha256_clone(arg);
47720 int64_t ret_ref = 0;
47721 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47722 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47723 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47724 ret_ref = (uintptr_t)ret_var.inner;
47725 if (ret_var.is_owned) {
47726         ret_ref |= 1;
47727 }
47728         return ret_ref;
47729 }
47730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47731         LDKSha256 arg_conv;
47732         arg_conv.inner = (void*)(arg & (~1));
47733         arg_conv.is_owned = false;
47734         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47735         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
47736         return ret_conv;
47737 }
47738
47739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47740         LDKSha256 orig_conv;
47741         orig_conv.inner = (void*)(orig & (~1));
47742         orig_conv.is_owned = false;
47743         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47744         LDKSha256 ret_var = Sha256_clone(&orig_conv);
47745         int64_t ret_ref = 0;
47746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47749         ret_ref = (uintptr_t)ret_var.inner;
47750         if (ret_var.is_owned) {
47751                 ret_ref |= 1;
47752         }
47753         return ret_ref;
47754 }
47755
47756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
47757         LDKSha256 o_conv;
47758         o_conv.inner = (void*)(o & (~1));
47759         o_conv.is_owned = false;
47760         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47761         int64_t ret_conv = Sha256_hash(&o_conv);
47762         return ret_conv;
47763 }
47764
47765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47766         LDKSha256 a_conv;
47767         a_conv.inner = (void*)(a & (~1));
47768         a_conv.is_owned = false;
47769         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47770         LDKSha256 b_conv;
47771         b_conv.inner = (void*)(b & (~1));
47772         b_conv.is_owned = false;
47773         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47774         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
47775         return ret_conv;
47776 }
47777
47778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47779         LDKDescription this_obj_conv;
47780         this_obj_conv.inner = (void*)(this_obj & (~1));
47781         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47783         Description_free(this_obj_conv);
47784 }
47785
47786 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
47787         LDKDescription ret_var = Description_clone(arg);
47788 int64_t ret_ref = 0;
47789 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47790 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47791 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47792 ret_ref = (uintptr_t)ret_var.inner;
47793 if (ret_var.is_owned) {
47794         ret_ref |= 1;
47795 }
47796         return ret_ref;
47797 }
47798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47799         LDKDescription arg_conv;
47800         arg_conv.inner = (void*)(arg & (~1));
47801         arg_conv.is_owned = false;
47802         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47803         int64_t ret_conv = Description_clone_ptr(&arg_conv);
47804         return ret_conv;
47805 }
47806
47807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47808         LDKDescription orig_conv;
47809         orig_conv.inner = (void*)(orig & (~1));
47810         orig_conv.is_owned = false;
47811         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47812         LDKDescription ret_var = Description_clone(&orig_conv);
47813         int64_t ret_ref = 0;
47814         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47815         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47817         ret_ref = (uintptr_t)ret_var.inner;
47818         if (ret_var.is_owned) {
47819                 ret_ref |= 1;
47820         }
47821         return ret_ref;
47822 }
47823
47824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
47825         LDKDescription o_conv;
47826         o_conv.inner = (void*)(o & (~1));
47827         o_conv.is_owned = false;
47828         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47829         int64_t ret_conv = Description_hash(&o_conv);
47830         return ret_conv;
47831 }
47832
47833 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47834         LDKDescription a_conv;
47835         a_conv.inner = (void*)(a & (~1));
47836         a_conv.is_owned = false;
47837         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47838         LDKDescription b_conv;
47839         b_conv.inner = (void*)(b & (~1));
47840         b_conv.is_owned = false;
47841         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47842         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
47843         return ret_conv;
47844 }
47845
47846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47847         LDKPayeePubKey this_obj_conv;
47848         this_obj_conv.inner = (void*)(this_obj & (~1));
47849         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47851         PayeePubKey_free(this_obj_conv);
47852 }
47853
47854 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
47855         LDKPayeePubKey this_ptr_conv;
47856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47857         this_ptr_conv.is_owned = false;
47858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47859         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47860         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
47861         return ret_arr;
47862 }
47863
47864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
47865         LDKPayeePubKey this_ptr_conv;
47866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47867         this_ptr_conv.is_owned = false;
47868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47869         LDKPublicKey val_ref;
47870         CHECK((*env)->GetArrayLength(env, val) == 33);
47871         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
47872         PayeePubKey_set_a(&this_ptr_conv, val_ref);
47873 }
47874
47875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
47876         LDKPublicKey a_arg_ref;
47877         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
47878         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
47879         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
47880         int64_t ret_ref = 0;
47881         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47882         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47884         ret_ref = (uintptr_t)ret_var.inner;
47885         if (ret_var.is_owned) {
47886                 ret_ref |= 1;
47887         }
47888         return ret_ref;
47889 }
47890
47891 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
47892         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
47893 int64_t ret_ref = 0;
47894 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47895 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47896 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47897 ret_ref = (uintptr_t)ret_var.inner;
47898 if (ret_var.is_owned) {
47899         ret_ref |= 1;
47900 }
47901         return ret_ref;
47902 }
47903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47904         LDKPayeePubKey arg_conv;
47905         arg_conv.inner = (void*)(arg & (~1));
47906         arg_conv.is_owned = false;
47907         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47908         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
47909         return ret_conv;
47910 }
47911
47912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47913         LDKPayeePubKey orig_conv;
47914         orig_conv.inner = (void*)(orig & (~1));
47915         orig_conv.is_owned = false;
47916         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47917         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
47918         int64_t ret_ref = 0;
47919         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47920         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47922         ret_ref = (uintptr_t)ret_var.inner;
47923         if (ret_var.is_owned) {
47924                 ret_ref |= 1;
47925         }
47926         return ret_ref;
47927 }
47928
47929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
47930         LDKPayeePubKey o_conv;
47931         o_conv.inner = (void*)(o & (~1));
47932         o_conv.is_owned = false;
47933         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47934         int64_t ret_conv = PayeePubKey_hash(&o_conv);
47935         return ret_conv;
47936 }
47937
47938 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47939         LDKPayeePubKey a_conv;
47940         a_conv.inner = (void*)(a & (~1));
47941         a_conv.is_owned = false;
47942         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47943         LDKPayeePubKey b_conv;
47944         b_conv.inner = (void*)(b & (~1));
47945         b_conv.is_owned = false;
47946         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47947         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
47948         return ret_conv;
47949 }
47950
47951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47952         LDKExpiryTime this_obj_conv;
47953         this_obj_conv.inner = (void*)(this_obj & (~1));
47954         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47956         ExpiryTime_free(this_obj_conv);
47957 }
47958
47959 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
47960         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
47961 int64_t ret_ref = 0;
47962 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47963 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47964 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47965 ret_ref = (uintptr_t)ret_var.inner;
47966 if (ret_var.is_owned) {
47967         ret_ref |= 1;
47968 }
47969         return ret_ref;
47970 }
47971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47972         LDKExpiryTime arg_conv;
47973         arg_conv.inner = (void*)(arg & (~1));
47974         arg_conv.is_owned = false;
47975         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47976         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
47977         return ret_conv;
47978 }
47979
47980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47981         LDKExpiryTime orig_conv;
47982         orig_conv.inner = (void*)(orig & (~1));
47983         orig_conv.is_owned = false;
47984         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47985         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
47986         int64_t ret_ref = 0;
47987         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47988         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47990         ret_ref = (uintptr_t)ret_var.inner;
47991         if (ret_var.is_owned) {
47992                 ret_ref |= 1;
47993         }
47994         return ret_ref;
47995 }
47996
47997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
47998         LDKExpiryTime o_conv;
47999         o_conv.inner = (void*)(o & (~1));
48000         o_conv.is_owned = false;
48001         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48002         int64_t ret_conv = ExpiryTime_hash(&o_conv);
48003         return ret_conv;
48004 }
48005
48006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48007         LDKExpiryTime a_conv;
48008         a_conv.inner = (void*)(a & (~1));
48009         a_conv.is_owned = false;
48010         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48011         LDKExpiryTime b_conv;
48012         b_conv.inner = (void*)(b & (~1));
48013         b_conv.is_owned = false;
48014         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48015         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
48016         return ret_conv;
48017 }
48018
48019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48020         LDKMinFinalCltvExpiry this_obj_conv;
48021         this_obj_conv.inner = (void*)(this_obj & (~1));
48022         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48024         MinFinalCltvExpiry_free(this_obj_conv);
48025 }
48026
48027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
48028         LDKMinFinalCltvExpiry this_ptr_conv;
48029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
48030         this_ptr_conv.is_owned = false;
48031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48032         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
48033         return ret_conv;
48034 }
48035
48036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48037         LDKMinFinalCltvExpiry this_ptr_conv;
48038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
48039         this_ptr_conv.is_owned = false;
48040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48041         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
48042 }
48043
48044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
48045         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
48046         int64_t ret_ref = 0;
48047         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48048         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48049         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48050         ret_ref = (uintptr_t)ret_var.inner;
48051         if (ret_var.is_owned) {
48052                 ret_ref |= 1;
48053         }
48054         return ret_ref;
48055 }
48056
48057 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
48058         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
48059 int64_t ret_ref = 0;
48060 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48061 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48062 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48063 ret_ref = (uintptr_t)ret_var.inner;
48064 if (ret_var.is_owned) {
48065         ret_ref |= 1;
48066 }
48067         return ret_ref;
48068 }
48069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48070         LDKMinFinalCltvExpiry arg_conv;
48071         arg_conv.inner = (void*)(arg & (~1));
48072         arg_conv.is_owned = false;
48073         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48074         int64_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
48075         return ret_conv;
48076 }
48077
48078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48079         LDKMinFinalCltvExpiry orig_conv;
48080         orig_conv.inner = (void*)(orig & (~1));
48081         orig_conv.is_owned = false;
48082         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48083         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
48084         int64_t ret_ref = 0;
48085         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48086         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48087         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48088         ret_ref = (uintptr_t)ret_var.inner;
48089         if (ret_var.is_owned) {
48090                 ret_ref |= 1;
48091         }
48092         return ret_ref;
48093 }
48094
48095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
48096         LDKMinFinalCltvExpiry o_conv;
48097         o_conv.inner = (void*)(o & (~1));
48098         o_conv.is_owned = false;
48099         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48100         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
48101         return ret_conv;
48102 }
48103
48104 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48105         LDKMinFinalCltvExpiry a_conv;
48106         a_conv.inner = (void*)(a & (~1));
48107         a_conv.is_owned = false;
48108         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48109         LDKMinFinalCltvExpiry b_conv;
48110         b_conv.inner = (void*)(b & (~1));
48111         b_conv.is_owned = false;
48112         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48113         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
48114         return ret_conv;
48115 }
48116
48117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48118         if ((this_ptr & 1) != 0) return;
48119         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
48120         CHECK_ACCESS(this_ptr_ptr);
48121         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
48122         FREE((void*)this_ptr);
48123         Fallback_free(this_ptr_conv);
48124 }
48125
48126 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
48127         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48128         *ret_copy = Fallback_clone(arg);
48129 int64_t ret_ref = (uintptr_t)ret_copy;
48130         return ret_ref;
48131 }
48132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48133         LDKFallback* arg_conv = (LDKFallback*)arg;
48134         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
48135         return ret_conv;
48136 }
48137
48138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48139         LDKFallback* orig_conv = (LDKFallback*)orig;
48140         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48141         *ret_copy = Fallback_clone(orig_conv);
48142         int64_t ret_ref = (uintptr_t)ret_copy;
48143         return ret_ref;
48144 }
48145
48146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
48147         
48148         LDKCVec_u8Z program_ref;
48149         program_ref.datalen = (*env)->GetArrayLength(env, program);
48150         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
48151         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
48152         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48153         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
48154         int64_t ret_ref = (uintptr_t)ret_copy;
48155         return ret_ref;
48156 }
48157
48158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
48159         LDKTwentyBytes a_ref;
48160         CHECK((*env)->GetArrayLength(env, a) == 20);
48161         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
48162         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48163         *ret_copy = Fallback_pub_key_hash(a_ref);
48164         int64_t ret_ref = (uintptr_t)ret_copy;
48165         return ret_ref;
48166 }
48167
48168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
48169         LDKTwentyBytes a_ref;
48170         CHECK((*env)->GetArrayLength(env, a) == 20);
48171         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
48172         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48173         *ret_copy = Fallback_script_hash(a_ref);
48174         int64_t ret_ref = (uintptr_t)ret_copy;
48175         return ret_ref;
48176 }
48177
48178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
48179         LDKFallback* o_conv = (LDKFallback*)o;
48180         int64_t ret_conv = Fallback_hash(o_conv);
48181         return ret_conv;
48182 }
48183
48184 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48185         LDKFallback* a_conv = (LDKFallback*)a;
48186         LDKFallback* b_conv = (LDKFallback*)b;
48187         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
48188         return ret_conv;
48189 }
48190
48191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48192         LDKInvoiceSignature this_obj_conv;
48193         this_obj_conv.inner = (void*)(this_obj & (~1));
48194         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48196         InvoiceSignature_free(this_obj_conv);
48197 }
48198
48199 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
48200         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
48201 int64_t ret_ref = 0;
48202 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48203 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48204 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48205 ret_ref = (uintptr_t)ret_var.inner;
48206 if (ret_var.is_owned) {
48207         ret_ref |= 1;
48208 }
48209         return ret_ref;
48210 }
48211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48212         LDKInvoiceSignature arg_conv;
48213         arg_conv.inner = (void*)(arg & (~1));
48214         arg_conv.is_owned = false;
48215         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48216         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
48217         return ret_conv;
48218 }
48219
48220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48221         LDKInvoiceSignature orig_conv;
48222         orig_conv.inner = (void*)(orig & (~1));
48223         orig_conv.is_owned = false;
48224         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48225         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
48226         int64_t ret_ref = 0;
48227         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48228         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48230         ret_ref = (uintptr_t)ret_var.inner;
48231         if (ret_var.is_owned) {
48232                 ret_ref |= 1;
48233         }
48234         return ret_ref;
48235 }
48236
48237 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48238         LDKInvoiceSignature a_conv;
48239         a_conv.inner = (void*)(a & (~1));
48240         a_conv.is_owned = false;
48241         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48242         LDKInvoiceSignature b_conv;
48243         b_conv.inner = (void*)(b & (~1));
48244         b_conv.is_owned = false;
48245         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48246         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
48247         return ret_conv;
48248 }
48249
48250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48251         LDKPrivateRoute this_obj_conv;
48252         this_obj_conv.inner = (void*)(this_obj & (~1));
48253         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48255         PrivateRoute_free(this_obj_conv);
48256 }
48257
48258 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
48259         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
48260 int64_t ret_ref = 0;
48261 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48262 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48263 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48264 ret_ref = (uintptr_t)ret_var.inner;
48265 if (ret_var.is_owned) {
48266         ret_ref |= 1;
48267 }
48268         return ret_ref;
48269 }
48270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48271         LDKPrivateRoute arg_conv;
48272         arg_conv.inner = (void*)(arg & (~1));
48273         arg_conv.is_owned = false;
48274         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48275         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
48276         return ret_conv;
48277 }
48278
48279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48280         LDKPrivateRoute orig_conv;
48281         orig_conv.inner = (void*)(orig & (~1));
48282         orig_conv.is_owned = false;
48283         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48284         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
48285         int64_t ret_ref = 0;
48286         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48287         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48289         ret_ref = (uintptr_t)ret_var.inner;
48290         if (ret_var.is_owned) {
48291                 ret_ref |= 1;
48292         }
48293         return ret_ref;
48294 }
48295
48296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
48297         LDKPrivateRoute o_conv;
48298         o_conv.inner = (void*)(o & (~1));
48299         o_conv.is_owned = false;
48300         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48301         int64_t ret_conv = PrivateRoute_hash(&o_conv);
48302         return ret_conv;
48303 }
48304
48305 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48306         LDKPrivateRoute a_conv;
48307         a_conv.inner = (void*)(a & (~1));
48308         a_conv.is_owned = false;
48309         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48310         LDKPrivateRoute b_conv;
48311         b_conv.inner = (void*)(b & (~1));
48312         b_conv.is_owned = false;
48313         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48314         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
48315         return ret_conv;
48316 }
48317
48318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
48319         LDKSignedRawInvoice this_arg_conv;
48320         this_arg_conv.inner = (void*)(this_arg & (~1));
48321         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
48322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48323         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
48324         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
48325         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
48326         return ((int64_t)ret_conv);
48327 }
48328
48329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
48330         LDKSignedRawInvoice this_arg_conv;
48331         this_arg_conv.inner = (void*)(this_arg & (~1));
48332         this_arg_conv.is_owned = false;
48333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48334         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
48335         int64_t ret_ref = 0;
48336         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48337         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48339         ret_ref = (uintptr_t)ret_var.inner;
48340         if (ret_var.is_owned) {
48341                 ret_ref |= 1;
48342         }
48343         return ret_ref;
48344 }
48345
48346 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48347         LDKSignedRawInvoice this_arg_conv;
48348         this_arg_conv.inner = (void*)(this_arg & (~1));
48349         this_arg_conv.is_owned = false;
48350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48351         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48352         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
48353         return ret_arr;
48354 }
48355
48356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
48357         LDKSignedRawInvoice this_arg_conv;
48358         this_arg_conv.inner = (void*)(this_arg & (~1));
48359         this_arg_conv.is_owned = false;
48360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48361         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
48362         int64_t ret_ref = 0;
48363         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48364         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48366         ret_ref = (uintptr_t)ret_var.inner;
48367         if (ret_var.is_owned) {
48368                 ret_ref |= 1;
48369         }
48370         return ret_ref;
48371 }
48372
48373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
48374         LDKSignedRawInvoice this_arg_conv;
48375         this_arg_conv.inner = (void*)(this_arg & (~1));
48376         this_arg_conv.is_owned = false;
48377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48378         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
48379         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
48380         return (int64_t)ret_conv;
48381 }
48382
48383 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
48384         LDKSignedRawInvoice this_arg_conv;
48385         this_arg_conv.inner = (void*)(this_arg & (~1));
48386         this_arg_conv.is_owned = false;
48387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48388         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
48389         return ret_conv;
48390 }
48391
48392 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48393         LDKRawInvoice this_arg_conv;
48394         this_arg_conv.inner = (void*)(this_arg & (~1));
48395         this_arg_conv.is_owned = false;
48396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48397         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48398         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
48399         return ret_arr;
48400 }
48401
48402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48403         LDKRawInvoice this_arg_conv;
48404         this_arg_conv.inner = (void*)(this_arg & (~1));
48405         this_arg_conv.is_owned = false;
48406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48407         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
48408         int64_t ret_ref = 0;
48409         if ((uintptr_t)ret_var.inner > 4096) {
48410                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48411                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48413                 ret_ref = (uintptr_t)ret_var.inner;
48414                 if (ret_var.is_owned) {
48415                         ret_ref |= 1;
48416                 }
48417         }
48418         return ret_ref;
48419 }
48420
48421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
48422         LDKRawInvoice this_arg_conv;
48423         this_arg_conv.inner = (void*)(this_arg & (~1));
48424         this_arg_conv.is_owned = false;
48425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48426         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
48427         int64_t ret_ref = 0;
48428         if ((uintptr_t)ret_var.inner > 4096) {
48429                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48430                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48432                 ret_ref = (uintptr_t)ret_var.inner;
48433                 if (ret_var.is_owned) {
48434                         ret_ref |= 1;
48435                 }
48436         }
48437         return ret_ref;
48438 }
48439
48440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
48441         LDKRawInvoice this_arg_conv;
48442         this_arg_conv.inner = (void*)(this_arg & (~1));
48443         this_arg_conv.is_owned = false;
48444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48445         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
48446         int64_t ret_ref = 0;
48447         if ((uintptr_t)ret_var.inner > 4096) {
48448                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48449                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48451                 ret_ref = (uintptr_t)ret_var.inner;
48452                 if (ret_var.is_owned) {
48453                         ret_ref |= 1;
48454                 }
48455         }
48456         return ret_ref;
48457 }
48458
48459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48460         LDKRawInvoice this_arg_conv;
48461         this_arg_conv.inner = (void*)(this_arg & (~1));
48462         this_arg_conv.is_owned = false;
48463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48464         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
48465         int64_t ret_ref = 0;
48466         if ((uintptr_t)ret_var.inner > 4096) {
48467                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48468                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48470                 ret_ref = (uintptr_t)ret_var.inner;
48471                 if (ret_var.is_owned) {
48472                         ret_ref |= 1;
48473                 }
48474         }
48475         return ret_ref;
48476 }
48477
48478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
48479         LDKRawInvoice this_arg_conv;
48480         this_arg_conv.inner = (void*)(this_arg & (~1));
48481         this_arg_conv.is_owned = false;
48482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48483         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
48484         int64_t ret_ref = 0;
48485         if ((uintptr_t)ret_var.inner > 4096) {
48486                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48487                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48488         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48489                 ret_ref = (uintptr_t)ret_var.inner;
48490                 if (ret_var.is_owned) {
48491                         ret_ref |= 1;
48492                 }
48493         }
48494         return ret_ref;
48495 }
48496
48497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
48498         LDKRawInvoice this_arg_conv;
48499         this_arg_conv.inner = (void*)(this_arg & (~1));
48500         this_arg_conv.is_owned = false;
48501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48502         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
48503         int64_t ret_ref = 0;
48504         if ((uintptr_t)ret_var.inner > 4096) {
48505                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48506                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48508                 ret_ref = (uintptr_t)ret_var.inner;
48509                 if (ret_var.is_owned) {
48510                         ret_ref |= 1;
48511                 }
48512         }
48513         return ret_ref;
48514 }
48515
48516 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
48517         LDKRawInvoice this_arg_conv;
48518         this_arg_conv.inner = (void*)(this_arg & (~1));
48519         this_arg_conv.is_owned = false;
48520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48521         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48522         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
48523         return ret_arr;
48524 }
48525
48526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
48527         LDKRawInvoice this_arg_conv;
48528         this_arg_conv.inner = (void*)(this_arg & (~1));
48529         this_arg_conv.is_owned = false;
48530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48531         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
48532         int64_t ret_ref = 0;
48533         if ((uintptr_t)ret_var.inner > 4096) {
48534                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48535                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48537                 ret_ref = (uintptr_t)ret_var.inner;
48538                 if (ret_var.is_owned) {
48539                         ret_ref |= 1;
48540                 }
48541         }
48542         return ret_ref;
48543 }
48544
48545 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
48546         LDKRawInvoice this_arg_conv;
48547         this_arg_conv.inner = (void*)(this_arg & (~1));
48548         this_arg_conv.is_owned = false;
48549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48550         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
48551         int64_tArray ret_arr = NULL;
48552         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48553         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48554         for (size_t o = 0; o < ret_var.datalen; o++) {
48555                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
48556                 int64_t ret_conv_14_ref = 0;
48557                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48558                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48559                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
48560                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
48561                 if (ret_conv_14_var.is_owned) {
48562                         ret_conv_14_ref |= 1;
48563                 }
48564                 ret_arr_ptr[o] = ret_conv_14_ref;
48565         }
48566         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48567         FREE(ret_var.data);
48568         return ret_arr;
48569 }
48570
48571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
48572         LDKRawInvoice this_arg_conv;
48573         this_arg_conv.inner = (void*)(this_arg & (~1));
48574         this_arg_conv.is_owned = false;
48575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48576         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
48577         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
48578         int64_t ret_ref = (uintptr_t)ret_copy;
48579         return ret_ref;
48580 }
48581
48582 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
48583         LDKRawInvoice this_arg_conv;
48584         this_arg_conv.inner = (void*)(this_arg & (~1));
48585         this_arg_conv.is_owned = false;
48586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48587         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
48588         return ret_conv;
48589 }
48590
48591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
48592         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
48593         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
48594         return (int64_t)ret_conv;
48595 }
48596
48597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
48598         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
48599         *ret_conv = PositiveTimestamp_from_system_time(time);
48600         return (int64_t)ret_conv;
48601 }
48602
48603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
48604         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
48605         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
48606         return (int64_t)ret_conv;
48607 }
48608
48609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
48610         LDKPositiveTimestamp this_arg_conv;
48611         this_arg_conv.inner = (void*)(this_arg & (~1));
48612         this_arg_conv.is_owned = false;
48613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48614         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
48615         return ret_conv;
48616 }
48617
48618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
48619         LDKPositiveTimestamp this_arg_conv;
48620         this_arg_conv.inner = (void*)(this_arg & (~1));
48621         this_arg_conv.is_owned = false;
48622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48623         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
48624         return ret_conv;
48625 }
48626
48627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
48628         LDKPositiveTimestamp this_arg_conv;
48629         this_arg_conv.inner = (void*)(this_arg & (~1));
48630         this_arg_conv.is_owned = false;
48631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48632         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
48633         return ret_conv;
48634 }
48635
48636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
48637         LDKInvoice this_arg_conv;
48638         this_arg_conv.inner = (void*)(this_arg & (~1));
48639         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
48640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48641         this_arg_conv = Invoice_clone(&this_arg_conv);
48642         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
48643         int64_t ret_ref = 0;
48644         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48645         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48647         ret_ref = (uintptr_t)ret_var.inner;
48648         if (ret_var.is_owned) {
48649                 ret_ref |= 1;
48650         }
48651         return ret_ref;
48652 }
48653
48654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
48655         LDKInvoice this_arg_conv;
48656         this_arg_conv.inner = (void*)(this_arg & (~1));
48657         this_arg_conv.is_owned = false;
48658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48659         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
48660         *ret_conv = Invoice_check_signature(&this_arg_conv);
48661         return (int64_t)ret_conv;
48662 }
48663
48664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
48665         LDKSignedRawInvoice signed_invoice_conv;
48666         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
48667         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
48668         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
48669         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
48670         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
48671         *ret_conv = Invoice_from_signed(signed_invoice_conv);
48672         return (int64_t)ret_conv;
48673 }
48674
48675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
48676         LDKInvoice this_arg_conv;
48677         this_arg_conv.inner = (void*)(this_arg & (~1));
48678         this_arg_conv.is_owned = false;
48679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48680         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
48681         return ret_conv;
48682 }
48683
48684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
48685         LDKInvoice this_arg_conv;
48686         this_arg_conv.inner = (void*)(this_arg & (~1));
48687         this_arg_conv.is_owned = false;
48688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48689         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
48690         return ret_conv;
48691 }
48692
48693 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
48694         LDKInvoice this_arg_conv;
48695         this_arg_conv.inner = (void*)(this_arg & (~1));
48696         this_arg_conv.is_owned = false;
48697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48698         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48699         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
48700         return ret_arr;
48701 }
48702
48703 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
48704         LDKInvoice this_arg_conv;
48705         this_arg_conv.inner = (void*)(this_arg & (~1));
48706         this_arg_conv.is_owned = false;
48707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48708         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48709         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
48710         return ret_arr;
48711 }
48712
48713 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
48714         LDKInvoice this_arg_conv;
48715         this_arg_conv.inner = (void*)(this_arg & (~1));
48716         this_arg_conv.is_owned = false;
48717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48718         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
48719         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
48720         return ret_arr;
48721 }
48722
48723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
48724         LDKInvoice this_arg_conv;
48725         this_arg_conv.inner = (void*)(this_arg & (~1));
48726         this_arg_conv.is_owned = false;
48727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48728         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
48729         int64_t ret_ref = 0;
48730         if ((uintptr_t)ret_var.inner > 4096) {
48731                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48732                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48734                 ret_ref = (uintptr_t)ret_var.inner;
48735                 if (ret_var.is_owned) {
48736                         ret_ref |= 1;
48737                 }
48738         }
48739         return ret_ref;
48740 }
48741
48742 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
48743         LDKInvoice this_arg_conv;
48744         this_arg_conv.inner = (void*)(this_arg & (~1));
48745         this_arg_conv.is_owned = false;
48746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48747         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48748         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
48749         return ret_arr;
48750 }
48751
48752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
48753         LDKInvoice this_arg_conv;
48754         this_arg_conv.inner = (void*)(this_arg & (~1));
48755         this_arg_conv.is_owned = false;
48756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48757         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
48758         return ret_conv;
48759 }
48760
48761 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
48762         LDKInvoice this_arg_conv;
48763         this_arg_conv.inner = (void*)(this_arg & (~1));
48764         this_arg_conv.is_owned = false;
48765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48766         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
48767         return ret_conv;
48768 }
48769
48770 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
48771         LDKInvoice this_arg_conv;
48772         this_arg_conv.inner = (void*)(this_arg & (~1));
48773         this_arg_conv.is_owned = false;
48774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48775         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
48776         return ret_conv;
48777 }
48778
48779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
48780         LDKInvoice this_arg_conv;
48781         this_arg_conv.inner = (void*)(this_arg & (~1));
48782         this_arg_conv.is_owned = false;
48783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48784         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
48785         return ret_conv;
48786 }
48787
48788 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
48789         LDKInvoice this_arg_conv;
48790         this_arg_conv.inner = (void*)(this_arg & (~1));
48791         this_arg_conv.is_owned = false;
48792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48793         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
48794         int64_tArray ret_arr = NULL;
48795         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48796         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48797         for (size_t o = 0; o < ret_var.datalen; o++) {
48798                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
48799                 int64_t ret_conv_14_ref = 0;
48800                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48801                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48802                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
48803                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
48804                 if (ret_conv_14_var.is_owned) {
48805                         ret_conv_14_ref |= 1;
48806                 }
48807                 ret_arr_ptr[o] = ret_conv_14_ref;
48808         }
48809         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48810         FREE(ret_var.data);
48811         return ret_arr;
48812 }
48813
48814 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
48815         LDKInvoice this_arg_conv;
48816         this_arg_conv.inner = (void*)(this_arg & (~1));
48817         this_arg_conv.is_owned = false;
48818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48819         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
48820         int64_tArray ret_arr = NULL;
48821         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48822         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48823         for (size_t l = 0; l < ret_var.datalen; l++) {
48824                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
48825                 int64_t ret_conv_11_ref = 0;
48826                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48827                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48828                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
48829                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
48830                 if (ret_conv_11_var.is_owned) {
48831                         ret_conv_11_ref |= 1;
48832                 }
48833                 ret_arr_ptr[l] = ret_conv_11_ref;
48834         }
48835         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48836         FREE(ret_var.data);
48837         return ret_arr;
48838 }
48839
48840 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
48841         LDKInvoice this_arg_conv;
48842         this_arg_conv.inner = (void*)(this_arg & (~1));
48843         this_arg_conv.is_owned = false;
48844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48845         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
48846         return ret_conv;
48847 }
48848
48849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
48850         LDKInvoice this_arg_conv;
48851         this_arg_conv.inner = (void*)(this_arg & (~1));
48852         this_arg_conv.is_owned = false;
48853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48854         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
48855         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
48856         int64_t ret_ref = (uintptr_t)ret_copy;
48857         return ret_ref;
48858 }
48859
48860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
48861         LDKStr description_conv = java_to_owned_str(env, description);
48862         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
48863         *ret_conv = Description_new(description_conv);
48864         return (int64_t)ret_conv;
48865 }
48866
48867 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
48868         LDKDescription this_arg_conv;
48869         this_arg_conv.inner = (void*)(this_arg & (~1));
48870         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
48871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48872         this_arg_conv = Description_clone(&this_arg_conv);
48873         LDKStr ret_str = Description_into_inner(this_arg_conv);
48874         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48875         Str_free(ret_str);
48876         return ret_conv;
48877 }
48878
48879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
48880         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
48881         int64_t ret_ref = 0;
48882         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48883         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48885         ret_ref = (uintptr_t)ret_var.inner;
48886         if (ret_var.is_owned) {
48887                 ret_ref |= 1;
48888         }
48889         return ret_ref;
48890 }
48891
48892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
48893         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
48894         int64_t ret_ref = 0;
48895         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48896         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48898         ret_ref = (uintptr_t)ret_var.inner;
48899         if (ret_var.is_owned) {
48900                 ret_ref |= 1;
48901         }
48902         return ret_ref;
48903 }
48904
48905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
48906         LDKExpiryTime this_arg_conv;
48907         this_arg_conv.inner = (void*)(this_arg & (~1));
48908         this_arg_conv.is_owned = false;
48909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48910         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
48911         return ret_conv;
48912 }
48913
48914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
48915         LDKExpiryTime this_arg_conv;
48916         this_arg_conv.inner = (void*)(this_arg & (~1));
48917         this_arg_conv.is_owned = false;
48918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48919         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
48920         return ret_conv;
48921 }
48922
48923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
48924         LDKRouteHint hops_conv;
48925         hops_conv.inner = (void*)(hops & (~1));
48926         hops_conv.is_owned = (hops & 1) || (hops == 0);
48927         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
48928         hops_conv = RouteHint_clone(&hops_conv);
48929         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
48930         *ret_conv = PrivateRoute_new(hops_conv);
48931         return (int64_t)ret_conv;
48932 }
48933
48934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
48935         LDKPrivateRoute this_arg_conv;
48936         this_arg_conv.inner = (void*)(this_arg & (~1));
48937         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
48938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48939         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
48940         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
48941         int64_t ret_ref = 0;
48942         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48943         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48945         ret_ref = (uintptr_t)ret_var.inner;
48946         if (ret_var.is_owned) {
48947                 ret_ref |= 1;
48948         }
48949         return ret_ref;
48950 }
48951
48952 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48953         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
48954         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
48955         return ret_conv;
48956 }
48957
48958 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
48959         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
48960         return ret_conv;
48961 }
48962
48963 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
48964         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
48965         return ret_conv;
48966 }
48967
48968 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
48969         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
48970         return ret_conv;
48971 }
48972
48973 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
48974         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
48975         return ret_conv;
48976 }
48977
48978 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
48979         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
48980         return ret_conv;
48981 }
48982
48983 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48984         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
48985         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
48986         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
48987         return ret_conv;
48988 }
48989
48990 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48991         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
48992         LDKStr ret_str = CreationError_to_str(o_conv);
48993         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48994         Str_free(ret_str);
48995         return ret_conv;
48996 }
48997
48998 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48999         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
49000         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
49001         return ret_conv;
49002 }
49003
49004 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
49005         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
49006         return ret_conv;
49007 }
49008
49009 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
49010         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
49011         return ret_conv;
49012 }
49013
49014 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
49015         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
49016         return ret_conv;
49017 }
49018
49019 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
49020         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
49021         return ret_conv;
49022 }
49023
49024 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
49025         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
49026         return ret_conv;
49027 }
49028
49029 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
49030         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
49031         return ret_conv;
49032 }
49033
49034 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
49035         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
49036         return ret_conv;
49037 }
49038
49039 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
49040         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
49041         return ret_conv;
49042 }
49043
49044 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
49045         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
49046         return ret_conv;
49047 }
49048
49049 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
49050         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
49051         return ret_conv;
49052 }
49053
49054 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49055         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
49056         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
49057         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
49058         return ret_conv;
49059 }
49060
49061 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49062         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
49063         LDKStr ret_str = SemanticError_to_str(o_conv);
49064         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49065         Str_free(ret_str);
49066         return ret_conv;
49067 }
49068
49069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49070         if ((this_ptr & 1) != 0) return;
49071         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49072         CHECK_ACCESS(this_ptr_ptr);
49073         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
49074         FREE((void*)this_ptr);
49075         SignOrCreationError_free(this_ptr_conv);
49076 }
49077
49078 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
49079         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49080         *ret_copy = SignOrCreationError_clone(arg);
49081 int64_t ret_ref = (uintptr_t)ret_copy;
49082         return ret_ref;
49083 }
49084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49085         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
49086         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
49087         return ret_conv;
49088 }
49089
49090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49091         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
49092         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49093         *ret_copy = SignOrCreationError_clone(orig_conv);
49094         int64_t ret_ref = (uintptr_t)ret_copy;
49095         return ret_ref;
49096 }
49097
49098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
49099         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49100         *ret_copy = SignOrCreationError_sign_error();
49101         int64_t ret_ref = (uintptr_t)ret_copy;
49102         return ret_ref;
49103 }
49104
49105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
49106         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
49107         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49108         *ret_copy = SignOrCreationError_creation_error(a_conv);
49109         int64_t ret_ref = (uintptr_t)ret_copy;
49110         return ret_ref;
49111 }
49112
49113 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49114         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
49115         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
49116         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
49117         return ret_conv;
49118 }
49119
49120 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49121         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
49122         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
49123         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49124         Str_free(ret_str);
49125         return ret_conv;
49126 }
49127
49128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49129         LDKInvoicePayer this_obj_conv;
49130         this_obj_conv.inner = (void*)(this_obj & (~1));
49131         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
49132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49133         InvoicePayer_free(this_obj_conv);
49134 }
49135
49136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49137         if ((this_ptr & 1) != 0) return;
49138         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49139         CHECK_ACCESS(this_ptr_ptr);
49140         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
49141         FREE((void*)this_ptr);
49142         Payer_free(this_ptr_conv);
49143 }
49144
49145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49146         if ((this_ptr & 1) != 0) return;
49147         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49148         CHECK_ACCESS(this_ptr_ptr);
49149         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
49150         FREE((void*)this_ptr);
49151         Router_free(this_ptr_conv);
49152 }
49153
49154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49155         if ((this_ptr & 1) != 0) return;
49156         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49157         CHECK_ACCESS(this_ptr_ptr);
49158         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
49159         FREE((void*)this_ptr);
49160         Retry_free(this_ptr_conv);
49161 }
49162
49163 static inline uintptr_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
49164         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49165         *ret_copy = Retry_clone(arg);
49166 int64_t ret_ref = (uintptr_t)ret_copy;
49167         return ret_ref;
49168 }
49169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49170         LDKRetry* arg_conv = (LDKRetry*)arg;
49171         int64_t ret_conv = Retry_clone_ptr(arg_conv);
49172         return ret_conv;
49173 }
49174
49175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49176         LDKRetry* orig_conv = (LDKRetry*)orig;
49177         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49178         *ret_copy = Retry_clone(orig_conv);
49179         int64_t ret_ref = (uintptr_t)ret_copy;
49180         return ret_ref;
49181 }
49182
49183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
49184         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49185         *ret_copy = Retry_attempts(a);
49186         int64_t ret_ref = (uintptr_t)ret_copy;
49187         return ret_ref;
49188 }
49189
49190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
49191         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49192         *ret_copy = Retry_timeout(a);
49193         int64_t ret_ref = (uintptr_t)ret_copy;
49194         return ret_ref;
49195 }
49196
49197 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49198         LDKRetry* a_conv = (LDKRetry*)a;
49199         LDKRetry* b_conv = (LDKRetry*)b;
49200         jboolean ret_conv = Retry_eq(a_conv, b_conv);
49201         return ret_conv;
49202 }
49203
49204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
49205         LDKRetry* o_conv = (LDKRetry*)o;
49206         int64_t ret_conv = Retry_hash(o_conv);
49207         return ret_conv;
49208 }
49209
49210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49211         if ((this_ptr & 1) != 0) return;
49212         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49213         CHECK_ACCESS(this_ptr_ptr);
49214         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
49215         FREE((void*)this_ptr);
49216         PaymentError_free(this_ptr_conv);
49217 }
49218
49219 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
49220         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49221         *ret_copy = PaymentError_clone(arg);
49222 int64_t ret_ref = (uintptr_t)ret_copy;
49223         return ret_ref;
49224 }
49225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49226         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
49227         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
49228         return ret_conv;
49229 }
49230
49231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49232         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
49233         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49234         *ret_copy = PaymentError_clone(orig_conv);
49235         int64_t ret_ref = (uintptr_t)ret_copy;
49236         return ret_ref;
49237 }
49238
49239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
49240         LDKStr a_conv = java_to_owned_str(env, a);
49241         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49242         *ret_copy = PaymentError_invoice(a_conv);
49243         int64_t ret_ref = (uintptr_t)ret_copy;
49244         return ret_ref;
49245 }
49246
49247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
49248         LDKLightningError a_conv;
49249         a_conv.inner = (void*)(a & (~1));
49250         a_conv.is_owned = (a & 1) || (a == 0);
49251         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49252         a_conv = LightningError_clone(&a_conv);
49253         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49254         *ret_copy = PaymentError_routing(a_conv);
49255         int64_t ret_ref = (uintptr_t)ret_copy;
49256         return ret_ref;
49257 }
49258
49259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
49260         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
49261         CHECK_ACCESS(a_ptr);
49262         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
49263         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
49264         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49265         *ret_copy = PaymentError_sending(a_conv);
49266         int64_t ret_ref = (uintptr_t)ret_copy;
49267         return ret_ref;
49268 }
49269
49270 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) {
49271         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
49272         CHECK_ACCESS(payer_ptr);
49273         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
49274         if (payer_conv.free == LDKPayer_JCalls_free) {
49275                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49276                 LDKPayer_JCalls_cloned(&payer_conv);
49277         }
49278         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
49279         CHECK_ACCESS(router_ptr);
49280         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
49281         if (router_conv.free == LDKRouter_JCalls_free) {
49282                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49283                 LDKRouter_JCalls_cloned(&router_conv);
49284         }
49285         LDKMultiThreadedLockableScore scorer_conv;
49286         scorer_conv.inner = (void*)(scorer & (~1));
49287         scorer_conv.is_owned = false;
49288         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
49289         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
49290         CHECK_ACCESS(logger_ptr);
49291         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
49292         if (logger_conv.free == LDKLogger_JCalls_free) {
49293                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49294                 LDKLogger_JCalls_cloned(&logger_conv);
49295         }
49296         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
49297         CHECK_ACCESS(event_handler_ptr);
49298         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
49299         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
49300                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49301                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
49302         }
49303         void* retry_ptr = (void*)(((uintptr_t)retry) & ~1);
49304         CHECK_ACCESS(retry_ptr);
49305         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
49306         retry_conv = Retry_clone((LDKRetry*)(((uintptr_t)retry) & ~1));
49307         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_conv);
49308         int64_t ret_ref = 0;
49309         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49310         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49312         ret_ref = (uintptr_t)ret_var.inner;
49313         if (ret_var.is_owned) {
49314                 ret_ref |= 1;
49315         }
49316         return ret_ref;
49317 }
49318
49319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
49320         LDKInvoicePayer this_arg_conv;
49321         this_arg_conv.inner = (void*)(this_arg & (~1));
49322         this_arg_conv.is_owned = false;
49323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49324         LDKInvoice invoice_conv;
49325         invoice_conv.inner = (void*)(invoice & (~1));
49326         invoice_conv.is_owned = false;
49327         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
49328         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
49329         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
49330         return (int64_t)ret_conv;
49331 }
49332
49333 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) {
49334         LDKInvoicePayer this_arg_conv;
49335         this_arg_conv.inner = (void*)(this_arg & (~1));
49336         this_arg_conv.is_owned = false;
49337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49338         LDKInvoice invoice_conv;
49339         invoice_conv.inner = (void*)(invoice & (~1));
49340         invoice_conv.is_owned = false;
49341         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
49342         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
49343         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
49344         return (int64_t)ret_conv;
49345 }
49346
49347 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) {
49348         LDKInvoicePayer this_arg_conv;
49349         this_arg_conv.inner = (void*)(this_arg & (~1));
49350         this_arg_conv.is_owned = false;
49351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49352         LDKPublicKey pubkey_ref;
49353         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
49354         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
49355         LDKThirtyTwoBytes payment_preimage_ref;
49356         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
49357         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
49358         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
49359         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
49360         return (int64_t)ret_conv;
49361 }
49362
49363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
49364         LDKInvoicePayer this_arg_conv;
49365         this_arg_conv.inner = (void*)(this_arg & (~1));
49366         this_arg_conv.is_owned = false;
49367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49368         unsigned char payment_hash_arr[32];
49369         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
49370         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
49371         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
49372         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
49373 }
49374
49375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
49376         LDKInvoicePayer this_arg_conv;
49377         this_arg_conv.inner = (void*)(this_arg & (~1));
49378         this_arg_conv.is_owned = false;
49379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49380         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
49381         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
49382         return (int64_t)ret_ret;
49383 }
49384
49385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice(JNIEnv *env, jclass clz, int64_t amt_msat, int8_tArray payment_hash, jstring description, int32_t invoice_expiry_delta_secs, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
49386         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49387         CHECK_ACCESS(amt_msat_ptr);
49388         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49389         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49390         LDKThirtyTwoBytes payment_hash_ref;
49391         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
49392         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
49393         LDKStr description_conv = java_to_owned_str(env, description);
49394         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
49395         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
49396         if (phantom_route_hints_constr.datalen > 0)
49397                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
49398         else
49399                 phantom_route_hints_constr.data = NULL;
49400         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
49401         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
49402                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
49403                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
49404                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
49405                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
49406                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
49407                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
49408                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
49409         }
49410         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
49411         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49412         CHECK_ACCESS(keys_manager_ptr);
49413         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49414         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49415                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49416                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49417         }
49418         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49419         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49420         *ret_conv = create_phantom_invoice(amt_msat_conv, payment_hash_ref, description_conv, invoice_expiry_delta_secs, phantom_route_hints_constr, keys_manager_conv, network_conv);
49421         return (int64_t)ret_conv;
49422 }
49423
49424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice_1with_1description_1hash(JNIEnv *env, jclass clz, int64_t amt_msat, int8_tArray payment_hash, int32_t invoice_expiry_delta_secs, int64_t description_hash, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
49425         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49426         CHECK_ACCESS(amt_msat_ptr);
49427         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49428         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49429         LDKThirtyTwoBytes payment_hash_ref;
49430         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
49431         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
49432         LDKSha256 description_hash_conv;
49433         description_hash_conv.inner = (void*)(description_hash & (~1));
49434         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
49435         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
49436         description_hash_conv = Sha256_clone(&description_hash_conv);
49437         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
49438         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
49439         if (phantom_route_hints_constr.datalen > 0)
49440                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
49441         else
49442                 phantom_route_hints_constr.data = NULL;
49443         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
49444         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
49445                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
49446                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
49447                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
49448                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
49449                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
49450                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
49451                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
49452         }
49453         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
49454         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49455         CHECK_ACCESS(keys_manager_ptr);
49456         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49457         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49458                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49459                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49460         }
49461         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49462         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49463         *ret_conv = create_phantom_invoice_with_description_hash(amt_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, description_hash_conv, phantom_route_hints_constr, keys_manager_conv, network_conv);
49464         return (int64_t)ret_conv;
49465 }
49466
49467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, jstring description, int32_t invoice_expiry_delta_secs) {
49468         LDKChannelManager channelmanager_conv;
49469         channelmanager_conv.inner = (void*)(channelmanager & (~1));
49470         channelmanager_conv.is_owned = false;
49471         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
49472         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49473         CHECK_ACCESS(keys_manager_ptr);
49474         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49475         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49476                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49477                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49478         }
49479         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49480         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49481         CHECK_ACCESS(amt_msat_ptr);
49482         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49483         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49484         LDKStr description_conv = java_to_owned_str(env, description);
49485         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49486         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv, invoice_expiry_delta_secs);
49487         return (int64_t)ret_conv;
49488 }
49489
49490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1with_1description_1hash(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, int64_t description_hash, int32_t invoice_expiry_delta_secs) {
49491         LDKChannelManager channelmanager_conv;
49492         channelmanager_conv.inner = (void*)(channelmanager & (~1));
49493         channelmanager_conv.is_owned = false;
49494         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
49495         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49496         CHECK_ACCESS(keys_manager_ptr);
49497         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49498         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49499                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49500                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49501         }
49502         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49503         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49504         CHECK_ACCESS(amt_msat_ptr);
49505         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49506         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49507         LDKSha256 description_hash_conv;
49508         description_hash_conv.inner = (void*)(description_hash & (~1));
49509         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
49510         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
49511         description_hash_conv = Sha256_clone(&description_hash_conv);
49512         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49513         *ret_conv = create_invoice_from_channelmanager_with_description_hash(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_hash_conv, invoice_expiry_delta_secs);
49514         return (int64_t)ret_conv;
49515 }
49516
49517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1with_1description_1hash_1and_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, int64_t description_hash, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
49518         LDKChannelManager channelmanager_conv;
49519         channelmanager_conv.inner = (void*)(channelmanager & (~1));
49520         channelmanager_conv.is_owned = false;
49521         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
49522         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49523         CHECK_ACCESS(keys_manager_ptr);
49524         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49525         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49526                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49527                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49528         }
49529         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49530         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49531         CHECK_ACCESS(amt_msat_ptr);
49532         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49533         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49534         LDKSha256 description_hash_conv;
49535         description_hash_conv.inner = (void*)(description_hash & (~1));
49536         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
49537         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
49538         description_hash_conv = Sha256_clone(&description_hash_conv);
49539         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49540         *ret_conv = create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_hash_conv, duration_since_epoch, invoice_expiry_delta_secs);
49541         return (int64_t)ret_conv;
49542 }
49543
49544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1and_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, jstring description, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
49545         LDKChannelManager channelmanager_conv;
49546         channelmanager_conv.inner = (void*)(channelmanager & (~1));
49547         channelmanager_conv.is_owned = false;
49548         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
49549         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
49550         CHECK_ACCESS(keys_manager_ptr);
49551         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
49552         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
49553                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49554                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
49555         }
49556         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
49557         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
49558         CHECK_ACCESS(amt_msat_ptr);
49559         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
49560         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
49561         LDKStr description_conv = java_to_owned_str(env, description);
49562         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
49563         *ret_conv = create_invoice_from_channelmanager_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv, duration_since_epoch, invoice_expiry_delta_secs);
49564         return (int64_t)ret_conv;
49565 }
49566
49567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49568         LDKDefaultRouter this_obj_conv;
49569         this_obj_conv.inner = (void*)(this_obj & (~1));
49570         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
49571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49572         DefaultRouter_free(this_obj_conv);
49573 }
49574
49575 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) {
49576         LDKNetworkGraph network_graph_conv;
49577         network_graph_conv.inner = (void*)(network_graph & (~1));
49578         network_graph_conv.is_owned = false;
49579         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
49580         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
49581         CHECK_ACCESS(logger_ptr);
49582         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
49583         if (logger_conv.free == LDKLogger_JCalls_free) {
49584                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49585                 LDKLogger_JCalls_cloned(&logger_conv);
49586         }
49587         LDKThirtyTwoBytes random_seed_bytes_ref;
49588         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
49589         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
49590         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
49591         int64_t ret_ref = 0;
49592         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49593         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49595         ret_ref = (uintptr_t)ret_var.inner;
49596         if (ret_var.is_owned) {
49597                 ret_ref |= 1;
49598         }
49599         return ret_ref;
49600 }
49601
49602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
49603         LDKDefaultRouter this_arg_conv;
49604         this_arg_conv.inner = (void*)(this_arg & (~1));
49605         this_arg_conv.is_owned = false;
49606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49607         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
49608         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
49609         return (int64_t)ret_ret;
49610 }
49611
49612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
49613         LDKChannelManager this_arg_conv;
49614         this_arg_conv.inner = (void*)(this_arg & (~1));
49615         this_arg_conv.is_owned = false;
49616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49617         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
49618         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
49619         return (int64_t)ret_ret;
49620 }
49621
49622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
49623         LDKStr s_conv = java_to_owned_str(env, s);
49624         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
49625         *ret_conv = SiPrefix_from_str(s_conv);
49626         return (int64_t)ret_conv;
49627 }
49628
49629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
49630         LDKStr s_conv = java_to_owned_str(env, s);
49631         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
49632         *ret_conv = Invoice_from_str(s_conv);
49633         return (int64_t)ret_conv;
49634 }
49635
49636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
49637         LDKStr s_conv = java_to_owned_str(env, s);
49638         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
49639         *ret_conv = SignedRawInvoice_from_str(s_conv);
49640         return (int64_t)ret_conv;
49641 }
49642
49643 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49644         LDKParseError* o_conv = (LDKParseError*)o;
49645         LDKStr ret_str = ParseError_to_str(o_conv);
49646         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49647         Str_free(ret_str);
49648         return ret_conv;
49649 }
49650
49651 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49652         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
49653         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
49654         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49655         Str_free(ret_str);
49656         return ret_conv;
49657 }
49658
49659 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49660         LDKInvoice o_conv;
49661         o_conv.inner = (void*)(o & (~1));
49662         o_conv.is_owned = false;
49663         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49664         LDKStr ret_str = Invoice_to_str(&o_conv);
49665         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49666         Str_free(ret_str);
49667         return ret_conv;
49668 }
49669
49670 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49671         LDKSignedRawInvoice o_conv;
49672         o_conv.inner = (void*)(o & (~1));
49673         o_conv.is_owned = false;
49674         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49675         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
49676         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49677         Str_free(ret_str);
49678         return ret_conv;
49679 }
49680
49681 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49682         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
49683         LDKStr ret_str = Currency_to_str(o_conv);
49684         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49685         Str_free(ret_str);
49686         return ret_conv;
49687 }
49688
49689 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49690         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
49691         LDKStr ret_str = SiPrefix_to_str(o_conv);
49692         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49693         Str_free(ret_str);
49694         return ret_conv;
49695 }
49696
49697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49698         LDKRapidGossipSync this_obj_conv;
49699         this_obj_conv.inner = (void*)(this_obj & (~1));
49700         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
49701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49702         RapidGossipSync_free(this_obj_conv);
49703 }
49704
49705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph) {
49706         LDKNetworkGraph network_graph_conv;
49707         network_graph_conv.inner = (void*)(network_graph & (~1));
49708         network_graph_conv.is_owned = false;
49709         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
49710         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv);
49711         int64_t ret_ref = 0;
49712         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
49713         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
49714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49715         ret_ref = (uintptr_t)ret_var.inner;
49716         if (ret_var.is_owned) {
49717                 ret_ref |= 1;
49718         }
49719         return ret_ref;
49720 }
49721
49722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1sync_1network_1graph_1with_1file_1path(JNIEnv *env, jclass clz, int64_t this_arg, jstring sync_path) {
49723         LDKRapidGossipSync this_arg_conv;
49724         this_arg_conv.inner = (void*)(this_arg & (~1));
49725         this_arg_conv.is_owned = false;
49726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49727         LDKStr sync_path_conv = java_to_owned_str(env, sync_path);
49728         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
49729         *ret_conv = RapidGossipSync_sync_network_graph_with_file_path(&this_arg_conv, sync_path_conv);
49730         return (int64_t)ret_conv;
49731 }
49732
49733 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
49734         LDKRapidGossipSync this_arg_conv;
49735         this_arg_conv.inner = (void*)(this_arg & (~1));
49736         this_arg_conv.is_owned = false;
49737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49738         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
49739         return ret_conv;
49740 }
49741
49742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49743         if ((this_ptr & 1) != 0) return;
49744         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
49745         CHECK_ACCESS(this_ptr_ptr);
49746         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
49747         FREE((void*)this_ptr);
49748         GraphSyncError_free(this_ptr_conv);
49749 }
49750
49751 static inline uintptr_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
49752         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
49753         *ret_copy = GraphSyncError_clone(arg);
49754 int64_t ret_ref = (uintptr_t)ret_copy;
49755         return ret_ref;
49756 }
49757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49758         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)arg;
49759         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
49760         return ret_conv;
49761 }
49762
49763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49764         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)orig;
49765         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
49766         *ret_copy = GraphSyncError_clone(orig_conv);
49767         int64_t ret_ref = (uintptr_t)ret_copy;
49768         return ret_ref;
49769 }
49770
49771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
49772         LDKDecodeError a_conv;
49773         a_conv.inner = (void*)(a & (~1));
49774         a_conv.is_owned = (a & 1) || (a == 0);
49775         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49776         a_conv = DecodeError_clone(&a_conv);
49777         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
49778         *ret_copy = GraphSyncError_decode_error(a_conv);
49779         int64_t ret_ref = (uintptr_t)ret_copy;
49780         return ret_ref;
49781 }
49782
49783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
49784         LDKLightningError a_conv;
49785         a_conv.inner = (void*)(a & (~1));
49786         a_conv.is_owned = (a & 1) || (a == 0);
49787         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49788         a_conv = LightningError_clone(&a_conv);
49789         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
49790         *ret_copy = GraphSyncError_lightning_error(a_conv);
49791         int64_t ret_ref = (uintptr_t)ret_copy;
49792         return ret_ref;
49793 }
49794
49795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1update_1network_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray update_data) {
49796         LDKRapidGossipSync this_arg_conv;
49797         this_arg_conv.inner = (void*)(this_arg & (~1));
49798         this_arg_conv.is_owned = false;
49799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49800         LDKu8slice update_data_ref;
49801         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
49802         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
49803         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
49804         *ret_conv = RapidGossipSync_update_network_graph(&this_arg_conv, update_data_ref);
49805         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
49806         return (int64_t)ret_conv;
49807 }
49808