[Java] Update auto-generated bindings to 0.0.105.0
[ldk-java] / src / main / jni / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include <jni.h>
4 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
5 #define int64_t jlong
6 #include "org_ldk_impl_bindings.h"
7 #include <lightning.h>
8 #include <string.h>
9 #include <stdatomic.h>
10 #include <stdlib.h>
11
12 #define LIKELY(v) __builtin_expect(!!(v), 1)
13 #define UNLIKELY(v) __builtin_expect(!!(v), 0)
14
15 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
16 #define MALLOC(a, _) malloc(a)
17 #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
18 #define CHECK_ACCESS(p)
19 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
20 #define DO_ASSERT(a) (void)(a)
21 #define CHECK(a)
22
23 static jmethodID ordinal_meth = NULL;
24 static jmethodID slicedef_meth = NULL;
25 static jclass slicedef_cls = NULL;
26 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
27         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
28         CHECK(ordinal_meth != NULL);
29         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
30         CHECK(slicedef_meth != NULL);
31         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
32         CHECK(slicedef_cls != NULL);
33 }
34
35 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
36         return *((bool*)ptr);
37 }
38 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
39         return *((long*)ptr);
40 }
41 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
42         FREE((void*)ptr);
43 }
44 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
45         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
46         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
47         return ret_arr;
48 }
49 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
50         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
51         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
52         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
53         return ret_arr;
54 }
55 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
56         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
57         vec->datalen = (*env)->GetArrayLength(env, bytes);
58         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
59         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
60         return (uint64_t)vec;
61 }
62 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
63         LDKTransaction *txdata = (LDKTransaction*)ptr;
64         LDKu8slice slice;
65         slice.data = txdata->data;
66         slice.datalen = txdata->datalen;
67         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
68 }
69 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
70         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
71         txdata->datalen = (*env)->GetArrayLength(env, bytes);
72         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
73         txdata->data_is_owned = false;
74         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
75         return (uint64_t)txdata;
76 }
77 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
78         LDKTransaction *tx = (LDKTransaction*)ptr;
79         tx->data_is_owned = true;
80         Transaction_free(*tx);
81         FREE((void*)ptr);
82 }
83 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
84         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
85         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
86         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
87         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
88         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
89         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
90         return (uint64_t)vec->datalen;
91 }
92 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
93         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
94         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
95         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
96         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
97         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
98         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
99         vec->data = NULL;
100         vec->datalen = 0;
101         return (uint64_t)vec;
102 }
103
104 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
105 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
106 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
107 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
108
109 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
110 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
111 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
112
113 typedef jlongArray int64_tArray;
114 typedef jbyteArray int8_tArray;
115
116 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
117         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
118         char* conv_buf = MALLOC(len + 1, "str conv buf");
119         memcpy(conv_buf, chars, len);
120         conv_buf[len] = 0;
121         jstring ret = (*env)->NewStringUTF(env, conv_buf);
122         FREE(conv_buf);
123         return ret;
124 }
125 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
126         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
127         char* newchars = MALLOC(str_len + 1, "String chars");
128         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
129         memcpy(newchars, jchars, str_len);
130         newchars[str_len] = 0;
131         (*env)->ReleaseStringUTFChars(env, str, jchars);
132         LDKStr res = {
133                 .chars = newchars,
134                 .len = str_len,
135                 .chars_is_owned = true
136         };
137         return res;
138 }
139
140 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
141         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
142 }
143 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
144         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
145 }
146 #include "version.c"
147 static jclass arr_of_B_clz = NULL;
148 static jclass arr_of_J_clz = NULL;
149 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
150         arr_of_B_clz = (*env)->FindClass(env, "[B");
151         CHECK(arr_of_B_clz != NULL);
152         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
153         arr_of_J_clz = (*env)->FindClass(env, "[J");
154         CHECK(arr_of_J_clz != NULL);
155         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
156 }
157 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
158 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
159         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
160         if (UNLIKELY((*env)->ExceptionCheck(env))) {
161                 (*env)->ExceptionDescribe(env);
162                 (*env)->FatalError(env, "A call to AccessError.ordinal() from rust threw an exception.");
163         }
164         switch (ord) {
165                 case 0: return LDKAccessError_UnknownChain;
166                 case 1: return LDKAccessError_UnknownTx;
167         }
168         (*env)->FatalError(env, "A call to AccessError.ordinal() from rust returned an invalid value.");
169         abort(); // Unreachable, but will let the compiler know we don't return here
170 }
171 static jclass AccessError_class = NULL;
172 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
173 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
174 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
175         AccessError_class = (*env)->NewGlobalRef(env, clz);
176         CHECK(AccessError_class != NULL);
177         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
178         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
179         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
180         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
181 }
182 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
183         switch (val) {
184                 case LDKAccessError_UnknownChain:
185                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
186                 case LDKAccessError_UnknownTx:
187                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
188                 default: abort();
189         }
190 }
191
192 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_java(JNIEnv *env, jclass clz) {
193         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
194         if (UNLIKELY((*env)->ExceptionCheck(env))) {
195                 (*env)->ExceptionDescribe(env);
196                 (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust threw an exception.");
197         }
198         switch (ord) {
199                 case 0: return LDKCOption_NoneZ_Some;
200                 case 1: return LDKCOption_NoneZ_None;
201         }
202         (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust returned an invalid value.");
203         abort(); // Unreachable, but will let the compiler know we don't return here
204 }
205 static jclass COption_NoneZ_class = NULL;
206 static jfieldID COption_NoneZ_LDKCOption_NoneZ_Some = NULL;
207 static jfieldID COption_NoneZ_LDKCOption_NoneZ_None = NULL;
208 JNIEXPORT void JNICALL Java_org_ldk_enums_COption_1NoneZ_init (JNIEnv *env, jclass clz) {
209         COption_NoneZ_class = (*env)->NewGlobalRef(env, clz);
210         CHECK(COption_NoneZ_class != NULL);
211         COption_NoneZ_LDKCOption_NoneZ_Some = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_Some", "Lorg/ldk/enums/COption_NoneZ;");
212         CHECK(COption_NoneZ_LDKCOption_NoneZ_Some != NULL);
213         COption_NoneZ_LDKCOption_NoneZ_None = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_None", "Lorg/ldk/enums/COption_NoneZ;");
214         CHECK(COption_NoneZ_LDKCOption_NoneZ_None != NULL);
215 }
216 static inline jclass LDKCOption_NoneZ_to_java(JNIEnv *env, LDKCOption_NoneZ val) {
217         switch (val) {
218                 case LDKCOption_NoneZ_Some:
219                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_Some);
220                 case LDKCOption_NoneZ_None:
221                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_None);
222                 default: abort();
223         }
224 }
225
226 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
227         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
228         if (UNLIKELY((*env)->ExceptionCheck(env))) {
229                 (*env)->ExceptionDescribe(env);
230                 (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust threw an exception.");
231         }
232         switch (ord) {
233                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
234                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
235         }
236         (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust returned an invalid value.");
237         abort(); // Unreachable, but will let the compiler know we don't return here
238 }
239 static jclass ChannelMonitorUpdateErr_class = NULL;
240 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
241 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
242 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
243         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
244         CHECK(ChannelMonitorUpdateErr_class != NULL);
245         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
246         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
247         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
248         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
249 }
250 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
251         switch (val) {
252                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
253                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
254                 case LDKChannelMonitorUpdateErr_PermanentFailure:
255                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
256                 default: abort();
257         }
258 }
259
260 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
261         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
262         if (UNLIKELY((*env)->ExceptionCheck(env))) {
263                 (*env)->ExceptionDescribe(env);
264                 (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust threw an exception.");
265         }
266         switch (ord) {
267                 case 0: return LDKConfirmationTarget_Background;
268                 case 1: return LDKConfirmationTarget_Normal;
269                 case 2: return LDKConfirmationTarget_HighPriority;
270         }
271         (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust returned an invalid value.");
272         abort(); // Unreachable, but will let the compiler know we don't return here
273 }
274 static jclass ConfirmationTarget_class = NULL;
275 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
276 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
277 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
278 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
279         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
280         CHECK(ConfirmationTarget_class != NULL);
281         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
282         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
283         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
284         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
285         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
286         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
287 }
288 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
289         switch (val) {
290                 case LDKConfirmationTarget_Background:
291                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
292                 case LDKConfirmationTarget_Normal:
293                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
294                 case LDKConfirmationTarget_HighPriority:
295                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
296                 default: abort();
297         }
298 }
299
300 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
301         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
302         if (UNLIKELY((*env)->ExceptionCheck(env))) {
303                 (*env)->ExceptionDescribe(env);
304                 (*env)->FatalError(env, "A call to CreationError.ordinal() from rust threw an exception.");
305         }
306         switch (ord) {
307                 case 0: return LDKCreationError_DescriptionTooLong;
308                 case 1: return LDKCreationError_RouteTooLong;
309                 case 2: return LDKCreationError_TimestampOutOfBounds;
310                 case 3: return LDKCreationError_InvalidAmount;
311                 case 4: return LDKCreationError_MissingRouteHints;
312         }
313         (*env)->FatalError(env, "A call to CreationError.ordinal() from rust returned an invalid value.");
314         abort(); // Unreachable, but will let the compiler know we don't return here
315 }
316 static jclass CreationError_class = NULL;
317 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
318 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
319 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
320 static jfieldID CreationError_LDKCreationError_InvalidAmount = NULL;
321 static jfieldID CreationError_LDKCreationError_MissingRouteHints = NULL;
322 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
323         CreationError_class = (*env)->NewGlobalRef(env, clz);
324         CHECK(CreationError_class != NULL);
325         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
326         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
327         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
328         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
329         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
330         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
331         CreationError_LDKCreationError_InvalidAmount = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_InvalidAmount", "Lorg/ldk/enums/CreationError;");
332         CHECK(CreationError_LDKCreationError_InvalidAmount != NULL);
333         CreationError_LDKCreationError_MissingRouteHints = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_MissingRouteHints", "Lorg/ldk/enums/CreationError;");
334         CHECK(CreationError_LDKCreationError_MissingRouteHints != NULL);
335 }
336 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
337         switch (val) {
338                 case LDKCreationError_DescriptionTooLong:
339                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
340                 case LDKCreationError_RouteTooLong:
341                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
342                 case LDKCreationError_TimestampOutOfBounds:
343                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
344                 case LDKCreationError_InvalidAmount:
345                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_InvalidAmount);
346                 case LDKCreationError_MissingRouteHints:
347                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_MissingRouteHints);
348                 default: abort();
349         }
350 }
351
352 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
353         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
354         if (UNLIKELY((*env)->ExceptionCheck(env))) {
355                 (*env)->ExceptionDescribe(env);
356                 (*env)->FatalError(env, "A call to Currency.ordinal() from rust threw an exception.");
357         }
358         switch (ord) {
359                 case 0: return LDKCurrency_Bitcoin;
360                 case 1: return LDKCurrency_BitcoinTestnet;
361                 case 2: return LDKCurrency_Regtest;
362                 case 3: return LDKCurrency_Simnet;
363                 case 4: return LDKCurrency_Signet;
364         }
365         (*env)->FatalError(env, "A call to Currency.ordinal() from rust returned an invalid value.");
366         abort(); // Unreachable, but will let the compiler know we don't return here
367 }
368 static jclass Currency_class = NULL;
369 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
370 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
371 static jfieldID Currency_LDKCurrency_Regtest = NULL;
372 static jfieldID Currency_LDKCurrency_Simnet = NULL;
373 static jfieldID Currency_LDKCurrency_Signet = NULL;
374 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
375         Currency_class = (*env)->NewGlobalRef(env, clz);
376         CHECK(Currency_class != NULL);
377         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
378         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
379         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
380         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
381         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
382         CHECK(Currency_LDKCurrency_Regtest != NULL);
383         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
384         CHECK(Currency_LDKCurrency_Simnet != NULL);
385         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
386         CHECK(Currency_LDKCurrency_Signet != NULL);
387 }
388 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
389         switch (val) {
390                 case LDKCurrency_Bitcoin:
391                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
392                 case LDKCurrency_BitcoinTestnet:
393                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
394                 case LDKCurrency_Regtest:
395                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
396                 case LDKCurrency_Simnet:
397                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
398                 case LDKCurrency_Signet:
399                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
400                 default: abort();
401         }
402 }
403
404 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
405         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
406         if (UNLIKELY((*env)->ExceptionCheck(env))) {
407                 (*env)->ExceptionDescribe(env);
408                 (*env)->FatalError(env, "A call to IOError.ordinal() from rust threw an exception.");
409         }
410         switch (ord) {
411                 case 0: return LDKIOError_NotFound;
412                 case 1: return LDKIOError_PermissionDenied;
413                 case 2: return LDKIOError_ConnectionRefused;
414                 case 3: return LDKIOError_ConnectionReset;
415                 case 4: return LDKIOError_ConnectionAborted;
416                 case 5: return LDKIOError_NotConnected;
417                 case 6: return LDKIOError_AddrInUse;
418                 case 7: return LDKIOError_AddrNotAvailable;
419                 case 8: return LDKIOError_BrokenPipe;
420                 case 9: return LDKIOError_AlreadyExists;
421                 case 10: return LDKIOError_WouldBlock;
422                 case 11: return LDKIOError_InvalidInput;
423                 case 12: return LDKIOError_InvalidData;
424                 case 13: return LDKIOError_TimedOut;
425                 case 14: return LDKIOError_WriteZero;
426                 case 15: return LDKIOError_Interrupted;
427                 case 16: return LDKIOError_Other;
428                 case 17: return LDKIOError_UnexpectedEof;
429         }
430         (*env)->FatalError(env, "A call to IOError.ordinal() from rust returned an invalid value.");
431         abort(); // Unreachable, but will let the compiler know we don't return here
432 }
433 static jclass IOError_class = NULL;
434 static jfieldID IOError_LDKIOError_NotFound = NULL;
435 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
436 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
437 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
438 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
439 static jfieldID IOError_LDKIOError_NotConnected = NULL;
440 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
441 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
442 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
443 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
444 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
445 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
446 static jfieldID IOError_LDKIOError_InvalidData = NULL;
447 static jfieldID IOError_LDKIOError_TimedOut = NULL;
448 static jfieldID IOError_LDKIOError_WriteZero = NULL;
449 static jfieldID IOError_LDKIOError_Interrupted = NULL;
450 static jfieldID IOError_LDKIOError_Other = NULL;
451 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
452 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
453         IOError_class = (*env)->NewGlobalRef(env, clz);
454         CHECK(IOError_class != NULL);
455         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
456         CHECK(IOError_LDKIOError_NotFound != NULL);
457         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
458         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
459         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
460         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
461         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
462         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
463         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
464         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
465         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
466         CHECK(IOError_LDKIOError_NotConnected != NULL);
467         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
468         CHECK(IOError_LDKIOError_AddrInUse != NULL);
469         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
470         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
471         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
472         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
473         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
474         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
475         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
476         CHECK(IOError_LDKIOError_WouldBlock != NULL);
477         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
478         CHECK(IOError_LDKIOError_InvalidInput != NULL);
479         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
480         CHECK(IOError_LDKIOError_InvalidData != NULL);
481         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
482         CHECK(IOError_LDKIOError_TimedOut != NULL);
483         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
484         CHECK(IOError_LDKIOError_WriteZero != NULL);
485         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
486         CHECK(IOError_LDKIOError_Interrupted != NULL);
487         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
488         CHECK(IOError_LDKIOError_Other != NULL);
489         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
490         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
491 }
492 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
493         switch (val) {
494                 case LDKIOError_NotFound:
495                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
496                 case LDKIOError_PermissionDenied:
497                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
498                 case LDKIOError_ConnectionRefused:
499                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
500                 case LDKIOError_ConnectionReset:
501                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
502                 case LDKIOError_ConnectionAborted:
503                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
504                 case LDKIOError_NotConnected:
505                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
506                 case LDKIOError_AddrInUse:
507                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
508                 case LDKIOError_AddrNotAvailable:
509                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
510                 case LDKIOError_BrokenPipe:
511                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
512                 case LDKIOError_AlreadyExists:
513                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
514                 case LDKIOError_WouldBlock:
515                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
516                 case LDKIOError_InvalidInput:
517                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
518                 case LDKIOError_InvalidData:
519                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
520                 case LDKIOError_TimedOut:
521                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
522                 case LDKIOError_WriteZero:
523                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
524                 case LDKIOError_Interrupted:
525                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
526                 case LDKIOError_Other:
527                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
528                 case LDKIOError_UnexpectedEof:
529                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
530                 default: abort();
531         }
532 }
533
534 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
535         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
536         if (UNLIKELY((*env)->ExceptionCheck(env))) {
537                 (*env)->ExceptionDescribe(env);
538                 (*env)->FatalError(env, "A call to Level.ordinal() from rust threw an exception.");
539         }
540         switch (ord) {
541                 case 0: return LDKLevel_Gossip;
542                 case 1: return LDKLevel_Trace;
543                 case 2: return LDKLevel_Debug;
544                 case 3: return LDKLevel_Info;
545                 case 4: return LDKLevel_Warn;
546                 case 5: return LDKLevel_Error;
547         }
548         (*env)->FatalError(env, "A call to Level.ordinal() from rust returned an invalid value.");
549         abort(); // Unreachable, but will let the compiler know we don't return here
550 }
551 static jclass Level_class = NULL;
552 static jfieldID Level_LDKLevel_Gossip = NULL;
553 static jfieldID Level_LDKLevel_Trace = NULL;
554 static jfieldID Level_LDKLevel_Debug = NULL;
555 static jfieldID Level_LDKLevel_Info = NULL;
556 static jfieldID Level_LDKLevel_Warn = NULL;
557 static jfieldID Level_LDKLevel_Error = NULL;
558 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
559         Level_class = (*env)->NewGlobalRef(env, clz);
560         CHECK(Level_class != NULL);
561         Level_LDKLevel_Gossip = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Gossip", "Lorg/ldk/enums/Level;");
562         CHECK(Level_LDKLevel_Gossip != NULL);
563         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
564         CHECK(Level_LDKLevel_Trace != NULL);
565         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
566         CHECK(Level_LDKLevel_Debug != NULL);
567         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
568         CHECK(Level_LDKLevel_Info != NULL);
569         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
570         CHECK(Level_LDKLevel_Warn != NULL);
571         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
572         CHECK(Level_LDKLevel_Error != NULL);
573 }
574 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
575         switch (val) {
576                 case LDKLevel_Gossip:
577                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Gossip);
578                 case LDKLevel_Trace:
579                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
580                 case LDKLevel_Debug:
581                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
582                 case LDKLevel_Info:
583                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
584                 case LDKLevel_Warn:
585                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
586                 case LDKLevel_Error:
587                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
588                 default: abort();
589         }
590 }
591
592 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
593         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
594         if (UNLIKELY((*env)->ExceptionCheck(env))) {
595                 (*env)->ExceptionDescribe(env);
596                 (*env)->FatalError(env, "A call to Network.ordinal() from rust threw an exception.");
597         }
598         switch (ord) {
599                 case 0: return LDKNetwork_Bitcoin;
600                 case 1: return LDKNetwork_Testnet;
601                 case 2: return LDKNetwork_Regtest;
602                 case 3: return LDKNetwork_Signet;
603         }
604         (*env)->FatalError(env, "A call to Network.ordinal() from rust returned an invalid value.");
605         abort(); // Unreachable, but will let the compiler know we don't return here
606 }
607 static jclass Network_class = NULL;
608 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
609 static jfieldID Network_LDKNetwork_Testnet = NULL;
610 static jfieldID Network_LDKNetwork_Regtest = NULL;
611 static jfieldID Network_LDKNetwork_Signet = NULL;
612 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
613         Network_class = (*env)->NewGlobalRef(env, clz);
614         CHECK(Network_class != NULL);
615         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
616         CHECK(Network_LDKNetwork_Bitcoin != NULL);
617         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
618         CHECK(Network_LDKNetwork_Testnet != NULL);
619         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
620         CHECK(Network_LDKNetwork_Regtest != NULL);
621         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
622         CHECK(Network_LDKNetwork_Signet != NULL);
623 }
624 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
625         switch (val) {
626                 case LDKNetwork_Bitcoin:
627                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
628                 case LDKNetwork_Testnet:
629                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
630                 case LDKNetwork_Regtest:
631                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
632                 case LDKNetwork_Signet:
633                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
634                 default: abort();
635         }
636 }
637
638 static inline LDKRecipient LDKRecipient_from_java(JNIEnv *env, jclass clz) {
639         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
640         if (UNLIKELY((*env)->ExceptionCheck(env))) {
641                 (*env)->ExceptionDescribe(env);
642                 (*env)->FatalError(env, "A call to Recipient.ordinal() from rust threw an exception.");
643         }
644         switch (ord) {
645                 case 0: return LDKRecipient_Node;
646                 case 1: return LDKRecipient_PhantomNode;
647         }
648         (*env)->FatalError(env, "A call to Recipient.ordinal() from rust returned an invalid value.");
649         abort(); // Unreachable, but will let the compiler know we don't return here
650 }
651 static jclass Recipient_class = NULL;
652 static jfieldID Recipient_LDKRecipient_Node = NULL;
653 static jfieldID Recipient_LDKRecipient_PhantomNode = NULL;
654 JNIEXPORT void JNICALL Java_org_ldk_enums_Recipient_init (JNIEnv *env, jclass clz) {
655         Recipient_class = (*env)->NewGlobalRef(env, clz);
656         CHECK(Recipient_class != NULL);
657         Recipient_LDKRecipient_Node = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_Node", "Lorg/ldk/enums/Recipient;");
658         CHECK(Recipient_LDKRecipient_Node != NULL);
659         Recipient_LDKRecipient_PhantomNode = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_PhantomNode", "Lorg/ldk/enums/Recipient;");
660         CHECK(Recipient_LDKRecipient_PhantomNode != NULL);
661 }
662 static inline jclass LDKRecipient_to_java(JNIEnv *env, LDKRecipient val) {
663         switch (val) {
664                 case LDKRecipient_Node:
665                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_Node);
666                 case LDKRecipient_PhantomNode:
667                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_PhantomNode);
668                 default: abort();
669         }
670 }
671
672 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
673         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
674         if (UNLIKELY((*env)->ExceptionCheck(env))) {
675                 (*env)->ExceptionDescribe(env);
676                 (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust threw an exception.");
677         }
678         switch (ord) {
679                 case 0: return LDKSecp256k1Error_IncorrectSignature;
680                 case 1: return LDKSecp256k1Error_InvalidMessage;
681                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
682                 case 3: return LDKSecp256k1Error_InvalidSignature;
683                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
684                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
685                 case 6: return LDKSecp256k1Error_InvalidTweak;
686                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
687                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
688         }
689         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
690         abort(); // Unreachable, but will let the compiler know we don't return here
691 }
692 static jclass Secp256k1Error_class = NULL;
693 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
694 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
695 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
696 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
697 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
698 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
699 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
700 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
701 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
702 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
703         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
704         CHECK(Secp256k1Error_class != NULL);
705         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
706         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
707         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
708         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
709         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
710         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
711         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
712         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
713         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
714         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
715         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
716         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
717         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
718         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
719         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
720         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
721         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
722         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
723 }
724 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
725         switch (val) {
726                 case LDKSecp256k1Error_IncorrectSignature:
727                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
728                 case LDKSecp256k1Error_InvalidMessage:
729                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
730                 case LDKSecp256k1Error_InvalidPublicKey:
731                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
732                 case LDKSecp256k1Error_InvalidSignature:
733                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
734                 case LDKSecp256k1Error_InvalidSecretKey:
735                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
736                 case LDKSecp256k1Error_InvalidRecoveryId:
737                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
738                 case LDKSecp256k1Error_InvalidTweak:
739                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
740                 case LDKSecp256k1Error_TweakCheckFailed:
741                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
742                 case LDKSecp256k1Error_NotEnoughMemory:
743                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
744                 default: abort();
745         }
746 }
747
748 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
749         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
750         if (UNLIKELY((*env)->ExceptionCheck(env))) {
751                 (*env)->ExceptionDescribe(env);
752                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
753         }
754         switch (ord) {
755                 case 0: return LDKSemanticError_NoPaymentHash;
756                 case 1: return LDKSemanticError_MultiplePaymentHashes;
757                 case 2: return LDKSemanticError_NoDescription;
758                 case 3: return LDKSemanticError_MultipleDescriptions;
759                 case 4: return LDKSemanticError_NoPaymentSecret;
760                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
761                 case 6: return LDKSemanticError_InvalidFeatures;
762                 case 7: return LDKSemanticError_InvalidRecoveryId;
763                 case 8: return LDKSemanticError_InvalidSignature;
764                 case 9: return LDKSemanticError_ImpreciseAmount;
765         }
766         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
767         abort(); // Unreachable, but will let the compiler know we don't return here
768 }
769 static jclass SemanticError_class = NULL;
770 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
771 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
772 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
773 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
774 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
775 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
776 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
777 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
778 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
779 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
780 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
781         SemanticError_class = (*env)->NewGlobalRef(env, clz);
782         CHECK(SemanticError_class != NULL);
783         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
784         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
785         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
786         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
787         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
788         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
789         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
790         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
791         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
792         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
793         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
794         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
795         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
796         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
797         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
798         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
799         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
800         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
801         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
802         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
803 }
804 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
805         switch (val) {
806                 case LDKSemanticError_NoPaymentHash:
807                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
808                 case LDKSemanticError_MultiplePaymentHashes:
809                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
810                 case LDKSemanticError_NoDescription:
811                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
812                 case LDKSemanticError_MultipleDescriptions:
813                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
814                 case LDKSemanticError_NoPaymentSecret:
815                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
816                 case LDKSemanticError_MultiplePaymentSecrets:
817                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
818                 case LDKSemanticError_InvalidFeatures:
819                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
820                 case LDKSemanticError_InvalidRecoveryId:
821                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
822                 case LDKSemanticError_InvalidSignature:
823                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
824                 case LDKSemanticError_ImpreciseAmount:
825                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
826                 default: abort();
827         }
828 }
829
830 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
831         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
832         if (UNLIKELY((*env)->ExceptionCheck(env))) {
833                 (*env)->ExceptionDescribe(env);
834                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
835         }
836         switch (ord) {
837                 case 0: return LDKSiPrefix_Milli;
838                 case 1: return LDKSiPrefix_Micro;
839                 case 2: return LDKSiPrefix_Nano;
840                 case 3: return LDKSiPrefix_Pico;
841         }
842         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
843         abort(); // Unreachable, but will let the compiler know we don't return here
844 }
845 static jclass SiPrefix_class = NULL;
846 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
847 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
848 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
849 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
850 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
851         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
852         CHECK(SiPrefix_class != NULL);
853         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
854         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
855         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
856         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
857         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
858         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
859         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
860         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
861 }
862 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
863         switch (val) {
864                 case LDKSiPrefix_Milli:
865                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
866                 case LDKSiPrefix_Micro:
867                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
868                 case LDKSiPrefix_Nano:
869                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
870                 case LDKSiPrefix_Pico:
871                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
872                 default: abort();
873         }
874 }
875
876 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
877         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
878         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
879         return ret;
880 }
881 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) {
882         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
883         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
884         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
885         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
886         CVec_u8Z_free(ret_var);
887         return ret_arr;
888 }
889
890 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) {
891         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
892         int64_t ret_val = TxOut_get_value(thing_conv);
893         return ret_val;
894 }
895
896 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
897 CHECK(owner->result_ok);
898         return *owner->contents.result;
899 }
900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
901         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
902         CResult_NoneNoneZ_get_ok(owner_conv);
903 }
904
905 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
906 CHECK(!owner->result_ok);
907         return *owner->contents.err;
908 }
909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
910         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
911         CResult_NoneNoneZ_get_err(owner_conv);
912 }
913
914 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
915 CHECK(owner->result_ok);
916         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
917 }
918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
919         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
920         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
921         uintptr_t ret_ref = 0;
922         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
923         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
925         ret_ref = (uintptr_t)ret_var.inner;
926         if (ret_var.is_owned) {
927                 ret_ref |= 1;
928         }
929         return ret_ref;
930 }
931
932 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
933 CHECK(!owner->result_ok);
934         return DecodeError_clone(&*owner->contents.err);
935 }
936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
937         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
938         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
939         uintptr_t ret_ref = 0;
940         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
941         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
943         ret_ref = (uintptr_t)ret_var.inner;
944         if (ret_var.is_owned) {
945                 ret_ref |= 1;
946         }
947         return ret_ref;
948 }
949
950 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
951 CHECK(owner->result_ok);
952         return *owner->contents.result;
953 }
954 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
955         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
956         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
957         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes);
958         return ret_arr;
959 }
960
961 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
962 CHECK(!owner->result_ok);
963         return *owner->contents.err;
964 }
965 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
966         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
967         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_SecretKeyErrorZ_get_err(owner_conv));
968         return ret_conv;
969 }
970
971 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
972 CHECK(owner->result_ok);
973         return *owner->contents.result;
974 }
975 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
976         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
977         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
978         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
979         return ret_arr;
980 }
981
982 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
983 CHECK(!owner->result_ok);
984         return *owner->contents.err;
985 }
986 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
987         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
988         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
989         return ret_conv;
990 }
991
992 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
993 CHECK(owner->result_ok);
994         return TxCreationKeys_clone(&*owner->contents.result);
995 }
996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
997         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
998         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
999         uintptr_t ret_ref = 0;
1000         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1001         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1003         ret_ref = (uintptr_t)ret_var.inner;
1004         if (ret_var.is_owned) {
1005                 ret_ref |= 1;
1006         }
1007         return ret_ref;
1008 }
1009
1010 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1011 CHECK(!owner->result_ok);
1012         return DecodeError_clone(&*owner->contents.err);
1013 }
1014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1015         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1016         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1017         uintptr_t ret_ref = 0;
1018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1021         ret_ref = (uintptr_t)ret_var.inner;
1022         if (ret_var.is_owned) {
1023                 ret_ref |= 1;
1024         }
1025         return ret_ref;
1026 }
1027
1028 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1029 CHECK(owner->result_ok);
1030         return ChannelPublicKeys_clone(&*owner->contents.result);
1031 }
1032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1033         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1034         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1035         uintptr_t ret_ref = 0;
1036         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1037         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1039         ret_ref = (uintptr_t)ret_var.inner;
1040         if (ret_var.is_owned) {
1041                 ret_ref |= 1;
1042         }
1043         return ret_ref;
1044 }
1045
1046 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1047 CHECK(!owner->result_ok);
1048         return DecodeError_clone(&*owner->contents.err);
1049 }
1050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1051         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1052         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1053         uintptr_t ret_ref = 0;
1054         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1055         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1057         ret_ref = (uintptr_t)ret_var.inner;
1058         if (ret_var.is_owned) {
1059                 ret_ref |= 1;
1060         }
1061         return ret_ref;
1062 }
1063
1064 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1065 CHECK(owner->result_ok);
1066         return TxCreationKeys_clone(&*owner->contents.result);
1067 }
1068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1069         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1070         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
1071         uintptr_t ret_ref = 0;
1072         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1073         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1075         ret_ref = (uintptr_t)ret_var.inner;
1076         if (ret_var.is_owned) {
1077                 ret_ref |= 1;
1078         }
1079         return ret_ref;
1080 }
1081
1082 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1083 CHECK(!owner->result_ok);
1084         return *owner->contents.err;
1085 }
1086 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1087         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1088         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_TxCreationKeysErrorZ_get_err(owner_conv));
1089         return ret_conv;
1090 }
1091
1092 static jclass LDKCOption_u32Z_Some_class = NULL;
1093 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1094 static jclass LDKCOption_u32Z_None_class = NULL;
1095 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1097         LDKCOption_u32Z_Some_class =
1098                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1099         CHECK(LDKCOption_u32Z_Some_class != NULL);
1100         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1101         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1102         LDKCOption_u32Z_None_class =
1103                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1104         CHECK(LDKCOption_u32Z_None_class != NULL);
1105         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1106         CHECK(LDKCOption_u32Z_None_meth != NULL);
1107 }
1108 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1109         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
1110         switch(obj->tag) {
1111                 case LDKCOption_u32Z_Some: {
1112                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
1113                 }
1114                 case LDKCOption_u32Z_None: {
1115                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1116                 }
1117                 default: abort();
1118         }
1119 }
1120 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1121 CHECK(owner->result_ok);
1122         return HTLCOutputInCommitment_clone(&*owner->contents.result);
1123 }
1124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1125         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1126         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1127         uintptr_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_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *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_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1143         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1144         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1145         uintptr_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 LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1157 CHECK(owner->result_ok);
1158         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
1159 }
1160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1161         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1162         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1163         uintptr_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 struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1175 CHECK(!owner->result_ok);
1176         return DecodeError_clone(&*owner->contents.err);
1177 }
1178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1179         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1180         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1181         uintptr_t ret_ref = 0;
1182         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1183         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1185         ret_ref = (uintptr_t)ret_var.inner;
1186         if (ret_var.is_owned) {
1187                 ret_ref |= 1;
1188         }
1189         return ret_ref;
1190 }
1191
1192 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1193 CHECK(owner->result_ok);
1194         return ChannelTransactionParameters_clone(&*owner->contents.result);
1195 }
1196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1197         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1198         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1199         uintptr_t ret_ref = 0;
1200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1203         ret_ref = (uintptr_t)ret_var.inner;
1204         if (ret_var.is_owned) {
1205                 ret_ref |= 1;
1206         }
1207         return ret_ref;
1208 }
1209
1210 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1211 CHECK(!owner->result_ok);
1212         return DecodeError_clone(&*owner->contents.err);
1213 }
1214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1215         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1216         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1217         uintptr_t ret_ref = 0;
1218         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1219         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1221         ret_ref = (uintptr_t)ret_var.inner;
1222         if (ret_var.is_owned) {
1223                 ret_ref |= 1;
1224         }
1225         return ret_ref;
1226 }
1227
1228 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1229 CHECK(owner->result_ok);
1230         return HolderCommitmentTransaction_clone(&*owner->contents.result);
1231 }
1232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1233         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1234         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1235         uintptr_t ret_ref = 0;
1236         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1237         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1239         ret_ref = (uintptr_t)ret_var.inner;
1240         if (ret_var.is_owned) {
1241                 ret_ref |= 1;
1242         }
1243         return ret_ref;
1244 }
1245
1246 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1247 CHECK(!owner->result_ok);
1248         return DecodeError_clone(&*owner->contents.err);
1249 }
1250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1251         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1252         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1253         uintptr_t ret_ref = 0;
1254         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1255         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1257         ret_ref = (uintptr_t)ret_var.inner;
1258         if (ret_var.is_owned) {
1259                 ret_ref |= 1;
1260         }
1261         return ret_ref;
1262 }
1263
1264 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1265 CHECK(owner->result_ok);
1266         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
1267 }
1268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1269         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1270         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1271         uintptr_t ret_ref = 0;
1272         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1273         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1275         ret_ref = (uintptr_t)ret_var.inner;
1276         if (ret_var.is_owned) {
1277                 ret_ref |= 1;
1278         }
1279         return ret_ref;
1280 }
1281
1282 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1283 CHECK(!owner->result_ok);
1284         return DecodeError_clone(&*owner->contents.err);
1285 }
1286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1287         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1288         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1289         uintptr_t ret_ref = 0;
1290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1293         ret_ref = (uintptr_t)ret_var.inner;
1294         if (ret_var.is_owned) {
1295                 ret_ref |= 1;
1296         }
1297         return ret_ref;
1298 }
1299
1300 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1301 CHECK(owner->result_ok);
1302         return &*owner->contents.result;
1303 }
1304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1305         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1306         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1307         uintptr_t ret_ref = 0;
1308         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1309         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1311         ret_ref = (uintptr_t)ret_var.inner & ~1;
1312         return ret_ref;
1313 }
1314
1315 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1316 CHECK(!owner->result_ok);
1317         return *owner->contents.err;
1318 }
1319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1320         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1321         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1322 }
1323
1324 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1325 CHECK(owner->result_ok);
1326         return CommitmentTransaction_clone(&*owner->contents.result);
1327 }
1328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1329         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1330         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1331         uintptr_t ret_ref = 0;
1332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1335         ret_ref = (uintptr_t)ret_var.inner;
1336         if (ret_var.is_owned) {
1337                 ret_ref |= 1;
1338         }
1339         return ret_ref;
1340 }
1341
1342 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1343 CHECK(!owner->result_ok);
1344         return DecodeError_clone(&*owner->contents.err);
1345 }
1346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1347         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1348         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1349         uintptr_t ret_ref = 0;
1350         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1351         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1353         ret_ref = (uintptr_t)ret_var.inner;
1354         if (ret_var.is_owned) {
1355                 ret_ref |= 1;
1356         }
1357         return ret_ref;
1358 }
1359
1360 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1361 CHECK(owner->result_ok);
1362         return &*owner->contents.result;
1363 }
1364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1365         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1366         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1367         uintptr_t ret_ref = 0;
1368         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1369         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1371         ret_ref = (uintptr_t)ret_var.inner & ~1;
1372         return ret_ref;
1373 }
1374
1375 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1376 CHECK(!owner->result_ok);
1377         return *owner->contents.err;
1378 }
1379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1380         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1381         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1382 }
1383
1384 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1385 CHECK(owner->result_ok);
1386         return *owner->contents.result;
1387 }
1388 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1389         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1390         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1391         jobjectArray ret_arr = NULL;
1392         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1393         ;
1394         for (size_t i = 0; i < ret_var.datalen; i++) {
1395                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1396                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1397                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1398         }
1399         
1400         return ret_arr;
1401 }
1402
1403 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1404 CHECK(!owner->result_ok);
1405         return *owner->contents.err;
1406 }
1407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1408         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1409         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1410 }
1411
1412 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1413 CHECK(owner->result_ok);
1414         return ShutdownScript_clone(&*owner->contents.result);
1415 }
1416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1417         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1418         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1419         uintptr_t ret_ref = 0;
1420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1423         ret_ref = (uintptr_t)ret_var.inner;
1424         if (ret_var.is_owned) {
1425                 ret_ref |= 1;
1426         }
1427         return ret_ref;
1428 }
1429
1430 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1431 CHECK(!owner->result_ok);
1432         return DecodeError_clone(&*owner->contents.err);
1433 }
1434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1435         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1436         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1437         uintptr_t ret_ref = 0;
1438         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1439         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1441         ret_ref = (uintptr_t)ret_var.inner;
1442         if (ret_var.is_owned) {
1443                 ret_ref |= 1;
1444         }
1445         return ret_ref;
1446 }
1447
1448 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1449 CHECK(owner->result_ok);
1450         return ShutdownScript_clone(&*owner->contents.result);
1451 }
1452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1453         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1454         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1455         uintptr_t ret_ref = 0;
1456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1459         ret_ref = (uintptr_t)ret_var.inner;
1460         if (ret_var.is_owned) {
1461                 ret_ref |= 1;
1462         }
1463         return ret_ref;
1464 }
1465
1466 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1467 CHECK(!owner->result_ok);
1468         return InvalidShutdownScript_clone(&*owner->contents.err);
1469 }
1470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1471         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1472         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1473         uintptr_t ret_ref = 0;
1474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1477         ret_ref = (uintptr_t)ret_var.inner;
1478         if (ret_var.is_owned) {
1479                 ret_ref |= 1;
1480         }
1481         return ret_ref;
1482 }
1483
1484 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1485 CHECK(owner->result_ok);
1486         return *owner->contents.result;
1487 }
1488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1489         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1490         CResult_NoneErrorZ_get_ok(owner_conv);
1491 }
1492
1493 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1494 CHECK(!owner->result_ok);
1495         return *owner->contents.err;
1496 }
1497 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1498         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1499         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
1500         return ret_conv;
1501 }
1502
1503 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1504 CHECK(owner->result_ok);
1505         return RouteHop_clone(&*owner->contents.result);
1506 }
1507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1508         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1509         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
1510         uintptr_t ret_ref = 0;
1511         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1512         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1514         ret_ref = (uintptr_t)ret_var.inner;
1515         if (ret_var.is_owned) {
1516                 ret_ref |= 1;
1517         }
1518         return ret_ref;
1519 }
1520
1521 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1522 CHECK(!owner->result_ok);
1523         return DecodeError_clone(&*owner->contents.err);
1524 }
1525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1526         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1527         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1528         uintptr_t ret_ref = 0;
1529         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1530         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1532         ret_ref = (uintptr_t)ret_var.inner;
1533         if (ret_var.is_owned) {
1534                 ret_ref |= 1;
1535         }
1536         return ret_ref;
1537 }
1538
1539 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1540         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1541         for (size_t i = 0; i < ret.datalen; i++) {
1542                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1543         }
1544         return ret;
1545 }
1546 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1547         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1548         for (size_t i = 0; i < ret.datalen; i++) {
1549                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1550         }
1551         return ret;
1552 }
1553 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1554 CHECK(owner->result_ok);
1555         return Route_clone(&*owner->contents.result);
1556 }
1557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1558         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1559         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1560         uintptr_t ret_ref = 0;
1561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1564         ret_ref = (uintptr_t)ret_var.inner;
1565         if (ret_var.is_owned) {
1566                 ret_ref |= 1;
1567         }
1568         return ret_ref;
1569 }
1570
1571 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1572 CHECK(!owner->result_ok);
1573         return DecodeError_clone(&*owner->contents.err);
1574 }
1575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1576         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1577         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1578         uintptr_t ret_ref = 0;
1579         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1580         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1582         ret_ref = (uintptr_t)ret_var.inner;
1583         if (ret_var.is_owned) {
1584                 ret_ref |= 1;
1585         }
1586         return ret_ref;
1587 }
1588
1589 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1590 CHECK(owner->result_ok);
1591         return RouteParameters_clone(&*owner->contents.result);
1592 }
1593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1594         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1595         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1596         uintptr_t ret_ref = 0;
1597         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1598         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1600         ret_ref = (uintptr_t)ret_var.inner;
1601         if (ret_var.is_owned) {
1602                 ret_ref |= 1;
1603         }
1604         return ret_ref;
1605 }
1606
1607 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1608 CHECK(!owner->result_ok);
1609         return DecodeError_clone(&*owner->contents.err);
1610 }
1611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1612         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1613         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1614         uintptr_t ret_ref = 0;
1615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1618         ret_ref = (uintptr_t)ret_var.inner;
1619         if (ret_var.is_owned) {
1620                 ret_ref |= 1;
1621         }
1622         return ret_ref;
1623 }
1624
1625 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1626         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1627         for (size_t i = 0; i < ret.datalen; i++) {
1628                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1629         }
1630         return ret;
1631 }
1632 static jclass LDKCOption_u64Z_Some_class = NULL;
1633 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1634 static jclass LDKCOption_u64Z_None_class = NULL;
1635 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1637         LDKCOption_u64Z_Some_class =
1638                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
1639         CHECK(LDKCOption_u64Z_Some_class != NULL);
1640         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1641         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1642         LDKCOption_u64Z_None_class =
1643                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
1644         CHECK(LDKCOption_u64Z_None_class != NULL);
1645         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1646         CHECK(LDKCOption_u64Z_None_meth != NULL);
1647 }
1648 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1649         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1650         switch(obj->tag) {
1651                 case LDKCOption_u64Z_Some: {
1652                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1653                 }
1654                 case LDKCOption_u64Z_None: {
1655                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1656                 }
1657                 default: abort();
1658         }
1659 }
1660 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1661 CHECK(owner->result_ok);
1662         return PaymentParameters_clone(&*owner->contents.result);
1663 }
1664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1665         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1666         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1667         uintptr_t ret_ref = 0;
1668         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1669         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1671         ret_ref = (uintptr_t)ret_var.inner;
1672         if (ret_var.is_owned) {
1673                 ret_ref |= 1;
1674         }
1675         return ret_ref;
1676 }
1677
1678 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1679 CHECK(!owner->result_ok);
1680         return DecodeError_clone(&*owner->contents.err);
1681 }
1682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1683         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1684         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1685         uintptr_t ret_ref = 0;
1686         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1687         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1689         ret_ref = (uintptr_t)ret_var.inner;
1690         if (ret_var.is_owned) {
1691                 ret_ref |= 1;
1692         }
1693         return ret_ref;
1694 }
1695
1696 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1697         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1698         for (size_t i = 0; i < ret.datalen; i++) {
1699                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1700         }
1701         return ret;
1702 }
1703 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1704 CHECK(owner->result_ok);
1705         return RouteHint_clone(&*owner->contents.result);
1706 }
1707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1708         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1709         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1710         uintptr_t ret_ref = 0;
1711         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1712         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1714         ret_ref = (uintptr_t)ret_var.inner;
1715         if (ret_var.is_owned) {
1716                 ret_ref |= 1;
1717         }
1718         return ret_ref;
1719 }
1720
1721 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1722 CHECK(!owner->result_ok);
1723         return DecodeError_clone(&*owner->contents.err);
1724 }
1725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1726         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1727         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1728         uintptr_t ret_ref = 0;
1729         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1730         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1732         ret_ref = (uintptr_t)ret_var.inner;
1733         if (ret_var.is_owned) {
1734                 ret_ref |= 1;
1735         }
1736         return ret_ref;
1737 }
1738
1739 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1740 CHECK(owner->result_ok);
1741         return RouteHintHop_clone(&*owner->contents.result);
1742 }
1743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1744         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1745         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1746         uintptr_t ret_ref = 0;
1747         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1748         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1750         ret_ref = (uintptr_t)ret_var.inner;
1751         if (ret_var.is_owned) {
1752                 ret_ref |= 1;
1753         }
1754         return ret_ref;
1755 }
1756
1757 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1758 CHECK(!owner->result_ok);
1759         return DecodeError_clone(&*owner->contents.err);
1760 }
1761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1762         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1763         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1764         uintptr_t ret_ref = 0;
1765         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1766         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1768         ret_ref = (uintptr_t)ret_var.inner;
1769         if (ret_var.is_owned) {
1770                 ret_ref |= 1;
1771         }
1772         return ret_ref;
1773 }
1774
1775 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1776         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1777         for (size_t i = 0; i < ret.datalen; i++) {
1778                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1779         }
1780         return ret;
1781 }
1782 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1783 CHECK(owner->result_ok);
1784         return Route_clone(&*owner->contents.result);
1785 }
1786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1787         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1788         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1789         uintptr_t ret_ref = 0;
1790         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1791         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1793         ret_ref = (uintptr_t)ret_var.inner;
1794         if (ret_var.is_owned) {
1795                 ret_ref |= 1;
1796         }
1797         return ret_ref;
1798 }
1799
1800 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1801 CHECK(!owner->result_ok);
1802         return LightningError_clone(&*owner->contents.err);
1803 }
1804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1805         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1806         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1807         uintptr_t ret_ref = 0;
1808         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1809         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1811         ret_ref = (uintptr_t)ret_var.inner;
1812         if (ret_var.is_owned) {
1813                 ret_ref |= 1;
1814         }
1815         return ret_ref;
1816 }
1817
1818 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1819 CHECK(owner->result_ok);
1820         return TxOut_clone(&*owner->contents.result);
1821 }
1822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1823         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1824         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
1825         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
1826         return (uintptr_t)ret_ref;
1827 }
1828
1829 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1830 CHECK(!owner->result_ok);
1831         return AccessError_clone(&*owner->contents.err);
1832 }
1833 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1834         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1835         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
1836         return ret_conv;
1837 }
1838
1839 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1840         return owner->a;
1841 }
1842 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
1843         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1844         intptr_t ret_val = C2Tuple_usizeTransactionZ_get_a(owner_conv);
1845         return ret_val;
1846 }
1847
1848 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1849         return owner->b;
1850 }
1851 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
1852         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1853         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
1854         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1855         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1856         return ret_arr;
1857 }
1858
1859 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1860         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1861         for (size_t i = 0; i < ret.datalen; i++) {
1862                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1863         }
1864         return ret;
1865 }
1866 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
1867         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1868         for (size_t i = 0; i < ret.datalen; i++) {
1869                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1870         }
1871         return ret;
1872 }
1873 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1874 CHECK(owner->result_ok);
1875         return *owner->contents.result;
1876 }
1877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1878         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1879         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
1880 }
1881
1882 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1883 CHECK(!owner->result_ok);
1884         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
1885 }
1886 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1887         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1888         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
1889         return ret_conv;
1890 }
1891
1892 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1893 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1894 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
1895 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
1896 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
1897 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
1898 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
1899 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
1900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1901         LDKMonitorEvent_HTLCEvent_class =
1902                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
1903         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1904         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1905         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1906         LDKMonitorEvent_CommitmentTxConfirmed_class =
1907                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
1908         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
1909         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
1910         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
1911         LDKMonitorEvent_UpdateCompleted_class =
1912                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted"));
1913         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
1914         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
1915         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
1916         LDKMonitorEvent_UpdateFailed_class =
1917                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
1918         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
1919         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
1920         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
1921 }
1922 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1923         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1924         switch(obj->tag) {
1925                 case LDKMonitorEvent_HTLCEvent: {
1926                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1927                         uintptr_t htlc_event_ref = 0;
1928                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1929                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1930                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
1931                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
1932                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1933                 }
1934                 case LDKMonitorEvent_CommitmentTxConfirmed: {
1935                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1936                         uintptr_t commitment_tx_confirmed_ref = 0;
1937                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1938                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1939                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
1940                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
1941                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
1942                 }
1943                 case LDKMonitorEvent_UpdateCompleted: {
1944                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
1945                         uintptr_t funding_txo_ref = 0;
1946                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1947                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1948                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
1949                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
1950                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, obj->update_completed.monitor_update_id);
1951                 }
1952                 case LDKMonitorEvent_UpdateFailed: {
1953                         LDKOutPoint update_failed_var = obj->update_failed;
1954                         uintptr_t update_failed_ref = 0;
1955                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1956                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1957                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
1958                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
1959                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
1960                 }
1961                 default: abort();
1962         }
1963 }
1964 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1965         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1966         for (size_t i = 0; i < ret.datalen; i++) {
1967                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1968         }
1969         return ret;
1970 }
1971 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1972 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1973 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1974 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1976         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1977                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some"));
1978         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1979         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1980         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1981         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1982                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None"));
1983         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1984         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1985         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1986 }
1987 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1988         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1989         switch(obj->tag) {
1990                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1991                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1992                         *some_conv = obj->some;
1993                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
1994                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((uintptr_t)some_conv));
1995                 }
1996                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1997                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1998                 }
1999                 default: abort();
2000         }
2001 }
2002 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
2003 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
2004 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
2005 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
2006 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
2007 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
2008 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
2009 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
2010 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
2011 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
2012 static jclass LDKClosureReason_ProcessingError_class = NULL;
2013 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
2014 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
2015 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
2016 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
2017 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
2018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
2019         LDKClosureReason_CounterpartyForceClosed_class =
2020                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
2021         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
2022         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
2023         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
2024         LDKClosureReason_HolderForceClosed_class =
2025                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
2026         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
2027         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
2028         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
2029         LDKClosureReason_CooperativeClosure_class =
2030                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
2031         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
2032         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
2033         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
2034         LDKClosureReason_CommitmentTxConfirmed_class =
2035                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
2036         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
2037         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
2038         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
2039         LDKClosureReason_FundingTimedOut_class =
2040                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
2041         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
2042         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
2043         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
2044         LDKClosureReason_ProcessingError_class =
2045                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
2046         CHECK(LDKClosureReason_ProcessingError_class != NULL);
2047         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
2048         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
2049         LDKClosureReason_DisconnectedPeer_class =
2050                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
2051         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
2052         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
2053         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
2054         LDKClosureReason_OutdatedChannelManager_class =
2055                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
2056         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
2057         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
2058         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
2059 }
2060 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2061         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
2062         switch(obj->tag) {
2063                 case LDKClosureReason_CounterpartyForceClosed: {
2064                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
2065                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
2066                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
2067                 }
2068                 case LDKClosureReason_HolderForceClosed: {
2069                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
2070                 }
2071                 case LDKClosureReason_CooperativeClosure: {
2072                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
2073                 }
2074                 case LDKClosureReason_CommitmentTxConfirmed: {
2075                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
2076                 }
2077                 case LDKClosureReason_FundingTimedOut: {
2078                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
2079                 }
2080                 case LDKClosureReason_ProcessingError: {
2081                         LDKStr err_str = obj->processing_error.err;
2082                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2083                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
2084                 }
2085                 case LDKClosureReason_DisconnectedPeer: {
2086                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
2087                 }
2088                 case LDKClosureReason_OutdatedChannelManager: {
2089                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
2090                 }
2091                 default: abort();
2092         }
2093 }
2094 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
2095 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
2096 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
2097 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
2098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
2099         LDKCOption_ClosureReasonZ_Some_class =
2100                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
2101         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
2102         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
2103         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
2104         LDKCOption_ClosureReasonZ_None_class =
2105                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
2106         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
2107         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
2108         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
2109 }
2110 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2111         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
2112         switch(obj->tag) {
2113                 case LDKCOption_ClosureReasonZ_Some: {
2114                         uintptr_t some_ref = ((uintptr_t)&obj->some) | 1;
2115                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
2116                 }
2117                 case LDKCOption_ClosureReasonZ_None: {
2118                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
2119                 }
2120                 default: abort();
2121         }
2122 }
2123 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2124 CHECK(owner->result_ok);
2125         return COption_ClosureReasonZ_clone(&*owner->contents.result);
2126 }
2127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2128         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2129         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
2130         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
2131         uintptr_t ret_ref = (uintptr_t)ret_copy;
2132         return ret_ref;
2133 }
2134
2135 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2136 CHECK(!owner->result_ok);
2137         return DecodeError_clone(&*owner->contents.err);
2138 }
2139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2140         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2141         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
2142         uintptr_t ret_ref = 0;
2143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2146         ret_ref = (uintptr_t)ret_var.inner;
2147         if (ret_var.is_owned) {
2148                 ret_ref |= 1;
2149         }
2150         return ret_ref;
2151 }
2152
2153 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2154 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2155 static jclass LDKNetworkUpdate_ChannelClosed_class = NULL;
2156 static jmethodID LDKNetworkUpdate_ChannelClosed_meth = NULL;
2157 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2158 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2160         LDKNetworkUpdate_ChannelUpdateMessage_class =
2161                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2162         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2163         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2164         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2165         LDKNetworkUpdate_ChannelClosed_class =
2166                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelClosed"));
2167         CHECK(LDKNetworkUpdate_ChannelClosed_class != NULL);
2168         LDKNetworkUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelClosed_class, "<init>", "(JZ)V");
2169         CHECK(LDKNetworkUpdate_ChannelClosed_meth != NULL);
2170         LDKNetworkUpdate_NodeFailure_class =
2171                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2172         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2173         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2174         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2175 }
2176 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2177         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
2178         switch(obj->tag) {
2179                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2180                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2181                         uintptr_t msg_ref = 0;
2182                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2183                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2184                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2185                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2186                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2187                 }
2188                 case LDKNetworkUpdate_ChannelClosed: {
2189                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelClosed_class, LDKNetworkUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
2190                 }
2191                 case LDKNetworkUpdate_NodeFailure: {
2192                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2193                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2194                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
2195                 }
2196                 default: abort();
2197         }
2198 }
2199 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2200 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2201 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2202 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2204         LDKCOption_NetworkUpdateZ_Some_class =
2205                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2206         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2207         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2208         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2209         LDKCOption_NetworkUpdateZ_None_class =
2210                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2211         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2212         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2213         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2214 }
2215 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2216         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
2217         switch(obj->tag) {
2218                 case LDKCOption_NetworkUpdateZ_Some: {
2219                         uintptr_t some_ref = ((uintptr_t)&obj->some) | 1;
2220                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2221                 }
2222                 case LDKCOption_NetworkUpdateZ_None: {
2223                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2224                 }
2225                 default: abort();
2226         }
2227 }
2228 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2229 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2230 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2231 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2232 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2233 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2235         LDKSpendableOutputDescriptor_StaticOutput_class =
2236                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2237         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2238         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2239         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2240         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2241                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2242         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2243         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2244         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2245         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2246                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2247         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2248         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2249         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2250 }
2251 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2252         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
2253         switch(obj->tag) {
2254                 case LDKSpendableOutputDescriptor_StaticOutput: {
2255                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2256                         uintptr_t outpoint_ref = 0;
2257                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2258                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2259                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2260                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
2261                         uintptr_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
2262                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uintptr_t)output_ref);
2263                 }
2264                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
2265                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
2266                         uintptr_t delayed_payment_output_ref = 0;
2267                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2268                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2269                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
2270                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
2271                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
2272                 }
2273                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
2274                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
2275                         uintptr_t static_payment_output_ref = 0;
2276                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2277                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2278                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
2279                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
2280                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
2281                 }
2282                 default: abort();
2283         }
2284 }
2285 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
2286         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
2287         for (size_t i = 0; i < ret.datalen; i++) {
2288                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
2289         }
2290         return ret;
2291 }
2292 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
2293 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
2294 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
2295 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
2296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
2297         LDKPaymentPurpose_InvoicePayment_class =
2298                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
2299         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
2300         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
2301         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
2302         LDKPaymentPurpose_SpontaneousPayment_class =
2303                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
2304         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
2305         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
2306         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
2307 }
2308 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2309         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
2310         switch(obj->tag) {
2311                 case LDKPaymentPurpose_InvoicePayment: {
2312                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2313                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
2314                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
2315                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
2316                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
2317                 }
2318                 case LDKPaymentPurpose_SpontaneousPayment: {
2319                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
2320                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
2321                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
2322                 }
2323                 default: abort();
2324         }
2325 }
2326 static jclass LDKEvent_FundingGenerationReady_class = NULL;
2327 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
2328 static jclass LDKEvent_PaymentReceived_class = NULL;
2329 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
2330 static jclass LDKEvent_PaymentSent_class = NULL;
2331 static jmethodID LDKEvent_PaymentSent_meth = NULL;
2332 static jclass LDKEvent_PaymentPathFailed_class = NULL;
2333 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
2334 static jclass LDKEvent_PaymentFailed_class = NULL;
2335 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
2336 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
2337 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
2338 static jclass LDKEvent_SpendableOutputs_class = NULL;
2339 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
2340 static jclass LDKEvent_PaymentForwarded_class = NULL;
2341 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
2342 static jclass LDKEvent_ChannelClosed_class = NULL;
2343 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
2344 static jclass LDKEvent_DiscardFunding_class = NULL;
2345 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
2346 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
2347 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
2348 static jclass LDKEvent_OpenChannelRequest_class = NULL;
2349 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
2350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
2351         LDKEvent_FundingGenerationReady_class =
2352                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
2353         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
2354         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
2355         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
2356         LDKEvent_PaymentReceived_class =
2357                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentReceived"));
2358         CHECK(LDKEvent_PaymentReceived_class != NULL);
2359         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
2360         CHECK(LDKEvent_PaymentReceived_meth != NULL);
2361         LDKEvent_PaymentSent_class =
2362                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
2363         CHECK(LDKEvent_PaymentSent_class != NULL);
2364         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
2365         CHECK(LDKEvent_PaymentSent_meth != NULL);
2366         LDKEvent_PaymentPathFailed_class =
2367                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
2368         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
2369         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
2370         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
2371         LDKEvent_PaymentFailed_class =
2372                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
2373         CHECK(LDKEvent_PaymentFailed_class != NULL);
2374         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
2375         CHECK(LDKEvent_PaymentFailed_meth != NULL);
2376         LDKEvent_PendingHTLCsForwardable_class =
2377                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
2378         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
2379         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
2380         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
2381         LDKEvent_SpendableOutputs_class =
2382                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
2383         CHECK(LDKEvent_SpendableOutputs_class != NULL);
2384         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
2385         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
2386         LDKEvent_PaymentForwarded_class =
2387                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
2388         CHECK(LDKEvent_PaymentForwarded_class != NULL);
2389         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "(JZ)V");
2390         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
2391         LDKEvent_ChannelClosed_class =
2392                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
2393         CHECK(LDKEvent_ChannelClosed_class != NULL);
2394         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
2395         CHECK(LDKEvent_ChannelClosed_meth != NULL);
2396         LDKEvent_DiscardFunding_class =
2397                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
2398         CHECK(LDKEvent_DiscardFunding_class != NULL);
2399         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
2400         CHECK(LDKEvent_DiscardFunding_meth != NULL);
2401         LDKEvent_PaymentPathSuccessful_class =
2402                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
2403         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
2404         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
2405         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
2406         LDKEvent_OpenChannelRequest_class =
2407                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
2408         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
2409         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJ)V");
2410         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
2411 }
2412 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2413         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2414         switch(obj->tag) {
2415                 case LDKEvent_FundingGenerationReady: {
2416                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2417                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
2418                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
2419                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
2420                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
2421                         return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, obj->funding_generation_ready.channel_value_satoshis, output_script_arr, obj->funding_generation_ready.user_channel_id);
2422                 }
2423                 case LDKEvent_PaymentReceived: {
2424                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2425                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
2426                         uintptr_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
2427                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
2428                 }
2429                 case LDKEvent_PaymentSent: {
2430                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2431                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
2432                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2433                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
2434                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2435                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
2436                         uintptr_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
2437                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
2438                 }
2439                 case LDKEvent_PaymentPathFailed: {
2440                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2441                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
2442                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2443                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
2444                         uintptr_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
2445                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
2446                         int64_tArray path_arr = NULL;
2447                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2448                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2449                         for (size_t k = 0; k < path_var.datalen; k++) {
2450                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2451                                 uintptr_t path_conv_10_ref = 0;
2452                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2453                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2454                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2455                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2456                                 path_arr_ptr[k] = path_conv_10_ref;
2457                         }
2458                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2459                         uintptr_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
2460                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
2461                         uintptr_t retry_ref = 0;
2462                         if ((uintptr_t)retry_var.inner > 4096) {
2463                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2464                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2465                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
2466                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
2467                         }
2468                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, obj->payment_path_failed.rejected_by_dest, network_update_ref, obj->payment_path_failed.all_paths_failed, path_arr, short_channel_id_ref, retry_ref);
2469                 }
2470                 case LDKEvent_PaymentFailed: {
2471                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2472                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
2473                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2474                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
2475                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
2476                 }
2477                 case LDKEvent_PendingHTLCsForwardable: {
2478                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
2479                 }
2480                 case LDKEvent_SpendableOutputs: {
2481                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
2482                         int64_tArray outputs_arr = NULL;
2483                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
2484                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
2485                         for (size_t b = 0; b < outputs_var.datalen; b++) {
2486                                 uintptr_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
2487                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
2488                         }
2489                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
2490                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
2491                 }
2492                 case LDKEvent_PaymentForwarded: {
2493                         uintptr_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
2494                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, obj->payment_forwarded.claim_from_onchain_tx);
2495                 }
2496                 case LDKEvent_ChannelClosed: {
2497                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2498                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
2499                         uintptr_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
2500                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, obj->channel_closed.user_channel_id, reason_ref);
2501                 }
2502                 case LDKEvent_DiscardFunding: {
2503                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2504                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
2505                         LDKTransaction transaction_var = obj->discard_funding.transaction;
2506                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
2507                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
2508                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
2509                 }
2510                 case LDKEvent_PaymentPathSuccessful: {
2511                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2512                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
2513                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2514                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
2515                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
2516                         int64_tArray path_arr = NULL;
2517                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2518                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2519                         for (size_t k = 0; k < path_var.datalen; k++) {
2520                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2521                                 uintptr_t path_conv_10_ref = 0;
2522                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2523                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2524                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2525                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2526                                 path_arr_ptr[k] = path_conv_10_ref;
2527                         }
2528                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2529                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2530                 }
2531                 case LDKEvent_OpenChannelRequest: {
2532                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2533                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
2534                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2535                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
2536                         return (*env)->NewObject(env, LDKEvent_OpenChannelRequest_class, LDKEvent_OpenChannelRequest_meth, temporary_channel_id_arr, counterparty_node_id_arr, obj->open_channel_request.funding_satoshis, obj->open_channel_request.push_msat);
2537                 }
2538                 default: abort();
2539         }
2540 }
2541 static jclass LDKCOption_EventZ_Some_class = NULL;
2542 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
2543 static jclass LDKCOption_EventZ_None_class = NULL;
2544 static jmethodID LDKCOption_EventZ_None_meth = NULL;
2545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
2546         LDKCOption_EventZ_Some_class =
2547                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
2548         CHECK(LDKCOption_EventZ_Some_class != NULL);
2549         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
2550         CHECK(LDKCOption_EventZ_Some_meth != NULL);
2551         LDKCOption_EventZ_None_class =
2552                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
2553         CHECK(LDKCOption_EventZ_None_class != NULL);
2554         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
2555         CHECK(LDKCOption_EventZ_None_meth != NULL);
2556 }
2557 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2558         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2559         switch(obj->tag) {
2560                 case LDKCOption_EventZ_Some: {
2561                         uintptr_t some_ref = ((uintptr_t)&obj->some) | 1;
2562                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
2563                 }
2564                 case LDKCOption_EventZ_None: {
2565                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
2566                 }
2567                 default: abort();
2568         }
2569 }
2570 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2571 CHECK(owner->result_ok);
2572         return COption_EventZ_clone(&*owner->contents.result);
2573 }
2574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2575         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2576         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
2577         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
2578         uintptr_t ret_ref = (uintptr_t)ret_copy;
2579         return ret_ref;
2580 }
2581
2582 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2583 CHECK(!owner->result_ok);
2584         return DecodeError_clone(&*owner->contents.err);
2585 }
2586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2587         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2588         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
2589         uintptr_t ret_ref = 0;
2590         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2591         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2593         ret_ref = (uintptr_t)ret_var.inner;
2594         if (ret_var.is_owned) {
2595                 ret_ref |= 1;
2596         }
2597         return ret_ref;
2598 }
2599
2600 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
2601 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
2602 static jclass LDKErrorAction_IgnoreError_class = NULL;
2603 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
2604 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
2605 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
2606 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
2607 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
2608 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
2609 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
2610 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
2611 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
2612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
2613         LDKErrorAction_DisconnectPeer_class =
2614                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
2615         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2616         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2617         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2618         LDKErrorAction_IgnoreError_class =
2619                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
2620         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2621         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2622         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2623         LDKErrorAction_IgnoreAndLog_class =
2624                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
2625         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
2626         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
2627         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
2628         LDKErrorAction_IgnoreDuplicateGossip_class =
2629                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
2630         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
2631         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
2632         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
2633         LDKErrorAction_SendErrorMessage_class =
2634                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
2635         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2636         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2637         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2638         LDKErrorAction_SendWarningMessage_class =
2639                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
2640         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
2641         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
2642         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
2643 }
2644 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2645         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2646         switch(obj->tag) {
2647                 case LDKErrorAction_DisconnectPeer: {
2648                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2649                         uintptr_t msg_ref = 0;
2650                         if ((uintptr_t)msg_var.inner > 4096) {
2651                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2652                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2653                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2654                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
2655                         }
2656                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2657                 }
2658                 case LDKErrorAction_IgnoreError: {
2659                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2660                 }
2661                 case LDKErrorAction_IgnoreAndLog: {
2662                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
2663                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
2664                 }
2665                 case LDKErrorAction_IgnoreDuplicateGossip: {
2666                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
2667                 }
2668                 case LDKErrorAction_SendErrorMessage: {
2669                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2670                         uintptr_t msg_ref = 0;
2671                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2672                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2673                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2674                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2675                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2676                 }
2677                 case LDKErrorAction_SendWarningMessage: {
2678                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2679                         uintptr_t msg_ref = 0;
2680                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2681                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2682                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2683                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2684                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
2685                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
2686                 }
2687                 default: abort();
2688         }
2689 }
2690 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2691 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2692 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2693 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2694 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2695 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2696 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2697 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2698 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
2699 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
2700 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2701 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2702 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2703 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2704 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2705 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2706 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2707 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2708 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2709 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2710 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2711 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2712 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2713 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2714 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2715 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2716 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2717 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2718 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
2719 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
2720 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2721 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2722 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2723 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2724 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2725 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2726 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2727 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2729         LDKMessageSendEvent_SendAcceptChannel_class =
2730                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
2731         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2732         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2733         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2734         LDKMessageSendEvent_SendOpenChannel_class =
2735                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
2736         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2737         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2738         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2739         LDKMessageSendEvent_SendFundingCreated_class =
2740                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
2741         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2742         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2743         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2744         LDKMessageSendEvent_SendFundingSigned_class =
2745                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
2746         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2747         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2748         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2749         LDKMessageSendEvent_SendFundingLocked_class =
2750                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked"));
2751         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
2752         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
2753         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
2754         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2755                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
2756         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2757         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2758         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2759         LDKMessageSendEvent_UpdateHTLCs_class =
2760                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
2761         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2762         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2763         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2764         LDKMessageSendEvent_SendRevokeAndACK_class =
2765                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
2766         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2767         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2768         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2769         LDKMessageSendEvent_SendClosingSigned_class =
2770                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
2771         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2772         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2773         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2774         LDKMessageSendEvent_SendShutdown_class =
2775                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
2776         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2777         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2778         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2779         LDKMessageSendEvent_SendChannelReestablish_class =
2780                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
2781         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2782         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2783         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2784         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2785                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
2786         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2787         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2788         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2789         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2790                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
2791         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2792         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2793         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2794         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2795                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
2796         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2797         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2798         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2799         LDKMessageSendEvent_SendChannelUpdate_class =
2800                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
2801         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
2802         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
2803         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
2804         LDKMessageSendEvent_HandleError_class =
2805                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
2806         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2807         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2808         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2809         LDKMessageSendEvent_SendChannelRangeQuery_class =
2810                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
2811         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2812         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2813         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2814         LDKMessageSendEvent_SendShortIdsQuery_class =
2815                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
2816         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2817         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2818         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2819         LDKMessageSendEvent_SendReplyChannelRange_class =
2820                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
2821         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2822         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2823         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2824 }
2825 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2826         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2827         switch(obj->tag) {
2828                 case LDKMessageSendEvent_SendAcceptChannel: {
2829                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2830                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2831                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2832                         uintptr_t msg_ref = 0;
2833                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2834                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2835                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2836                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2837                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
2838                 }
2839                 case LDKMessageSendEvent_SendOpenChannel: {
2840                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2841                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
2842                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2843                         uintptr_t msg_ref = 0;
2844                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2845                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2846                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2847                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2848                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
2849                 }
2850                 case LDKMessageSendEvent_SendFundingCreated: {
2851                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2852                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
2853                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2854                         uintptr_t msg_ref = 0;
2855                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2856                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2857                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2858                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2859                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
2860                 }
2861                 case LDKMessageSendEvent_SendFundingSigned: {
2862                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2863                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
2864                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2865                         uintptr_t msg_ref = 0;
2866                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2867                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2868                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2869                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2870                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
2871                 }
2872                 case LDKMessageSendEvent_SendFundingLocked: {
2873                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2874                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
2875                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2876                         uintptr_t msg_ref = 0;
2877                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2878                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2879                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2880                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2881                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
2882                 }
2883                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
2884                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2885                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
2886                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2887                         uintptr_t msg_ref = 0;
2888                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2889                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2890                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2891                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2892                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
2893                 }
2894                 case LDKMessageSendEvent_UpdateHTLCs: {
2895                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2896                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
2897                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2898                         uintptr_t updates_ref = 0;
2899                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2900                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2901                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2902                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2903                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
2904                 }
2905                 case LDKMessageSendEvent_SendRevokeAndACK: {
2906                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2907                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
2908                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2909                         uintptr_t msg_ref = 0;
2910                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2911                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2912                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2913                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2914                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
2915                 }
2916                 case LDKMessageSendEvent_SendClosingSigned: {
2917                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2918                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
2919                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2920                         uintptr_t msg_ref = 0;
2921                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2922                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2923                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2924                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2925                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
2926                 }
2927                 case LDKMessageSendEvent_SendShutdown: {
2928                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2929                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
2930                         LDKShutdown msg_var = obj->send_shutdown.msg;
2931                         uintptr_t msg_ref = 0;
2932                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2933                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2934                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2935                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2936                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
2937                 }
2938                 case LDKMessageSendEvent_SendChannelReestablish: {
2939                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2940                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
2941                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2942                         uintptr_t msg_ref = 0;
2943                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2944                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2945                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2946                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2947                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
2948                 }
2949                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
2950                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2951                         uintptr_t msg_ref = 0;
2952                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2953                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2954                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2955                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2956                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2957                         uintptr_t update_msg_ref = 0;
2958                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2959                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2960                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2961                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2962                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
2963                 }
2964                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
2965                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2966                         uintptr_t msg_ref = 0;
2967                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2968                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2969                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2970                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2971                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
2972                 }
2973                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
2974                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2975                         uintptr_t msg_ref = 0;
2976                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2977                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2978                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2979                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2980                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
2981                 }
2982                 case LDKMessageSendEvent_SendChannelUpdate: {
2983                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2984                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
2985                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2986                         uintptr_t msg_ref = 0;
2987                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2988                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2989                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2990                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2991                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
2992                 }
2993                 case LDKMessageSendEvent_HandleError: {
2994                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2995                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
2996                         uintptr_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2997                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
2998                 }
2999                 case LDKMessageSendEvent_SendChannelRangeQuery: {
3000                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3001                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
3002                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
3003                         uintptr_t msg_ref = 0;
3004                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3005                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3006                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3007                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3008                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
3009                 }
3010                 case LDKMessageSendEvent_SendShortIdsQuery: {
3011                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3012                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
3013                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
3014                         uintptr_t msg_ref = 0;
3015                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3016                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3017                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3018                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3019                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
3020                 }
3021                 case LDKMessageSendEvent_SendReplyChannelRange: {
3022                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3023                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
3024                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3025                         uintptr_t msg_ref = 0;
3026                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3027                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3028                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3029                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3030                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
3031                 }
3032                 default: abort();
3033         }
3034 }
3035 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3036         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3037         for (size_t i = 0; i < ret.datalen; i++) {
3038                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3039         }
3040         return ret;
3041 }
3042 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3043 CHECK(owner->result_ok);
3044         return FixedPenaltyScorer_clone(&*owner->contents.result);
3045 }
3046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3047         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3048         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3049         uintptr_t ret_ref = 0;
3050         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3051         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3053         ret_ref = (uintptr_t)ret_var.inner;
3054         if (ret_var.is_owned) {
3055                 ret_ref |= 1;
3056         }
3057         return ret_ref;
3058 }
3059
3060 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3061 CHECK(!owner->result_ok);
3062         return DecodeError_clone(&*owner->contents.err);
3063 }
3064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3065         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3066         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3067         uintptr_t ret_ref = 0;
3068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3071         ret_ref = (uintptr_t)ret_var.inner;
3072         if (ret_var.is_owned) {
3073                 ret_ref |= 1;
3074         }
3075         return ret_ref;
3076 }
3077
3078 static inline struct LDKScoringParameters CResult_ScoringParametersDecodeErrorZ_get_ok(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
3079 CHECK(owner->result_ok);
3080         return ScoringParameters_clone(&*owner->contents.result);
3081 }
3082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3083         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
3084         LDKScoringParameters ret_var = CResult_ScoringParametersDecodeErrorZ_get_ok(owner_conv);
3085         uintptr_t ret_ref = 0;
3086         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3087         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3088         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3089         ret_ref = (uintptr_t)ret_var.inner;
3090         if (ret_var.is_owned) {
3091                 ret_ref |= 1;
3092         }
3093         return ret_ref;
3094 }
3095
3096 static inline struct LDKDecodeError CResult_ScoringParametersDecodeErrorZ_get_err(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
3097 CHECK(!owner->result_ok);
3098         return DecodeError_clone(&*owner->contents.err);
3099 }
3100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3101         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
3102         LDKDecodeError ret_var = CResult_ScoringParametersDecodeErrorZ_get_err(owner_conv);
3103         uintptr_t ret_ref = 0;
3104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3107         ret_ref = (uintptr_t)ret_var.inner;
3108         if (ret_var.is_owned) {
3109                 ret_ref |= 1;
3110         }
3111         return ret_ref;
3112 }
3113
3114 static inline struct LDKScorer *CResult_ScorerDecodeErrorZ_get_ok(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
3115 CHECK(owner->result_ok);
3116         return &*owner->contents.result;
3117 }
3118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3119         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
3120         LDKScorer ret_var = *CResult_ScorerDecodeErrorZ_get_ok(owner_conv);
3121         uintptr_t ret_ref = 0;
3122         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3123         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3125         ret_ref = (uintptr_t)ret_var.inner & ~1;
3126         return ret_ref;
3127 }
3128
3129 static inline struct LDKDecodeError CResult_ScorerDecodeErrorZ_get_err(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
3130 CHECK(!owner->result_ok);
3131         return DecodeError_clone(&*owner->contents.err);
3132 }
3133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3134         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
3135         LDKDecodeError ret_var = CResult_ScorerDecodeErrorZ_get_err(owner_conv);
3136         uintptr_t ret_ref = 0;
3137         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3138         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3139         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3140         ret_ref = (uintptr_t)ret_var.inner;
3141         if (ret_var.is_owned) {
3142                 ret_ref |= 1;
3143         }
3144         return ret_ref;
3145 }
3146
3147 static inline struct LDKProbabilisticScoringParameters CResult_ProbabilisticScoringParametersDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR owner){
3148 CHECK(owner->result_ok);
3149         return ProbabilisticScoringParameters_clone(&*owner->contents.result);
3150 }
3151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3152         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(owner & ~1);
3153         LDKProbabilisticScoringParameters ret_var = CResult_ProbabilisticScoringParametersDecodeErrorZ_get_ok(owner_conv);
3154         uintptr_t ret_ref = 0;
3155         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3156         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3158         ret_ref = (uintptr_t)ret_var.inner;
3159         if (ret_var.is_owned) {
3160                 ret_ref |= 1;
3161         }
3162         return ret_ref;
3163 }
3164
3165 static inline struct LDKDecodeError CResult_ProbabilisticScoringParametersDecodeErrorZ_get_err(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR owner){
3166 CHECK(!owner->result_ok);
3167         return DecodeError_clone(&*owner->contents.err);
3168 }
3169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3170         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(owner & ~1);
3171         LDKDecodeError ret_var = CResult_ProbabilisticScoringParametersDecodeErrorZ_get_err(owner_conv);
3172         uintptr_t ret_ref = 0;
3173         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3174         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3176         ret_ref = (uintptr_t)ret_var.inner;
3177         if (ret_var.is_owned) {
3178                 ret_ref |= 1;
3179         }
3180         return ret_ref;
3181 }
3182
3183 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3184 CHECK(owner->result_ok);
3185         return InitFeatures_clone(&*owner->contents.result);
3186 }
3187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3188         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3189         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
3190         uintptr_t ret_ref = 0;
3191         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3192         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3194         ret_ref = (uintptr_t)ret_var.inner;
3195         if (ret_var.is_owned) {
3196                 ret_ref |= 1;
3197         }
3198         return ret_ref;
3199 }
3200
3201 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3202 CHECK(!owner->result_ok);
3203         return DecodeError_clone(&*owner->contents.err);
3204 }
3205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3206         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3207         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
3208         uintptr_t ret_ref = 0;
3209         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3210         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3212         ret_ref = (uintptr_t)ret_var.inner;
3213         if (ret_var.is_owned) {
3214                 ret_ref |= 1;
3215         }
3216         return ret_ref;
3217 }
3218
3219 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3220 CHECK(owner->result_ok);
3221         return ChannelFeatures_clone(&*owner->contents.result);
3222 }
3223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3224         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3225         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
3226         uintptr_t ret_ref = 0;
3227         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3228         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3230         ret_ref = (uintptr_t)ret_var.inner;
3231         if (ret_var.is_owned) {
3232                 ret_ref |= 1;
3233         }
3234         return ret_ref;
3235 }
3236
3237 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3238 CHECK(!owner->result_ok);
3239         return DecodeError_clone(&*owner->contents.err);
3240 }
3241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3242         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3243         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
3244         uintptr_t ret_ref = 0;
3245         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3246         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3248         ret_ref = (uintptr_t)ret_var.inner;
3249         if (ret_var.is_owned) {
3250                 ret_ref |= 1;
3251         }
3252         return ret_ref;
3253 }
3254
3255 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3256 CHECK(owner->result_ok);
3257         return NodeFeatures_clone(&*owner->contents.result);
3258 }
3259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3260         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3261         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
3262         uintptr_t ret_ref = 0;
3263         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3264         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3266         ret_ref = (uintptr_t)ret_var.inner;
3267         if (ret_var.is_owned) {
3268                 ret_ref |= 1;
3269         }
3270         return ret_ref;
3271 }
3272
3273 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3274 CHECK(!owner->result_ok);
3275         return DecodeError_clone(&*owner->contents.err);
3276 }
3277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3278         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3279         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3280         uintptr_t ret_ref = 0;
3281         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3282         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3284         ret_ref = (uintptr_t)ret_var.inner;
3285         if (ret_var.is_owned) {
3286                 ret_ref |= 1;
3287         }
3288         return ret_ref;
3289 }
3290
3291 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3292 CHECK(owner->result_ok);
3293         return InvoiceFeatures_clone(&*owner->contents.result);
3294 }
3295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3296         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3297         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3298         uintptr_t ret_ref = 0;
3299         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3300         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3302         ret_ref = (uintptr_t)ret_var.inner;
3303         if (ret_var.is_owned) {
3304                 ret_ref |= 1;
3305         }
3306         return ret_ref;
3307 }
3308
3309 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3310 CHECK(!owner->result_ok);
3311         return DecodeError_clone(&*owner->contents.err);
3312 }
3313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3314         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3315         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3316         uintptr_t ret_ref = 0;
3317         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3318         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3320         ret_ref = (uintptr_t)ret_var.inner;
3321         if (ret_var.is_owned) {
3322                 ret_ref |= 1;
3323         }
3324         return ret_ref;
3325 }
3326
3327 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3328 CHECK(owner->result_ok);
3329         return ChannelTypeFeatures_clone(&*owner->contents.result);
3330 }
3331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3332         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3333         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3334         uintptr_t ret_ref = 0;
3335         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3336         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3338         ret_ref = (uintptr_t)ret_var.inner;
3339         if (ret_var.is_owned) {
3340                 ret_ref |= 1;
3341         }
3342         return ret_ref;
3343 }
3344
3345 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3346 CHECK(!owner->result_ok);
3347         return DecodeError_clone(&*owner->contents.err);
3348 }
3349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3350         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3351         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3352         uintptr_t ret_ref = 0;
3353         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3354         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3356         ret_ref = (uintptr_t)ret_var.inner;
3357         if (ret_var.is_owned) {
3358                 ret_ref |= 1;
3359         }
3360         return ret_ref;
3361 }
3362
3363 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3364 CHECK(owner->result_ok);
3365         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
3366 }
3367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3368         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3369         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3370         uintptr_t ret_ref = 0;
3371         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3372         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3374         ret_ref = (uintptr_t)ret_var.inner;
3375         if (ret_var.is_owned) {
3376                 ret_ref |= 1;
3377         }
3378         return ret_ref;
3379 }
3380
3381 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3382 CHECK(!owner->result_ok);
3383         return DecodeError_clone(&*owner->contents.err);
3384 }
3385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3386         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3387         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3388         uintptr_t ret_ref = 0;
3389         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3390         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3392         ret_ref = (uintptr_t)ret_var.inner;
3393         if (ret_var.is_owned) {
3394                 ret_ref |= 1;
3395         }
3396         return ret_ref;
3397 }
3398
3399 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3400 CHECK(owner->result_ok);
3401         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
3402 }
3403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3404         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3405         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3406         uintptr_t ret_ref = 0;
3407         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3408         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3410         ret_ref = (uintptr_t)ret_var.inner;
3411         if (ret_var.is_owned) {
3412                 ret_ref |= 1;
3413         }
3414         return ret_ref;
3415 }
3416
3417 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3418 CHECK(!owner->result_ok);
3419         return DecodeError_clone(&*owner->contents.err);
3420 }
3421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3422         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3423         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3424         uintptr_t ret_ref = 0;
3425         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3426         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3428         ret_ref = (uintptr_t)ret_var.inner;
3429         if (ret_var.is_owned) {
3430                 ret_ref |= 1;
3431         }
3432         return ret_ref;
3433 }
3434
3435 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3436 CHECK(owner->result_ok);
3437         return SpendableOutputDescriptor_clone(&*owner->contents.result);
3438 }
3439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3440         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3441         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
3442         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3443         uintptr_t ret_ref = (uintptr_t)ret_copy;
3444         return ret_ref;
3445 }
3446
3447 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3448 CHECK(!owner->result_ok);
3449         return DecodeError_clone(&*owner->contents.err);
3450 }
3451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3452         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3453         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3454         uintptr_t ret_ref = 0;
3455         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3456         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3457         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3458         ret_ref = (uintptr_t)ret_var.inner;
3459         if (ret_var.is_owned) {
3460                 ret_ref |= 1;
3461         }
3462         return ret_ref;
3463 }
3464
3465 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
3466         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
3467         for (size_t i = 0; i < ret.datalen; i++) {
3468                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3469         }
3470         return ret;
3471 }
3472 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3473         return owner->a;
3474 }
3475 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3476         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3477         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3478         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
3479         return ret_arr;
3480 }
3481
3482 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3483         return owner->b;
3484 }
3485 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3486         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3487         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
3488         jobjectArray ret_arr = NULL;
3489         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
3490         ;
3491         for (size_t i = 0; i < ret_var.datalen; i++) {
3492                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
3493                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
3494                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
3495         }
3496         
3497         return ret_arr;
3498 }
3499
3500 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3501 CHECK(owner->result_ok);
3502         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
3503 }
3504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3505         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3506         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
3507         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
3508         return ((uintptr_t)ret_conv);
3509 }
3510
3511 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3512 CHECK(!owner->result_ok);
3513         return *owner->contents.err;
3514 }
3515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3516         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3517         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
3518 }
3519
3520 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3521 CHECK(owner->result_ok);
3522         return *owner->contents.result;
3523 }
3524 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3525         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3526         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3527         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
3528         return ret_arr;
3529 }
3530
3531 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3532 CHECK(!owner->result_ok);
3533         return *owner->contents.err;
3534 }
3535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3536         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3537         CResult_SignatureNoneZ_get_err(owner_conv);
3538 }
3539
3540 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3541         return owner->a;
3542 }
3543 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3544         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3545         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3546         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
3547         return ret_arr;
3548 }
3549
3550 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3551         return owner->b;
3552 }
3553 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3554         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3555         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3556         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
3557         return ret_arr;
3558 }
3559
3560 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3561 CHECK(owner->result_ok);
3562         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
3563 }
3564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3565         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3566         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
3567         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
3568         return ((uintptr_t)ret_conv);
3569 }
3570
3571 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3572 CHECK(!owner->result_ok);
3573         return *owner->contents.err;
3574 }
3575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3576         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3577         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
3578 }
3579
3580 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3581 CHECK(owner->result_ok);
3582         return *owner->contents.result;
3583 }
3584 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3585         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3586         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3587         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
3588         return ret_arr;
3589 }
3590
3591 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3592 CHECK(!owner->result_ok);
3593         return *owner->contents.err;
3594 }
3595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3596         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3597         CResult_SecretKeyNoneZ_get_err(owner_conv);
3598 }
3599
3600 typedef struct LDKBaseSign_JCalls {
3601         atomic_size_t refcnt;
3602         JavaVM *vm;
3603         jweak o;
3604         jmethodID get_per_commitment_point_meth;
3605         jmethodID release_commitment_secret_meth;
3606         jmethodID validate_holder_commitment_meth;
3607         jmethodID channel_keys_id_meth;
3608         jmethodID sign_counterparty_commitment_meth;
3609         jmethodID validate_counterparty_revocation_meth;
3610         jmethodID sign_holder_commitment_and_htlcs_meth;
3611         jmethodID sign_justice_revoked_output_meth;
3612         jmethodID sign_justice_revoked_htlc_meth;
3613         jmethodID sign_counterparty_htlc_transaction_meth;
3614         jmethodID sign_closing_transaction_meth;
3615         jmethodID sign_channel_announcement_meth;
3616         jmethodID ready_channel_meth;
3617 } LDKBaseSign_JCalls;
3618 static void LDKBaseSign_JCalls_free(void* this_arg) {
3619         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3620         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3621                 JNIEnv *env;
3622                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3623                 if (get_jenv_res == JNI_EDETACHED) {
3624                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3625                 } else {
3626                         DO_ASSERT(get_jenv_res == JNI_OK);
3627                 }
3628                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3629                 if (get_jenv_res == JNI_EDETACHED) {
3630                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3631                 }
3632                 FREE(j_calls);
3633         }
3634 }
3635 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3636         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3637         JNIEnv *env;
3638         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3639         if (get_jenv_res == JNI_EDETACHED) {
3640                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3641         } else {
3642                 DO_ASSERT(get_jenv_res == JNI_OK);
3643         }
3644         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3645         CHECK(obj != NULL);
3646         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
3647         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3648                 (*env)->ExceptionDescribe(env);
3649                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
3650         }
3651         LDKPublicKey ret_ref;
3652         CHECK((*env)->GetArrayLength(env, ret) == 33);
3653         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3654         if (get_jenv_res == JNI_EDETACHED) {
3655                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3656         }
3657         return ret_ref;
3658 }
3659 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3660         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3661         JNIEnv *env;
3662         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3663         if (get_jenv_res == JNI_EDETACHED) {
3664                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3665         } else {
3666                 DO_ASSERT(get_jenv_res == JNI_OK);
3667         }
3668         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3669         CHECK(obj != NULL);
3670         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
3671         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3672                 (*env)->ExceptionDescribe(env);
3673                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
3674         }
3675         LDKThirtyTwoBytes ret_ref;
3676         CHECK((*env)->GetArrayLength(env, ret) == 32);
3677         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3678         if (get_jenv_res == JNI_EDETACHED) {
3679                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3680         }
3681         return ret_ref;
3682 }
3683 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
3684         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3685         JNIEnv *env;
3686         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3687         if (get_jenv_res == JNI_EDETACHED) {
3688                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3689         } else {
3690                 DO_ASSERT(get_jenv_res == JNI_OK);
3691         }
3692         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
3693         uintptr_t holder_tx_ref = 0;
3694         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
3695         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3696         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3697         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
3698         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
3699         if (holder_tx_var.is_owned) {
3700                 holder_tx_ref |= 1;
3701         }
3702         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3703         jobjectArray preimages_arr = NULL;
3704         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
3705         ;
3706         for (size_t i = 0; i < preimages_var.datalen; i++) {
3707                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
3708                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
3709                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
3710         }
3711         
3712         FREE(preimages_var.data);
3713         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3714         CHECK(obj != NULL);
3715         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
3716         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3717                 (*env)->ExceptionDescribe(env);
3718                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
3719         }
3720         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3721         CHECK_ACCESS(ret_ptr);
3722         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3723         FREE((void*)ret);
3724         if (get_jenv_res == JNI_EDETACHED) {
3725                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3726         }
3727         return ret_conv;
3728 }
3729 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
3730         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3731         JNIEnv *env;
3732         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3733         if (get_jenv_res == JNI_EDETACHED) {
3734                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3735         } else {
3736                 DO_ASSERT(get_jenv_res == JNI_OK);
3737         }
3738         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3739         CHECK(obj != NULL);
3740         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
3741         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3742                 (*env)->ExceptionDescribe(env);
3743                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
3744         }
3745         LDKThirtyTwoBytes ret_ref;
3746         CHECK((*env)->GetArrayLength(env, ret) == 32);
3747         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3748         if (get_jenv_res == JNI_EDETACHED) {
3749                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3750         }
3751         return ret_ref;
3752 }
3753 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
3754         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3755         JNIEnv *env;
3756         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3757         if (get_jenv_res == JNI_EDETACHED) {
3758                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3759         } else {
3760                 DO_ASSERT(get_jenv_res == JNI_OK);
3761         }
3762         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
3763         uintptr_t commitment_tx_ref = 0;
3764         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
3765         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3766         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3767         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3768         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3769         if (commitment_tx_var.is_owned) {
3770                 commitment_tx_ref |= 1;
3771         }
3772         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3773         jobjectArray preimages_arr = NULL;
3774         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
3775         ;
3776         for (size_t i = 0; i < preimages_var.datalen; i++) {
3777                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
3778                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
3779                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
3780         }
3781         
3782         FREE(preimages_var.data);
3783         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3784         CHECK(obj != NULL);
3785         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
3786         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3787                 (*env)->ExceptionDescribe(env);
3788                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
3789         }
3790         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3791         CHECK_ACCESS(ret_ptr);
3792         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3793         FREE((void*)ret);
3794         if (get_jenv_res == JNI_EDETACHED) {
3795                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3796         }
3797         return ret_conv;
3798 }
3799 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
3800         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3801         JNIEnv *env;
3802         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3803         if (get_jenv_res == JNI_EDETACHED) {
3804                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3805         } else {
3806                 DO_ASSERT(get_jenv_res == JNI_OK);
3807         }
3808         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
3809         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
3810         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3811         CHECK(obj != NULL);
3812         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx, secret_arr);
3813         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3814                 (*env)->ExceptionDescribe(env);
3815                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
3816         }
3817         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3818         CHECK_ACCESS(ret_ptr);
3819         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3820         FREE((void*)ret);
3821         if (get_jenv_res == JNI_EDETACHED) {
3822                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3823         }
3824         return ret_conv;
3825 }
3826 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3827         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3828         JNIEnv *env;
3829         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3830         if (get_jenv_res == JNI_EDETACHED) {
3831                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3832         } else {
3833                 DO_ASSERT(get_jenv_res == JNI_OK);
3834         }
3835         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3836         uintptr_t commitment_tx_ref = 0;
3837         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
3838         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3839         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3840         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3841         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3842         if (commitment_tx_var.is_owned) {
3843                 commitment_tx_ref |= 1;
3844         }
3845         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3846         CHECK(obj != NULL);
3847         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
3848         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3849                 (*env)->ExceptionDescribe(env);
3850                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
3851         }
3852         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3853         CHECK_ACCESS(ret_ptr);
3854         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3855         FREE((void*)ret);
3856         if (get_jenv_res == JNI_EDETACHED) {
3857                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3858         }
3859         return ret_conv;
3860 }
3861 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]) {
3862         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3863         JNIEnv *env;
3864         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3865         if (get_jenv_res == JNI_EDETACHED) {
3866                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3867         } else {
3868                 DO_ASSERT(get_jenv_res == JNI_OK);
3869         }
3870         LDKTransaction justice_tx_var = justice_tx;
3871         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
3872         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
3873         Transaction_free(justice_tx_var);
3874         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
3875         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
3876         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3877         CHECK(obj != NULL);
3878         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
3879         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3880                 (*env)->ExceptionDescribe(env);
3881                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
3882         }
3883         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3884         CHECK_ACCESS(ret_ptr);
3885         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3886         FREE((void*)ret);
3887         if (get_jenv_res == JNI_EDETACHED) {
3888                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3889         }
3890         return ret_conv;
3891 }
3892 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) {
3893         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3894         JNIEnv *env;
3895         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3896         if (get_jenv_res == JNI_EDETACHED) {
3897                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3898         } else {
3899                 DO_ASSERT(get_jenv_res == JNI_OK);
3900         }
3901         LDKTransaction justice_tx_var = justice_tx;
3902         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
3903         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
3904         Transaction_free(justice_tx_var);
3905         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
3906         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
3907         LDKHTLCOutputInCommitment htlc_var = *htlc;
3908         uintptr_t htlc_ref = 0;
3909         htlc_var = HTLCOutputInCommitment_clone(htlc);
3910         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3911         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3912         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3913         htlc_ref = (uintptr_t)htlc_var.inner;
3914         if (htlc_var.is_owned) {
3915                 htlc_ref |= 1;
3916         }
3917         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3918         CHECK(obj != NULL);
3919         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
3920         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3921                 (*env)->ExceptionDescribe(env);
3922                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
3923         }
3924         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3925         CHECK_ACCESS(ret_ptr);
3926         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3927         FREE((void*)ret);
3928         if (get_jenv_res == JNI_EDETACHED) {
3929                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3930         }
3931         return ret_conv;
3932 }
3933 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) {
3934         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3935         JNIEnv *env;
3936         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3937         if (get_jenv_res == JNI_EDETACHED) {
3938                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3939         } else {
3940                 DO_ASSERT(get_jenv_res == JNI_OK);
3941         }
3942         LDKTransaction htlc_tx_var = htlc_tx;
3943         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
3944         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
3945         Transaction_free(htlc_tx_var);
3946         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
3947         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
3948         LDKHTLCOutputInCommitment htlc_var = *htlc;
3949         uintptr_t htlc_ref = 0;
3950         htlc_var = HTLCOutputInCommitment_clone(htlc);
3951         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3952         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3953         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3954         htlc_ref = (uintptr_t)htlc_var.inner;
3955         if (htlc_var.is_owned) {
3956                 htlc_ref |= 1;
3957         }
3958         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3959         CHECK(obj != NULL);
3960         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
3961         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3962                 (*env)->ExceptionDescribe(env);
3963                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
3964         }
3965         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3966         CHECK_ACCESS(ret_ptr);
3967         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3968         FREE((void*)ret);
3969         if (get_jenv_res == JNI_EDETACHED) {
3970                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3971         }
3972         return ret_conv;
3973 }
3974 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
3975         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3976         JNIEnv *env;
3977         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3978         if (get_jenv_res == JNI_EDETACHED) {
3979                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3980         } else {
3981                 DO_ASSERT(get_jenv_res == JNI_OK);
3982         }
3983         LDKClosingTransaction closing_tx_var = *closing_tx;
3984         uintptr_t closing_tx_ref = 0;
3985         closing_tx_var = ClosingTransaction_clone(closing_tx);
3986         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3987         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3988         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
3989         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
3990         if (closing_tx_var.is_owned) {
3991                 closing_tx_ref |= 1;
3992         }
3993         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3994         CHECK(obj != NULL);
3995         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
3996         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3997                 (*env)->ExceptionDescribe(env);
3998                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
3999         }
4000         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4001         CHECK_ACCESS(ret_ptr);
4002         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4003         FREE((void*)ret);
4004         if (get_jenv_res == JNI_EDETACHED) {
4005                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4006         }
4007         return ret_conv;
4008 }
4009 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
4010         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4011         JNIEnv *env;
4012         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4013         if (get_jenv_res == JNI_EDETACHED) {
4014                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4015         } else {
4016                 DO_ASSERT(get_jenv_res == JNI_OK);
4017         }
4018         LDKUnsignedChannelAnnouncement msg_var = *msg;
4019         uintptr_t msg_ref = 0;
4020         msg_var = UnsignedChannelAnnouncement_clone(msg);
4021         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4022         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4023         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4024         msg_ref = (uintptr_t)msg_var.inner;
4025         if (msg_var.is_owned) {
4026                 msg_ref |= 1;
4027         }
4028         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4029         CHECK(obj != NULL);
4030         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
4031         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4032                 (*env)->ExceptionDescribe(env);
4033                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
4034         }
4035         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4036         CHECK_ACCESS(ret_ptr);
4037         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
4038         FREE((void*)ret);
4039         if (get_jenv_res == JNI_EDETACHED) {
4040                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4041         }
4042         return ret_conv;
4043 }
4044 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
4045         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4046         JNIEnv *env;
4047         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4048         if (get_jenv_res == JNI_EDETACHED) {
4049                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4050         } else {
4051                 DO_ASSERT(get_jenv_res == JNI_OK);
4052         }
4053         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
4054         uintptr_t channel_parameters_ref = 0;
4055         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
4056         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4057         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4058         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
4059         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
4060         if (channel_parameters_var.is_owned) {
4061                 channel_parameters_ref |= 1;
4062         }
4063         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4064         CHECK(obj != NULL);
4065         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
4066         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4067                 (*env)->ExceptionDescribe(env);
4068                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
4069         }
4070         if (get_jenv_res == JNI_EDETACHED) {
4071                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4072         }
4073 }
4074 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
4075         jclass c = (*env)->GetObjectClass(env, o);
4076         CHECK(c != NULL);
4077         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
4078         atomic_init(&calls->refcnt, 1);
4079         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4080         calls->o = (*env)->NewWeakGlobalRef(env, o);
4081         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
4082         CHECK(calls->get_per_commitment_point_meth != NULL);
4083         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
4084         CHECK(calls->release_commitment_secret_meth != NULL);
4085         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
4086         CHECK(calls->validate_holder_commitment_meth != NULL);
4087         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
4088         CHECK(calls->channel_keys_id_meth != NULL);
4089         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
4090         CHECK(calls->sign_counterparty_commitment_meth != NULL);
4091         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
4092         CHECK(calls->validate_counterparty_revocation_meth != NULL);
4093         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
4094         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
4095         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
4096         CHECK(calls->sign_justice_revoked_output_meth != NULL);
4097         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
4098         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
4099         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
4100         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
4101         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
4102         CHECK(calls->sign_closing_transaction_meth != NULL);
4103         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
4104         CHECK(calls->sign_channel_announcement_meth != NULL);
4105         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
4106         CHECK(calls->ready_channel_meth != NULL);
4107
4108         LDKChannelPublicKeys pubkeys_conv;
4109         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4110         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4111         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4112
4113         LDKBaseSign ret = {
4114                 .this_arg = (void*) calls,
4115                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
4116                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
4117                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
4118                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
4119                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
4120                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
4121                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
4122                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
4123                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
4124                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
4125                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
4126                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
4127                 .ready_channel = ready_channel_LDKBaseSign_jcall,
4128                 .free = LDKBaseSign_JCalls_free,
4129                 .pubkeys = pubkeys_conv,
4130                 .set_pubkeys = NULL,
4131         };
4132         return ret;
4133 }
4134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
4135         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
4136         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
4137         return (uint64_t)res_ptr;
4138 }
4139 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) {
4140         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4141         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4142         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4143         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
4144         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
4145         return ret_arr;
4146 }
4147
4148 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
4149         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4150         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4151         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4152         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4153         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
4154         return ret_arr;
4155 }
4156
4157 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) {
4158         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4159         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4160         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4161         LDKHolderCommitmentTransaction holder_tx_conv;
4162         holder_tx_conv.inner = (void*)(holder_tx & (~1));
4163         holder_tx_conv.is_owned = false;
4164         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
4165         LDKCVec_PaymentPreimageZ preimages_constr;
4166         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
4167         if (preimages_constr.datalen > 0)
4168                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4169         else
4170                 preimages_constr.data = NULL;
4171         for (size_t i = 0; i < preimages_constr.datalen; i++) {
4172                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
4173                 LDKThirtyTwoBytes preimages_conv_8_ref;
4174                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
4175                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
4176                 preimages_constr.data[i] = preimages_conv_8_ref;
4177         }
4178         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4179         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
4180         return (uintptr_t)ret_conv;
4181 }
4182
4183 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
4184         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4185         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4186         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4187         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4188         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
4189         return ret_arr;
4190 }
4191
4192 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) {
4193         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4194         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4195         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4196         LDKCommitmentTransaction commitment_tx_conv;
4197         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4198         commitment_tx_conv.is_owned = false;
4199         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4200         LDKCVec_PaymentPreimageZ preimages_constr;
4201         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
4202         if (preimages_constr.datalen > 0)
4203                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4204         else
4205                 preimages_constr.data = NULL;
4206         for (size_t i = 0; i < preimages_constr.datalen; i++) {
4207                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
4208                 LDKThirtyTwoBytes preimages_conv_8_ref;
4209                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
4210                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
4211                 preimages_constr.data[i] = preimages_conv_8_ref;
4212         }
4213         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4214         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
4215         return (uintptr_t)ret_conv;
4216 }
4217
4218 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) {
4219         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4220         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4221         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4222         unsigned char secret_arr[32];
4223         CHECK((*env)->GetArrayLength(env, secret) == 32);
4224         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
4225         unsigned char (*secret_ref)[32] = &secret_arr;
4226         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4227         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
4228         return (uintptr_t)ret_conv;
4229 }
4230
4231 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) {
4232         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4233         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4234         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4235         LDKHolderCommitmentTransaction commitment_tx_conv;
4236         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4237         commitment_tx_conv.is_owned = false;
4238         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4239         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4240         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
4241         return (uintptr_t)ret_conv;
4242 }
4243
4244 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, intptr_t input, int64_t amount, int8_tArray per_commitment_key) {
4245         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4246         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4247         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4248         LDKTransaction justice_tx_ref;
4249         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
4250         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4251         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
4252         justice_tx_ref.data_is_owned = true;
4253         unsigned char per_commitment_key_arr[32];
4254         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
4255         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
4256         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4257         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4258         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
4259         return (uintptr_t)ret_conv;
4260 }
4261
4262 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, intptr_t input, int64_t amount, int8_tArray per_commitment_key, int64_t htlc) {
4263         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4264         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4265         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4266         LDKTransaction justice_tx_ref;
4267         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
4268         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4269         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
4270         justice_tx_ref.data_is_owned = true;
4271         unsigned char per_commitment_key_arr[32];
4272         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
4273         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
4274         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4275         LDKHTLCOutputInCommitment htlc_conv;
4276         htlc_conv.inner = (void*)(htlc & (~1));
4277         htlc_conv.is_owned = false;
4278         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4279         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4280         *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);
4281         return (uintptr_t)ret_conv;
4282 }
4283
4284 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, intptr_t input, int64_t amount, int8_tArray per_commitment_point, int64_t htlc) {
4285         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4286         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4287         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4288         LDKTransaction htlc_tx_ref;
4289         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
4290         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
4291         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
4292         htlc_tx_ref.data_is_owned = true;
4293         LDKPublicKey per_commitment_point_ref;
4294         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
4295         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
4296         LDKHTLCOutputInCommitment htlc_conv;
4297         htlc_conv.inner = (void*)(htlc & (~1));
4298         htlc_conv.is_owned = false;
4299         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4300         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4301         *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);
4302         return (uintptr_t)ret_conv;
4303 }
4304
4305 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) {
4306         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4307         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4308         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4309         LDKClosingTransaction closing_tx_conv;
4310         closing_tx_conv.inner = (void*)(closing_tx & (~1));
4311         closing_tx_conv.is_owned = false;
4312         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
4313         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4314         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
4315         return (uintptr_t)ret_conv;
4316 }
4317
4318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
4319         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4320         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4321         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4322         LDKUnsignedChannelAnnouncement msg_conv;
4323         msg_conv.inner = (void*)(msg & (~1));
4324         msg_conv.is_owned = false;
4325         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
4326         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
4327         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
4328         return (uintptr_t)ret_conv;
4329 }
4330
4331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
4332         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4333         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4334         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4335         LDKChannelTransactionParameters channel_parameters_conv;
4336         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
4337         channel_parameters_conv.is_owned = false;
4338         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
4339         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
4340 }
4341
4342 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
4343         if (this_arg->set_pubkeys != NULL)
4344                 this_arg->set_pubkeys(this_arg);
4345         return this_arg->pubkeys;
4346 }
4347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
4348         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4349         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4350         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4351         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
4352         uintptr_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 typedef struct LDKSign_JCalls {
4364         atomic_size_t refcnt;
4365         JavaVM *vm;
4366         jweak o;
4367         LDKBaseSign_JCalls* BaseSign;
4368         jmethodID write_meth;
4369 } LDKSign_JCalls;
4370 static void LDKSign_JCalls_free(void* this_arg) {
4371         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4372         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4373                 JNIEnv *env;
4374                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4375                 if (get_jenv_res == JNI_EDETACHED) {
4376                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4377                 } else {
4378                         DO_ASSERT(get_jenv_res == JNI_OK);
4379                 }
4380                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4381                 if (get_jenv_res == JNI_EDETACHED) {
4382                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4383                 }
4384                 FREE(j_calls);
4385         }
4386 }
4387 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
4388         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4389         JNIEnv *env;
4390         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4391         if (get_jenv_res == JNI_EDETACHED) {
4392                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4393         } else {
4394                 DO_ASSERT(get_jenv_res == JNI_OK);
4395         }
4396         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4397         CHECK(obj != NULL);
4398         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
4399         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4400                 (*env)->ExceptionDescribe(env);
4401                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
4402         }
4403         LDKCVec_u8Z ret_ref;
4404         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4405         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4406         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4407         if (get_jenv_res == JNI_EDETACHED) {
4408                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4409         }
4410         return ret_ref;
4411 }
4412 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
4413         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
4414         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4415         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
4416 }
4417 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
4418         jclass c = (*env)->GetObjectClass(env, o);
4419         CHECK(c != NULL);
4420         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
4421         atomic_init(&calls->refcnt, 1);
4422         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4423         calls->o = (*env)->NewWeakGlobalRef(env, o);
4424         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
4425         CHECK(calls->write_meth != NULL);
4426
4427         LDKChannelPublicKeys pubkeys_conv;
4428         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4429         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4430         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4431
4432         LDKSign ret = {
4433                 .this_arg = (void*) calls,
4434                 .write = write_LDKSign_jcall,
4435                 .cloned = LDKSign_JCalls_cloned,
4436                 .free = LDKSign_JCalls_free,
4437                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
4438         };
4439         calls->BaseSign = ret.BaseSign.this_arg;
4440         return ret;
4441 }
4442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
4443         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
4444         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
4445         return (uint64_t)res_ptr;
4446 }
4447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
4448         LDKSign *inp = (LDKSign *)(arg & ~1);
4449         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
4450         DO_ASSERT((res_ptr & 1) == 0);
4451         return (int64_t)(res_ptr | 1);
4452 }
4453 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
4454         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4455         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4456         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
4457         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4458         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4459         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4460         CVec_u8Z_free(ret_var);
4461         return ret_arr;
4462 }
4463
4464 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4465 CHECK(owner->result_ok);
4466         return Sign_clone(&*owner->contents.result);
4467 }
4468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4469         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4470         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4471         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
4472         return (uintptr_t)ret_ret;
4473 }
4474
4475 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4476 CHECK(!owner->result_ok);
4477         return DecodeError_clone(&*owner->contents.err);
4478 }
4479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4480         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4481         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
4482         uintptr_t ret_ref = 0;
4483         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4484         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4486         ret_ref = (uintptr_t)ret_var.inner;
4487         if (ret_var.is_owned) {
4488                 ret_ref |= 1;
4489         }
4490         return ret_ref;
4491 }
4492
4493 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4494 CHECK(owner->result_ok);
4495         return *owner->contents.result;
4496 }
4497 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4498         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4499         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
4500         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
4501         return ret_arr;
4502 }
4503
4504 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4505 CHECK(!owner->result_ok);
4506         return *owner->contents.err;
4507 }
4508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4509         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4510         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
4511 }
4512
4513 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
4514         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
4515         for (size_t i = 0; i < ret.datalen; i++) {
4516                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
4517         }
4518         return ret;
4519 }
4520 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4521 CHECK(owner->result_ok);
4522         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
4523 }
4524 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4525         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4526         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
4527         jobjectArray ret_arr = NULL;
4528         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
4529         ;
4530         for (size_t i = 0; i < ret_var.datalen; i++) {
4531                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
4532                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
4533                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
4534                 CVec_u8Z_free(ret_conv_8_var);
4535                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
4536         }
4537         
4538         FREE(ret_var.data);
4539         return ret_arr;
4540 }
4541
4542 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4543 CHECK(!owner->result_ok);
4544         return *owner->contents.err;
4545 }
4546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4547         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4548         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
4549 }
4550
4551 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4552 CHECK(owner->result_ok);
4553         return InMemorySigner_clone(&*owner->contents.result);
4554 }
4555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4556         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4557         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
4558         uintptr_t ret_ref = 0;
4559         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4560         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4562         ret_ref = (uintptr_t)ret_var.inner;
4563         if (ret_var.is_owned) {
4564                 ret_ref |= 1;
4565         }
4566         return ret_ref;
4567 }
4568
4569 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4570 CHECK(!owner->result_ok);
4571         return DecodeError_clone(&*owner->contents.err);
4572 }
4573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4574         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4575         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
4576         uintptr_t ret_ref = 0;
4577         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4578         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4580         ret_ref = (uintptr_t)ret_var.inner;
4581         if (ret_var.is_owned) {
4582                 ret_ref |= 1;
4583         }
4584         return ret_ref;
4585 }
4586
4587 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
4588         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
4589         for (size_t i = 0; i < ret.datalen; i++) {
4590                 ret.data[i] = TxOut_clone(&orig->data[i]);
4591         }
4592         return ret;
4593 }
4594 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4595 CHECK(owner->result_ok);
4596         return *owner->contents.result;
4597 }
4598 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4599         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4600         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
4601         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4602         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4603         return ret_arr;
4604 }
4605
4606 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4607 CHECK(!owner->result_ok);
4608         return *owner->contents.err;
4609 }
4610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4611         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4612         CResult_TransactionNoneZ_get_err(owner_conv);
4613 }
4614
4615 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
4616         return ThirtyTwoBytes_clone(&owner->a);
4617 }
4618 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4619         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
4620         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4621         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
4622         return ret_arr;
4623 }
4624
4625 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
4626         return ChannelMonitor_clone(&owner->b);
4627 }
4628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4629         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
4630         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
4631         uintptr_t ret_ref = 0;
4632         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4633         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4635         ret_ref = (uintptr_t)ret_var.inner;
4636         if (ret_var.is_owned) {
4637                 ret_ref |= 1;
4638         }
4639         return ret_ref;
4640 }
4641
4642 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
4643         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
4644         for (size_t i = 0; i < ret.datalen; i++) {
4645                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
4646         }
4647         return ret;
4648 }
4649 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
4650 CHECK(owner->result_ok);
4651         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
4652 }
4653 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4654         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
4655         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
4656         int64_tArray ret_arr = NULL;
4657         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4658         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4659         for (size_t j = 0; j < ret_var.datalen; j++) {
4660                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
4661                 *ret_conv_35_conv = ret_var.data[j];
4662                 ret_arr_ptr[j] = ((uintptr_t)ret_conv_35_conv);
4663         }
4664         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4665         FREE(ret_var.data);
4666         return ret_arr;
4667 }
4668
4669 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
4670 CHECK(!owner->result_ok);
4671         return *owner->contents.err;
4672 }
4673 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4674         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
4675         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
4676         return ret_conv;
4677 }
4678
4679 static jclass LDKCOption_u16Z_Some_class = NULL;
4680 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
4681 static jclass LDKCOption_u16Z_None_class = NULL;
4682 static jmethodID LDKCOption_u16Z_None_meth = NULL;
4683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
4684         LDKCOption_u16Z_Some_class =
4685                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
4686         CHECK(LDKCOption_u16Z_Some_class != NULL);
4687         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
4688         CHECK(LDKCOption_u16Z_Some_meth != NULL);
4689         LDKCOption_u16Z_None_class =
4690                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
4691         CHECK(LDKCOption_u16Z_None_class != NULL);
4692         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
4693         CHECK(LDKCOption_u16Z_None_meth != NULL);
4694 }
4695 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4696         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4697         switch(obj->tag) {
4698                 case LDKCOption_u16Z_Some: {
4699                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
4700                 }
4701                 case LDKCOption_u16Z_None: {
4702                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
4703                 }
4704                 default: abort();
4705         }
4706 }
4707 static jclass LDKAPIError_APIMisuseError_class = NULL;
4708 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
4709 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
4710 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
4711 static jclass LDKAPIError_RouteError_class = NULL;
4712 static jmethodID LDKAPIError_RouteError_meth = NULL;
4713 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
4714 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
4715 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
4716 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
4717 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
4718 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
4719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
4720         LDKAPIError_APIMisuseError_class =
4721                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
4722         CHECK(LDKAPIError_APIMisuseError_class != NULL);
4723         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
4724         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
4725         LDKAPIError_FeeRateTooHigh_class =
4726                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
4727         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
4728         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
4729         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
4730         LDKAPIError_RouteError_class =
4731                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
4732         CHECK(LDKAPIError_RouteError_class != NULL);
4733         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
4734         CHECK(LDKAPIError_RouteError_meth != NULL);
4735         LDKAPIError_ChannelUnavailable_class =
4736                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
4737         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
4738         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
4739         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
4740         LDKAPIError_MonitorUpdateFailed_class =
4741                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed"));
4742         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
4743         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
4744         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
4745         LDKAPIError_IncompatibleShutdownScript_class =
4746                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
4747         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
4748         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
4749         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
4750 }
4751 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4752         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4753         switch(obj->tag) {
4754                 case LDKAPIError_APIMisuseError: {
4755                         LDKStr err_str = obj->api_misuse_error.err;
4756                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4757                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
4758                 }
4759                 case LDKAPIError_FeeRateTooHigh: {
4760                         LDKStr err_str = obj->fee_rate_too_high.err;
4761                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4762                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
4763                 }
4764                 case LDKAPIError_RouteError: {
4765                         LDKStr err_str = obj->route_error.err;
4766                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4767                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
4768                 }
4769                 case LDKAPIError_ChannelUnavailable: {
4770                         LDKStr err_str = obj->channel_unavailable.err;
4771                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4772                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
4773                 }
4774                 case LDKAPIError_MonitorUpdateFailed: {
4775                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
4776                 }
4777                 case LDKAPIError_IncompatibleShutdownScript: {
4778                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
4779                         uintptr_t script_ref = 0;
4780                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4781                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4782                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
4783                         script_ref = (uintptr_t)script_var.inner & ~1;
4784                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
4785                 }
4786                 default: abort();
4787         }
4788 }
4789 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4790 CHECK(owner->result_ok);
4791         return *owner->contents.result;
4792 }
4793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4794         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4795         CResult_NoneAPIErrorZ_get_ok(owner_conv);
4796 }
4797
4798 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4799 CHECK(!owner->result_ok);
4800         return APIError_clone(&*owner->contents.err);
4801 }
4802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4803         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4804         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4805         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
4806         uintptr_t ret_ref = (uintptr_t)ret_copy;
4807         return ret_ref;
4808 }
4809
4810 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
4811         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
4812         for (size_t i = 0; i < ret.datalen; i++) {
4813                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
4814         }
4815         return ret;
4816 }
4817 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
4818         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
4819         for (size_t i = 0; i < ret.datalen; i++) {
4820                 ret.data[i] = APIError_clone(&orig->data[i]);
4821         }
4822         return ret;
4823 }
4824 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4825 CHECK(owner->result_ok);
4826         return ThirtyTwoBytes_clone(&*owner->contents.result);
4827 }
4828 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4829         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4830         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4831         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
4832         return ret_arr;
4833 }
4834
4835 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4836 CHECK(!owner->result_ok);
4837         return APIError_clone(&*owner->contents.err);
4838 }
4839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4840         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4841         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4842         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
4843         uintptr_t ret_ref = (uintptr_t)ret_copy;
4844         return ret_ref;
4845 }
4846
4847 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
4848 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
4849 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
4850 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
4851 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
4852 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
4853 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
4854 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
4855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
4856         LDKPaymentSendFailure_ParameterError_class =
4857                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
4858         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
4859         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
4860         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
4861         LDKPaymentSendFailure_PathParameterError_class =
4862                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
4863         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
4864         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
4865         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
4866         LDKPaymentSendFailure_AllFailedRetrySafe_class =
4867                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
4868         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
4869         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
4870         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
4871         LDKPaymentSendFailure_PartialFailure_class =
4872                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
4873         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
4874         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
4875         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
4876 }
4877 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4878         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4879         switch(obj->tag) {
4880                 case LDKPaymentSendFailure_ParameterError: {
4881                         uintptr_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
4882                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
4883                 }
4884                 case LDKPaymentSendFailure_PathParameterError: {
4885                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
4886                         int64_tArray path_parameter_error_arr = NULL;
4887                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
4888                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
4889                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
4890                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4891                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
4892                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
4893                                 path_parameter_error_arr_ptr[w] = (uintptr_t)path_parameter_error_conv_22_conv;
4894                         }
4895                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
4896                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
4897                 }
4898                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
4899                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
4900                         int64_tArray all_failed_retry_safe_arr = NULL;
4901                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
4902                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
4903                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
4904                                 uintptr_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
4905                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
4906                         }
4907                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
4908                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
4909                 }
4910                 case LDKPaymentSendFailure_PartialFailure: {
4911                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
4912                         int64_tArray results_arr = NULL;
4913                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
4914                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
4915                         for (size_t w = 0; w < results_var.datalen; w++) {
4916                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4917                                 *results_conv_22_conv = results_var.data[w];
4918                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
4919                                 results_arr_ptr[w] = (uintptr_t)results_conv_22_conv;
4920                         }
4921                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
4922                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
4923                         uintptr_t failed_paths_retry_ref = 0;
4924                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
4925                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4926                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4927                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
4928                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
4929                         }
4930                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
4931                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
4932                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
4933                 }
4934                 default: abort();
4935         }
4936 }
4937 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4938 CHECK(owner->result_ok);
4939         return ThirtyTwoBytes_clone(&*owner->contents.result);
4940 }
4941 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4942         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
4943         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4944         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data);
4945         return ret_arr;
4946 }
4947
4948 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4949 CHECK(!owner->result_ok);
4950         return PaymentSendFailure_clone(&*owner->contents.err);
4951 }
4952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4953         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
4954         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4955         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
4956         uintptr_t ret_ref = (uintptr_t)ret_copy;
4957         return ret_ref;
4958 }
4959
4960 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4961 CHECK(owner->result_ok);
4962         return *owner->contents.result;
4963 }
4964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4965         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
4966         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
4967 }
4968
4969 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4970 CHECK(!owner->result_ok);
4971         return PaymentSendFailure_clone(&*owner->contents.err);
4972 }
4973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4974         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
4975         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4976         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
4977         uintptr_t ret_ref = (uintptr_t)ret_copy;
4978         return ret_ref;
4979 }
4980
4981 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4982         return ThirtyTwoBytes_clone(&owner->a);
4983 }
4984 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4985         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
4986         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4987         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
4988         return ret_arr;
4989 }
4990
4991 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4992         return ThirtyTwoBytes_clone(&owner->b);
4993 }
4994 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4995         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
4996         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4997         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
4998         return ret_arr;
4999 }
5000
5001 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5002 CHECK(owner->result_ok);
5003         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
5004 }
5005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5006         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
5007         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
5008         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
5009         return ((uintptr_t)ret_conv);
5010 }
5011
5012 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5013 CHECK(!owner->result_ok);
5014         return PaymentSendFailure_clone(&*owner->contents.err);
5015 }
5016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5017         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
5018         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5019         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
5020         uintptr_t ret_ref = (uintptr_t)ret_copy;
5021         return ret_ref;
5022 }
5023
5024 static jclass LDKNetAddress_IPv4_class = NULL;
5025 static jmethodID LDKNetAddress_IPv4_meth = NULL;
5026 static jclass LDKNetAddress_IPv6_class = NULL;
5027 static jmethodID LDKNetAddress_IPv6_meth = NULL;
5028 static jclass LDKNetAddress_OnionV2_class = NULL;
5029 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
5030 static jclass LDKNetAddress_OnionV3_class = NULL;
5031 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
5032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
5033         LDKNetAddress_IPv4_class =
5034                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
5035         CHECK(LDKNetAddress_IPv4_class != NULL);
5036         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
5037         CHECK(LDKNetAddress_IPv4_meth != NULL);
5038         LDKNetAddress_IPv6_class =
5039                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
5040         CHECK(LDKNetAddress_IPv6_class != NULL);
5041         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
5042         CHECK(LDKNetAddress_IPv6_meth != NULL);
5043         LDKNetAddress_OnionV2_class =
5044                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
5045         CHECK(LDKNetAddress_OnionV2_class != NULL);
5046         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
5047         CHECK(LDKNetAddress_OnionV2_meth != NULL);
5048         LDKNetAddress_OnionV3_class =
5049                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
5050         CHECK(LDKNetAddress_OnionV3_class != NULL);
5051         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
5052         CHECK(LDKNetAddress_OnionV3_meth != NULL);
5053 }
5054 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5055         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
5056         switch(obj->tag) {
5057                 case LDKNetAddress_IPv4: {
5058                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
5059                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
5060                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
5061                 }
5062                 case LDKNetAddress_IPv6: {
5063                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
5064                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
5065                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
5066                 }
5067                 case LDKNetAddress_OnionV2: {
5068                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
5069                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
5070                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
5071                 }
5072                 case LDKNetAddress_OnionV3: {
5073                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
5074                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
5075                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, obj->onion_v3.checksum, obj->onion_v3.version, obj->onion_v3.port);
5076                 }
5077                 default: abort();
5078         }
5079 }
5080 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
5081         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
5082         for (size_t i = 0; i < ret.datalen; i++) {
5083                 ret.data[i] = NetAddress_clone(&orig->data[i]);
5084         }
5085         return ret;
5086 }
5087 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
5088         return ThirtyTwoBytes_clone(&owner->a);
5089 }
5090 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5091         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
5092         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5093         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
5094         return ret_arr;
5095 }
5096
5097 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
5098         return ThirtyTwoBytes_clone(&owner->b);
5099 }
5100 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5101         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
5102         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5103         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
5104         return ret_arr;
5105 }
5106
5107 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5108 CHECK(owner->result_ok);
5109         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5110 }
5111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5112         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5113         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5114         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
5115         return ((uintptr_t)ret_conv);
5116 }
5117
5118 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5119 CHECK(!owner->result_ok);
5120         return *owner->contents.err;
5121 }
5122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5123         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5124         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
5125 }
5126
5127 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5128 CHECK(owner->result_ok);
5129         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5130 }
5131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5132         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5133         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5134         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
5135         return ((uintptr_t)ret_conv);
5136 }
5137
5138 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5139 CHECK(!owner->result_ok);
5140         return APIError_clone(&*owner->contents.err);
5141 }
5142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5143         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5144         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5145         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
5146         uintptr_t ret_ref = (uintptr_t)ret_copy;
5147         return ret_ref;
5148 }
5149
5150 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5151 CHECK(owner->result_ok);
5152         return ThirtyTwoBytes_clone(&*owner->contents.result);
5153 }
5154 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5155         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5156         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5157         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
5158         return ret_arr;
5159 }
5160
5161 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5162 CHECK(!owner->result_ok);
5163         return *owner->contents.err;
5164 }
5165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5166         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5167         CResult_PaymentSecretNoneZ_get_err(owner_conv);
5168 }
5169
5170 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5171 CHECK(owner->result_ok);
5172         return ThirtyTwoBytes_clone(&*owner->contents.result);
5173 }
5174 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5175         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
5176         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5177         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
5178         return ret_arr;
5179 }
5180
5181 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5182 CHECK(!owner->result_ok);
5183         return APIError_clone(&*owner->contents.err);
5184 }
5185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5186         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
5187         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5188         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
5189         uintptr_t ret_ref = (uintptr_t)ret_copy;
5190         return ret_ref;
5191 }
5192
5193 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5194 CHECK(owner->result_ok);
5195         return ThirtyTwoBytes_clone(&*owner->contents.result);
5196 }
5197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5198         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
5199         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5200         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
5201         return ret_arr;
5202 }
5203
5204 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5205 CHECK(!owner->result_ok);
5206         return APIError_clone(&*owner->contents.err);
5207 }
5208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5209         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
5210         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5211         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
5212         uintptr_t ret_ref = (uintptr_t)ret_copy;
5213         return ret_ref;
5214 }
5215
5216 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5217 CHECK(owner->result_ok);
5218         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
5219 }
5220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5221         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
5222         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
5223         uintptr_t ret_ref = 0;
5224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5227         ret_ref = (uintptr_t)ret_var.inner;
5228         if (ret_var.is_owned) {
5229                 ret_ref |= 1;
5230         }
5231         return ret_ref;
5232 }
5233
5234 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5235 CHECK(!owner->result_ok);
5236         return DecodeError_clone(&*owner->contents.err);
5237 }
5238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5239         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
5240         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
5241         uintptr_t ret_ref = 0;
5242         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5243         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5245         ret_ref = (uintptr_t)ret_var.inner;
5246         if (ret_var.is_owned) {
5247                 ret_ref |= 1;
5248         }
5249         return ret_ref;
5250 }
5251
5252 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5253 CHECK(owner->result_ok);
5254         return ChannelCounterparty_clone(&*owner->contents.result);
5255 }
5256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5257         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
5258         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
5259         uintptr_t ret_ref = 0;
5260         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5261         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5263         ret_ref = (uintptr_t)ret_var.inner;
5264         if (ret_var.is_owned) {
5265                 ret_ref |= 1;
5266         }
5267         return ret_ref;
5268 }
5269
5270 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5271 CHECK(!owner->result_ok);
5272         return DecodeError_clone(&*owner->contents.err);
5273 }
5274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5275         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
5276         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
5277         uintptr_t ret_ref = 0;
5278         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5279         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5281         ret_ref = (uintptr_t)ret_var.inner;
5282         if (ret_var.is_owned) {
5283                 ret_ref |= 1;
5284         }
5285         return ret_ref;
5286 }
5287
5288 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5289 CHECK(owner->result_ok);
5290         return ChannelDetails_clone(&*owner->contents.result);
5291 }
5292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5293         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5294         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
5295         uintptr_t ret_ref = 0;
5296         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5297         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5299         ret_ref = (uintptr_t)ret_var.inner;
5300         if (ret_var.is_owned) {
5301                 ret_ref |= 1;
5302         }
5303         return ret_ref;
5304 }
5305
5306 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5307 CHECK(!owner->result_ok);
5308         return DecodeError_clone(&*owner->contents.err);
5309 }
5310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5311         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5312         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
5313         uintptr_t ret_ref = 0;
5314         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5315         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5317         ret_ref = (uintptr_t)ret_var.inner;
5318         if (ret_var.is_owned) {
5319                 ret_ref |= 1;
5320         }
5321         return ret_ref;
5322 }
5323
5324 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5325 CHECK(owner->result_ok);
5326         return PhantomRouteHints_clone(&*owner->contents.result);
5327 }
5328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5329         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5330         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
5331         uintptr_t ret_ref = 0;
5332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5335         ret_ref = (uintptr_t)ret_var.inner;
5336         if (ret_var.is_owned) {
5337                 ret_ref |= 1;
5338         }
5339         return ret_ref;
5340 }
5341
5342 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5343 CHECK(!owner->result_ok);
5344         return DecodeError_clone(&*owner->contents.err);
5345 }
5346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5347         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5348         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
5349         uintptr_t ret_ref = 0;
5350         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5351         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5353         ret_ref = (uintptr_t)ret_var.inner;
5354         if (ret_var.is_owned) {
5355                 ret_ref |= 1;
5356         }
5357         return ret_ref;
5358 }
5359
5360 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
5361         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
5362         for (size_t i = 0; i < ret.datalen; i++) {
5363                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
5364         }
5365         return ret;
5366 }
5367 typedef struct LDKWatch_JCalls {
5368         atomic_size_t refcnt;
5369         JavaVM *vm;
5370         jweak o;
5371         jmethodID watch_channel_meth;
5372         jmethodID update_channel_meth;
5373         jmethodID release_pending_monitor_events_meth;
5374 } LDKWatch_JCalls;
5375 static void LDKWatch_JCalls_free(void* this_arg) {
5376         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5377         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5378                 JNIEnv *env;
5379                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5380                 if (get_jenv_res == JNI_EDETACHED) {
5381                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5382                 } else {
5383                         DO_ASSERT(get_jenv_res == JNI_OK);
5384                 }
5385                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5386                 if (get_jenv_res == JNI_EDETACHED) {
5387                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5388                 }
5389                 FREE(j_calls);
5390         }
5391 }
5392 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
5393         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5394         JNIEnv *env;
5395         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5396         if (get_jenv_res == JNI_EDETACHED) {
5397                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5398         } else {
5399                 DO_ASSERT(get_jenv_res == JNI_OK);
5400         }
5401         LDKOutPoint funding_txo_var = funding_txo;
5402         uintptr_t funding_txo_ref = 0;
5403         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5404         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5405         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5406         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5407         if (funding_txo_var.is_owned) {
5408                 funding_txo_ref |= 1;
5409         }
5410         LDKChannelMonitor monitor_var = monitor;
5411         uintptr_t monitor_ref = 0;
5412         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5413         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5414         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
5415         monitor_ref = (uintptr_t)monitor_var.inner;
5416         if (monitor_var.is_owned) {
5417                 monitor_ref |= 1;
5418         }
5419         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5420         CHECK(obj != NULL);
5421         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
5422         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5423                 (*env)->ExceptionDescribe(env);
5424                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
5425         }
5426         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5427         CHECK_ACCESS(ret_ptr);
5428         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5429         FREE((void*)ret);
5430         if (get_jenv_res == JNI_EDETACHED) {
5431                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5432         }
5433         return ret_conv;
5434 }
5435 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
5436         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5437         JNIEnv *env;
5438         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5439         if (get_jenv_res == JNI_EDETACHED) {
5440                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5441         } else {
5442                 DO_ASSERT(get_jenv_res == JNI_OK);
5443         }
5444         LDKOutPoint funding_txo_var = funding_txo;
5445         uintptr_t funding_txo_ref = 0;
5446         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5447         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5448         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5449         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5450         if (funding_txo_var.is_owned) {
5451                 funding_txo_ref |= 1;
5452         }
5453         LDKChannelMonitorUpdate update_var = update;
5454         uintptr_t update_ref = 0;
5455         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5456         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5457         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
5458         update_ref = (uintptr_t)update_var.inner;
5459         if (update_var.is_owned) {
5460                 update_ref |= 1;
5461         }
5462         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5463         CHECK(obj != NULL);
5464         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
5465         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5466                 (*env)->ExceptionDescribe(env);
5467                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
5468         }
5469         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5470         CHECK_ACCESS(ret_ptr);
5471         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5472         FREE((void*)ret);
5473         if (get_jenv_res == JNI_EDETACHED) {
5474                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5475         }
5476         return ret_conv;
5477 }
5478 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
5479         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5480         JNIEnv *env;
5481         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5482         if (get_jenv_res == JNI_EDETACHED) {
5483                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5484         } else {
5485                 DO_ASSERT(get_jenv_res == JNI_OK);
5486         }
5487         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5488         CHECK(obj != NULL);
5489         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
5490         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5491                 (*env)->ExceptionDescribe(env);
5492                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
5493         }
5494         LDKCVec_MonitorEventZ ret_constr;
5495         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
5496         if (ret_constr.datalen > 0)
5497                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
5498         else
5499                 ret_constr.data = NULL;
5500         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
5501         for (size_t o = 0; o < ret_constr.datalen; o++) {
5502                 int64_t ret_conv_14 = ret_vals[o];
5503                 void* ret_conv_14_ptr = (void*)(((uintptr_t)ret_conv_14) & ~1);
5504                 CHECK_ACCESS(ret_conv_14_ptr);
5505                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
5506                 FREE((void*)ret_conv_14);
5507                 ret_constr.data[o] = ret_conv_14_conv;
5508         }
5509         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
5510         if (get_jenv_res == JNI_EDETACHED) {
5511                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5512         }
5513         return ret_constr;
5514 }
5515 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
5516         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
5517         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5518 }
5519 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
5520         jclass c = (*env)->GetObjectClass(env, o);
5521         CHECK(c != NULL);
5522         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
5523         atomic_init(&calls->refcnt, 1);
5524         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5525         calls->o = (*env)->NewWeakGlobalRef(env, o);
5526         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
5527         CHECK(calls->watch_channel_meth != NULL);
5528         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
5529         CHECK(calls->update_channel_meth != NULL);
5530         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
5531         CHECK(calls->release_pending_monitor_events_meth != NULL);
5532
5533         LDKWatch ret = {
5534                 .this_arg = (void*) calls,
5535                 .watch_channel = watch_channel_LDKWatch_jcall,
5536                 .update_channel = update_channel_LDKWatch_jcall,
5537                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
5538                 .free = LDKWatch_JCalls_free,
5539         };
5540         return ret;
5541 }
5542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
5543         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
5544         *res_ptr = LDKWatch_init(env, clz, o);
5545         return (uint64_t)res_ptr;
5546 }
5547 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) {
5548         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5549         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5550         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5551         LDKOutPoint funding_txo_conv;
5552         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5553         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5554         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5555         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5556         LDKChannelMonitor monitor_conv;
5557         monitor_conv.inner = (void*)(monitor & (~1));
5558         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
5559         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
5560         monitor_conv = ChannelMonitor_clone(&monitor_conv);
5561         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5562         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
5563         return (uintptr_t)ret_conv;
5564 }
5565
5566 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) {
5567         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5568         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5569         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5570         LDKOutPoint funding_txo_conv;
5571         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5572         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5573         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5574         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5575         LDKChannelMonitorUpdate update_conv;
5576         update_conv.inner = (void*)(update & (~1));
5577         update_conv.is_owned = (update & 1) || (update == 0);
5578         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
5579         update_conv = ChannelMonitorUpdate_clone(&update_conv);
5580         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5581         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
5582         return (uintptr_t)ret_conv;
5583 }
5584
5585 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
5586         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5587         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5588         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5589         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
5590         int64_tArray ret_arr = NULL;
5591         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5592         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5593         for (size_t o = 0; o < ret_var.datalen; o++) {
5594                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
5595                 *ret_conv_14_copy = ret_var.data[o];
5596                 uintptr_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
5597                 ret_arr_ptr[o] = ret_conv_14_ref;
5598         }
5599         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5600         FREE(ret_var.data);
5601         return ret_arr;
5602 }
5603
5604 typedef struct LDKBroadcasterInterface_JCalls {
5605         atomic_size_t refcnt;
5606         JavaVM *vm;
5607         jweak o;
5608         jmethodID broadcast_transaction_meth;
5609 } LDKBroadcasterInterface_JCalls;
5610 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
5611         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5612         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5613                 JNIEnv *env;
5614                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5615                 if (get_jenv_res == JNI_EDETACHED) {
5616                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5617                 } else {
5618                         DO_ASSERT(get_jenv_res == JNI_OK);
5619                 }
5620                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5621                 if (get_jenv_res == JNI_EDETACHED) {
5622                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5623                 }
5624                 FREE(j_calls);
5625         }
5626 }
5627 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
5628         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5629         JNIEnv *env;
5630         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5631         if (get_jenv_res == JNI_EDETACHED) {
5632                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5633         } else {
5634                 DO_ASSERT(get_jenv_res == JNI_OK);
5635         }
5636         LDKTransaction tx_var = tx;
5637         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
5638         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
5639         Transaction_free(tx_var);
5640         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5641         CHECK(obj != NULL);
5642         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
5643         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5644                 (*env)->ExceptionDescribe(env);
5645                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
5646         }
5647         if (get_jenv_res == JNI_EDETACHED) {
5648                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5649         }
5650 }
5651 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
5652         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
5653         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5654 }
5655 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
5656         jclass c = (*env)->GetObjectClass(env, o);
5657         CHECK(c != NULL);
5658         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
5659         atomic_init(&calls->refcnt, 1);
5660         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5661         calls->o = (*env)->NewWeakGlobalRef(env, o);
5662         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
5663         CHECK(calls->broadcast_transaction_meth != NULL);
5664
5665         LDKBroadcasterInterface ret = {
5666                 .this_arg = (void*) calls,
5667                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
5668                 .free = LDKBroadcasterInterface_JCalls_free,
5669         };
5670         return ret;
5671 }
5672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
5673         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
5674         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
5675         return (uint64_t)res_ptr;
5676 }
5677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
5678         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5679         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5680         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
5681         LDKTransaction tx_ref;
5682         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
5683         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
5684         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
5685         tx_ref.data_is_owned = true;
5686         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
5687 }
5688
5689 typedef struct LDKKeysInterface_JCalls {
5690         atomic_size_t refcnt;
5691         JavaVM *vm;
5692         jweak o;
5693         jmethodID get_node_secret_meth;
5694         jmethodID get_destination_script_meth;
5695         jmethodID get_shutdown_scriptpubkey_meth;
5696         jmethodID get_channel_signer_meth;
5697         jmethodID get_secure_random_bytes_meth;
5698         jmethodID read_chan_signer_meth;
5699         jmethodID sign_invoice_meth;
5700         jmethodID get_inbound_payment_key_material_meth;
5701 } LDKKeysInterface_JCalls;
5702 static void LDKKeysInterface_JCalls_free(void* this_arg) {
5703         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5704         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5705                 JNIEnv *env;
5706                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5707                 if (get_jenv_res == JNI_EDETACHED) {
5708                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5709                 } else {
5710                         DO_ASSERT(get_jenv_res == JNI_OK);
5711                 }
5712                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5713                 if (get_jenv_res == JNI_EDETACHED) {
5714                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5715                 }
5716                 FREE(j_calls);
5717         }
5718 }
5719 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
5720         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5721         JNIEnv *env;
5722         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5723         if (get_jenv_res == JNI_EDETACHED) {
5724                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5725         } else {
5726                 DO_ASSERT(get_jenv_res == JNI_OK);
5727         }
5728         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
5729         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5730         CHECK(obj != NULL);
5731         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
5732         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5733                 (*env)->ExceptionDescribe(env);
5734                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
5735         }
5736         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5737         CHECK_ACCESS(ret_ptr);
5738         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
5739         FREE((void*)ret);
5740         if (get_jenv_res == JNI_EDETACHED) {
5741                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5742         }
5743         return ret_conv;
5744 }
5745 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
5746         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5747         JNIEnv *env;
5748         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5749         if (get_jenv_res == JNI_EDETACHED) {
5750                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5751         } else {
5752                 DO_ASSERT(get_jenv_res == JNI_OK);
5753         }
5754         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5755         CHECK(obj != NULL);
5756         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
5757         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5758                 (*env)->ExceptionDescribe(env);
5759                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
5760         }
5761         LDKCVec_u8Z ret_ref;
5762         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5763         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5764         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5765         if (get_jenv_res == JNI_EDETACHED) {
5766                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5767         }
5768         return ret_ref;
5769 }
5770 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
5771         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5772         JNIEnv *env;
5773         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5774         if (get_jenv_res == JNI_EDETACHED) {
5775                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5776         } else {
5777                 DO_ASSERT(get_jenv_res == JNI_OK);
5778         }
5779         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5780         CHECK(obj != NULL);
5781         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
5782         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5783                 (*env)->ExceptionDescribe(env);
5784                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
5785         }
5786         LDKShutdownScript ret_conv;
5787         ret_conv.inner = (void*)(ret & (~1));
5788         ret_conv.is_owned = (ret & 1) || (ret == 0);
5789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
5790         if (get_jenv_res == JNI_EDETACHED) {
5791                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5792         }
5793         return ret_conv;
5794 }
5795 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
5796         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5797         JNIEnv *env;
5798         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5799         if (get_jenv_res == JNI_EDETACHED) {
5800                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5801         } else {
5802                 DO_ASSERT(get_jenv_res == JNI_OK);
5803         }
5804         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5805         CHECK(obj != NULL);
5806         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
5807         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5808                 (*env)->ExceptionDescribe(env);
5809                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
5810         }
5811         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5812         CHECK_ACCESS(ret_ptr);
5813         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
5814         FREE((void*)ret);
5815         if (get_jenv_res == JNI_EDETACHED) {
5816                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5817         }
5818         return ret_conv;
5819 }
5820 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
5821         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5822         JNIEnv *env;
5823         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5824         if (get_jenv_res == JNI_EDETACHED) {
5825                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5826         } else {
5827                 DO_ASSERT(get_jenv_res == JNI_OK);
5828         }
5829         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5830         CHECK(obj != NULL);
5831         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
5832         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5833                 (*env)->ExceptionDescribe(env);
5834                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
5835         }
5836         LDKThirtyTwoBytes ret_ref;
5837         CHECK((*env)->GetArrayLength(env, ret) == 32);
5838         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5839         if (get_jenv_res == JNI_EDETACHED) {
5840                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5841         }
5842         return ret_ref;
5843 }
5844 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
5845         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5846         JNIEnv *env;
5847         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5848         if (get_jenv_res == JNI_EDETACHED) {
5849                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5850         } else {
5851                 DO_ASSERT(get_jenv_res == JNI_OK);
5852         }
5853         LDKu8slice reader_var = reader;
5854         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
5855         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
5856         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5857         CHECK(obj != NULL);
5858         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
5859         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5860                 (*env)->ExceptionDescribe(env);
5861                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
5862         }
5863         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5864         CHECK_ACCESS(ret_ptr);
5865         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
5866         FREE((void*)ret);
5867         if (get_jenv_res == JNI_EDETACHED) {
5868                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5869         }
5870         return ret_conv;
5871 }
5872 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
5873         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5874         JNIEnv *env;
5875         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5876         if (get_jenv_res == JNI_EDETACHED) {
5877                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5878         } else {
5879                 DO_ASSERT(get_jenv_res == JNI_OK);
5880         }
5881         LDKu8slice hrp_bytes_var = hrp_bytes;
5882         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
5883         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
5884         LDKCVec_u5Z invoice_data_var = invoice_data;
5885         jobjectArray invoice_data_arr = NULL;
5886         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
5887         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
5888         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
5889                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
5890                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
5891         }
5892         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
5893         FREE(invoice_data_var.data);
5894         jclass receipient_conv = LDKRecipient_to_java(env, receipient);
5895         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5896         CHECK(obj != NULL);
5897         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
5898         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5899                 (*env)->ExceptionDescribe(env);
5900                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
5901         }
5902         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5903         CHECK_ACCESS(ret_ptr);
5904         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
5905         FREE((void*)ret);
5906         if (get_jenv_res == JNI_EDETACHED) {
5907                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5908         }
5909         return ret_conv;
5910 }
5911 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
5912         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5913         JNIEnv *env;
5914         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5915         if (get_jenv_res == JNI_EDETACHED) {
5916                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5917         } else {
5918                 DO_ASSERT(get_jenv_res == JNI_OK);
5919         }
5920         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5921         CHECK(obj != NULL);
5922         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
5923         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5924                 (*env)->ExceptionDescribe(env);
5925                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
5926         }
5927         LDKThirtyTwoBytes ret_ref;
5928         CHECK((*env)->GetArrayLength(env, ret) == 32);
5929         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5930         if (get_jenv_res == JNI_EDETACHED) {
5931                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5932         }
5933         return ret_ref;
5934 }
5935 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
5936         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
5937         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5938 }
5939 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
5940         jclass c = (*env)->GetObjectClass(env, o);
5941         CHECK(c != NULL);
5942         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
5943         atomic_init(&calls->refcnt, 1);
5944         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5945         calls->o = (*env)->NewWeakGlobalRef(env, o);
5946         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
5947         CHECK(calls->get_node_secret_meth != NULL);
5948         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
5949         CHECK(calls->get_destination_script_meth != NULL);
5950         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
5951         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
5952         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
5953         CHECK(calls->get_channel_signer_meth != NULL);
5954         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
5955         CHECK(calls->get_secure_random_bytes_meth != NULL);
5956         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
5957         CHECK(calls->read_chan_signer_meth != NULL);
5958         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
5959         CHECK(calls->sign_invoice_meth != NULL);
5960         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
5961         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
5962
5963         LDKKeysInterface ret = {
5964                 .this_arg = (void*) calls,
5965                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
5966                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
5967                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
5968                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
5969                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
5970                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
5971                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
5972                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
5973                 .free = LDKKeysInterface_JCalls_free,
5974         };
5975         return ret;
5976 }
5977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
5978         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
5979         *res_ptr = LDKKeysInterface_init(env, clz, o);
5980         return (uint64_t)res_ptr;
5981 }
5982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
5983         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5984         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5985         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5986         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
5987         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
5988         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
5989         return (uintptr_t)ret_conv;
5990 }
5991
5992 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
5993         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5994         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5995         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5996         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
5997         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5998         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5999         CVec_u8Z_free(ret_var);
6000         return ret_arr;
6001 }
6002
6003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
6004         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6005         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6006         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6007         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
6008         uintptr_t ret_ref = 0;
6009         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6010         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6012         ret_ref = (uintptr_t)ret_var.inner;
6013         if (ret_var.is_owned) {
6014                 ret_ref |= 1;
6015         }
6016         return ret_ref;
6017 }
6018
6019 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) {
6020         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6021         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6022         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6023         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
6024         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
6025         return (uintptr_t)ret_ret;
6026 }
6027
6028 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
6029         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6030         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6031         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6032         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6033         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
6034         return ret_arr;
6035 }
6036
6037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
6038         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6039         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6040         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6041         LDKu8slice reader_ref;
6042         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
6043         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
6044         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
6045         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
6046         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
6047         return (uintptr_t)ret_conv;
6048 }
6049
6050 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) {
6051         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6052         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6053         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6054         LDKu8slice hrp_bytes_ref;
6055         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
6056         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
6057         LDKCVec_u5Z invoice_data_constr;
6058         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
6059         if (invoice_data_constr.datalen > 0)
6060                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
6061         else
6062                 invoice_data_constr.data = NULL;
6063         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
6064         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
6065                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
6066                 
6067                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
6068         }
6069         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
6070         LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
6071         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
6072         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
6073         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
6074         return (uintptr_t)ret_conv;
6075 }
6076
6077 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
6078         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6079         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6080         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6081         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6082         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
6083         return ret_arr;
6084 }
6085
6086 typedef struct LDKFeeEstimator_JCalls {
6087         atomic_size_t refcnt;
6088         JavaVM *vm;
6089         jweak o;
6090         jmethodID get_est_sat_per_1000_weight_meth;
6091 } LDKFeeEstimator_JCalls;
6092 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
6093         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6094         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6095                 JNIEnv *env;
6096                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6097                 if (get_jenv_res == JNI_EDETACHED) {
6098                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6099                 } else {
6100                         DO_ASSERT(get_jenv_res == JNI_OK);
6101                 }
6102                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6103                 if (get_jenv_res == JNI_EDETACHED) {
6104                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6105                 }
6106                 FREE(j_calls);
6107         }
6108 }
6109 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
6110         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6111         JNIEnv *env;
6112         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6113         if (get_jenv_res == JNI_EDETACHED) {
6114                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6115         } else {
6116                 DO_ASSERT(get_jenv_res == JNI_OK);
6117         }
6118         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
6119         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6120         CHECK(obj != NULL);
6121         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
6122         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6123                 (*env)->ExceptionDescribe(env);
6124                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
6125         }
6126         if (get_jenv_res == JNI_EDETACHED) {
6127                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6128         }
6129         return ret;
6130 }
6131 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
6132         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
6133         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6134 }
6135 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
6136         jclass c = (*env)->GetObjectClass(env, o);
6137         CHECK(c != NULL);
6138         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
6139         atomic_init(&calls->refcnt, 1);
6140         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6141         calls->o = (*env)->NewWeakGlobalRef(env, o);
6142         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
6143         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
6144
6145         LDKFeeEstimator ret = {
6146                 .this_arg = (void*) calls,
6147                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
6148                 .free = LDKFeeEstimator_JCalls_free,
6149         };
6150         return ret;
6151 }
6152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
6153         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
6154         *res_ptr = LDKFeeEstimator_init(env, clz, o);
6155         return (uint64_t)res_ptr;
6156 }
6157 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) {
6158         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6159         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6160         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
6161         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
6162         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
6163         return ret_val;
6164 }
6165
6166 typedef struct LDKLogger_JCalls {
6167         atomic_size_t refcnt;
6168         JavaVM *vm;
6169         jweak o;
6170         jmethodID log_meth;
6171 } LDKLogger_JCalls;
6172 static void LDKLogger_JCalls_free(void* this_arg) {
6173         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
6174         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6175                 JNIEnv *env;
6176                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6177                 if (get_jenv_res == JNI_EDETACHED) {
6178                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6179                 } else {
6180                         DO_ASSERT(get_jenv_res == JNI_OK);
6181                 }
6182                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6183                 if (get_jenv_res == JNI_EDETACHED) {
6184                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6185                 }
6186                 FREE(j_calls);
6187         }
6188 }
6189 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
6190         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
6191         JNIEnv *env;
6192         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6193         if (get_jenv_res == JNI_EDETACHED) {
6194                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6195         } else {
6196                 DO_ASSERT(get_jenv_res == JNI_OK);
6197         }
6198         LDKRecord record_var = *record;
6199         uintptr_t record_ref = 0;
6200         record_var = Record_clone(record);
6201         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6202         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6203         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
6204         record_ref = (uintptr_t)record_var.inner;
6205         if (record_var.is_owned) {
6206                 record_ref |= 1;
6207         }
6208         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6209         CHECK(obj != NULL);
6210         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
6211         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6212                 (*env)->ExceptionDescribe(env);
6213                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
6214         }
6215         if (get_jenv_res == JNI_EDETACHED) {
6216                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6217         }
6218 }
6219 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
6220         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
6221         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6222 }
6223 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
6224         jclass c = (*env)->GetObjectClass(env, o);
6225         CHECK(c != NULL);
6226         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
6227         atomic_init(&calls->refcnt, 1);
6228         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6229         calls->o = (*env)->NewWeakGlobalRef(env, o);
6230         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
6231         CHECK(calls->log_meth != NULL);
6232
6233         LDKLogger ret = {
6234                 .this_arg = (void*) calls,
6235                 .log = log_LDKLogger_jcall,
6236                 .free = LDKLogger_JCalls_free,
6237         };
6238         return ret;
6239 }
6240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
6241         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
6242         *res_ptr = LDKLogger_init(env, clz, o);
6243         return (uint64_t)res_ptr;
6244 }
6245 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6246         return ThirtyTwoBytes_clone(&owner->a);
6247 }
6248 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6249         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6250         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6251         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
6252         return ret_arr;
6253 }
6254
6255 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6256         return &owner->b;
6257 }
6258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6259         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6260         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
6261         uintptr_t ret_ref = 0;
6262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6265         ret_ref = (uintptr_t)ret_var.inner & ~1;
6266         return ret_ref;
6267 }
6268
6269 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6270 CHECK(owner->result_ok);
6271         return &*owner->contents.result;
6272 }
6273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6274         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
6275         uintptr_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
6276         return ret_ret;
6277 }
6278
6279 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6280 CHECK(!owner->result_ok);
6281         return DecodeError_clone(&*owner->contents.err);
6282 }
6283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6284         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
6285         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
6286         uintptr_t ret_ref = 0;
6287         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6288         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6290         ret_ref = (uintptr_t)ret_var.inner;
6291         if (ret_var.is_owned) {
6292                 ret_ref |= 1;
6293         }
6294         return ret_ref;
6295 }
6296
6297 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
6298 CHECK(owner->result_ok);
6299         return ChannelConfig_clone(&*owner->contents.result);
6300 }
6301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6302         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
6303         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
6304         uintptr_t ret_ref = 0;
6305         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6306         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6307         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6308         ret_ref = (uintptr_t)ret_var.inner;
6309         if (ret_var.is_owned) {
6310                 ret_ref |= 1;
6311         }
6312         return ret_ref;
6313 }
6314
6315 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
6316 CHECK(!owner->result_ok);
6317         return DecodeError_clone(&*owner->contents.err);
6318 }
6319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6320         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
6321         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
6322         uintptr_t ret_ref = 0;
6323         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6324         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6325         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6326         ret_ref = (uintptr_t)ret_var.inner;
6327         if (ret_var.is_owned) {
6328                 ret_ref |= 1;
6329         }
6330         return ret_ref;
6331 }
6332
6333 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
6334 CHECK(owner->result_ok);
6335         return OutPoint_clone(&*owner->contents.result);
6336 }
6337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6338         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
6339         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
6340         uintptr_t ret_ref = 0;
6341         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6342         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6344         ret_ref = (uintptr_t)ret_var.inner;
6345         if (ret_var.is_owned) {
6346                 ret_ref |= 1;
6347         }
6348         return ret_ref;
6349 }
6350
6351 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
6352 CHECK(!owner->result_ok);
6353         return DecodeError_clone(&*owner->contents.err);
6354 }
6355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6356         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
6357         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
6358         uintptr_t ret_ref = 0;
6359         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6360         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6362         ret_ref = (uintptr_t)ret_var.inner;
6363         if (ret_var.is_owned) {
6364                 ret_ref |= 1;
6365         }
6366         return ret_ref;
6367 }
6368
6369 typedef struct LDKType_JCalls {
6370         atomic_size_t refcnt;
6371         JavaVM *vm;
6372         jweak o;
6373         jmethodID type_id_meth;
6374         jmethodID debug_str_meth;
6375         jmethodID write_meth;
6376 } LDKType_JCalls;
6377 static void LDKType_JCalls_free(void* this_arg) {
6378         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6379         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6380                 JNIEnv *env;
6381                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6382                 if (get_jenv_res == JNI_EDETACHED) {
6383                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6384                 } else {
6385                         DO_ASSERT(get_jenv_res == JNI_OK);
6386                 }
6387                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6388                 if (get_jenv_res == JNI_EDETACHED) {
6389                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6390                 }
6391                 FREE(j_calls);
6392         }
6393 }
6394 uint16_t type_id_LDKType_jcall(const void* this_arg) {
6395         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6396         JNIEnv *env;
6397         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6398         if (get_jenv_res == JNI_EDETACHED) {
6399                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6400         } else {
6401                 DO_ASSERT(get_jenv_res == JNI_OK);
6402         }
6403         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6404         CHECK(obj != NULL);
6405         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
6406         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6407                 (*env)->ExceptionDescribe(env);
6408                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
6409         }
6410         if (get_jenv_res == JNI_EDETACHED) {
6411                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6412         }
6413         return ret;
6414 }
6415 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
6416         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6417         JNIEnv *env;
6418         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6419         if (get_jenv_res == JNI_EDETACHED) {
6420                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6421         } else {
6422                 DO_ASSERT(get_jenv_res == JNI_OK);
6423         }
6424         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6425         CHECK(obj != NULL);
6426         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
6427         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6428                 (*env)->ExceptionDescribe(env);
6429                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
6430         }
6431         LDKStr ret_conv = java_to_owned_str(env, ret);
6432         if (get_jenv_res == JNI_EDETACHED) {
6433                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6434         }
6435         return ret_conv;
6436 }
6437 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
6438         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6439         JNIEnv *env;
6440         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6441         if (get_jenv_res == JNI_EDETACHED) {
6442                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6443         } else {
6444                 DO_ASSERT(get_jenv_res == JNI_OK);
6445         }
6446         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6447         CHECK(obj != NULL);
6448         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
6449         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6450                 (*env)->ExceptionDescribe(env);
6451                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
6452         }
6453         LDKCVec_u8Z ret_ref;
6454         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6455         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6456         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6457         if (get_jenv_res == JNI_EDETACHED) {
6458                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6459         }
6460         return ret_ref;
6461 }
6462 static void LDKType_JCalls_cloned(LDKType* new_obj) {
6463         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
6464         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6465 }
6466 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
6467         jclass c = (*env)->GetObjectClass(env, o);
6468         CHECK(c != NULL);
6469         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
6470         atomic_init(&calls->refcnt, 1);
6471         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6472         calls->o = (*env)->NewWeakGlobalRef(env, o);
6473         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
6474         CHECK(calls->type_id_meth != NULL);
6475         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
6476         CHECK(calls->debug_str_meth != NULL);
6477         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
6478         CHECK(calls->write_meth != NULL);
6479
6480         LDKType ret = {
6481                 .this_arg = (void*) calls,
6482                 .type_id = type_id_LDKType_jcall,
6483                 .debug_str = debug_str_LDKType_jcall,
6484                 .write = write_LDKType_jcall,
6485                 .cloned = LDKType_JCalls_cloned,
6486                 .free = LDKType_JCalls_free,
6487         };
6488         return ret;
6489 }
6490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
6491         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
6492         *res_ptr = LDKType_init(env, clz, o);
6493         return (uint64_t)res_ptr;
6494 }
6495 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
6496         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6497         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6498         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6499         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
6500         return ret_val;
6501 }
6502
6503 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
6504         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6505         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6506         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6507         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
6508         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
6509         Str_free(ret_str);
6510         return ret_conv;
6511 }
6512
6513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
6514         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6515         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6516         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6517         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
6518         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6519         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6520         CVec_u8Z_free(ret_var);
6521         return ret_arr;
6522 }
6523
6524 static jclass LDKCOption_TypeZ_Some_class = NULL;
6525 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
6526 static jclass LDKCOption_TypeZ_None_class = NULL;
6527 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
6528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
6529         LDKCOption_TypeZ_Some_class =
6530                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
6531         CHECK(LDKCOption_TypeZ_Some_class != NULL);
6532         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
6533         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
6534         LDKCOption_TypeZ_None_class =
6535                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
6536         CHECK(LDKCOption_TypeZ_None_class != NULL);
6537         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
6538         CHECK(LDKCOption_TypeZ_None_meth != NULL);
6539 }
6540 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6541         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
6542         switch(obj->tag) {
6543                 case LDKCOption_TypeZ_Some: {
6544                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
6545                         *some_ret = Type_clone(&obj->some);
6546                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (uintptr_t)some_ret);
6547                 }
6548                 case LDKCOption_TypeZ_None: {
6549                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
6550                 }
6551                 default: abort();
6552         }
6553 }
6554 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
6555 CHECK(owner->result_ok);
6556         return COption_TypeZ_clone(&*owner->contents.result);
6557 }
6558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6559         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
6560         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
6561         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
6562         uintptr_t ret_ref = (uintptr_t)ret_copy;
6563         return ret_ref;
6564 }
6565
6566 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
6567 CHECK(!owner->result_ok);
6568         return DecodeError_clone(&*owner->contents.err);
6569 }
6570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6571         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
6572         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
6573         uintptr_t ret_ref = 0;
6574         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6575         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6577         ret_ref = (uintptr_t)ret_var.inner;
6578         if (ret_var.is_owned) {
6579                 ret_ref |= 1;
6580         }
6581         return ret_ref;
6582 }
6583
6584 static jclass LDKPaymentError_Invoice_class = NULL;
6585 static jmethodID LDKPaymentError_Invoice_meth = NULL;
6586 static jclass LDKPaymentError_Routing_class = NULL;
6587 static jmethodID LDKPaymentError_Routing_meth = NULL;
6588 static jclass LDKPaymentError_Sending_class = NULL;
6589 static jmethodID LDKPaymentError_Sending_meth = NULL;
6590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
6591         LDKPaymentError_Invoice_class =
6592                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
6593         CHECK(LDKPaymentError_Invoice_class != NULL);
6594         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
6595         CHECK(LDKPaymentError_Invoice_meth != NULL);
6596         LDKPaymentError_Routing_class =
6597                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
6598         CHECK(LDKPaymentError_Routing_class != NULL);
6599         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
6600         CHECK(LDKPaymentError_Routing_meth != NULL);
6601         LDKPaymentError_Sending_class =
6602                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
6603         CHECK(LDKPaymentError_Sending_class != NULL);
6604         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
6605         CHECK(LDKPaymentError_Sending_meth != NULL);
6606 }
6607 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6608         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6609         switch(obj->tag) {
6610                 case LDKPaymentError_Invoice: {
6611                         LDKStr invoice_str = obj->invoice;
6612                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
6613                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
6614                 }
6615                 case LDKPaymentError_Routing: {
6616                         LDKLightningError routing_var = obj->routing;
6617                         uintptr_t routing_ref = 0;
6618                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6619                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6620                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
6621                         routing_ref = (uintptr_t)routing_var.inner & ~1;
6622                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
6623                 }
6624                 case LDKPaymentError_Sending: {
6625                         uintptr_t sending_ref = ((uintptr_t)&obj->sending) | 1;
6626                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
6627                 }
6628                 default: abort();
6629         }
6630 }
6631 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6632 CHECK(owner->result_ok);
6633         return ThirtyTwoBytes_clone(&*owner->contents.result);
6634 }
6635 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6636         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6637         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6638         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
6639         return ret_arr;
6640 }
6641
6642 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6643 CHECK(!owner->result_ok);
6644         return PaymentError_clone(&*owner->contents.err);
6645 }
6646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6647         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6648         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
6649         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
6650         uintptr_t ret_ref = (uintptr_t)ret_copy;
6651         return ret_ref;
6652 }
6653
6654 static inline enum LDKSiPrefix CResult_SiPrefixNoneZ_get_ok(LDKCResult_SiPrefixNoneZ *NONNULL_PTR owner){
6655 CHECK(owner->result_ok);
6656         return SiPrefix_clone(&*owner->contents.result);
6657 }
6658 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6659         LDKCResult_SiPrefixNoneZ* owner_conv = (LDKCResult_SiPrefixNoneZ*)(owner & ~1);
6660         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixNoneZ_get_ok(owner_conv));
6661         return ret_conv;
6662 }
6663
6664 static inline void CResult_SiPrefixNoneZ_get_err(LDKCResult_SiPrefixNoneZ *NONNULL_PTR owner){
6665 CHECK(!owner->result_ok);
6666         return *owner->contents.err;
6667 }
6668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6669         LDKCResult_SiPrefixNoneZ* owner_conv = (LDKCResult_SiPrefixNoneZ*)(owner & ~1);
6670         CResult_SiPrefixNoneZ_get_err(owner_conv);
6671 }
6672
6673 static inline struct LDKInvoice CResult_InvoiceNoneZ_get_ok(LDKCResult_InvoiceNoneZ *NONNULL_PTR owner){
6674 CHECK(owner->result_ok);
6675         return Invoice_clone(&*owner->contents.result);
6676 }
6677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6678         LDKCResult_InvoiceNoneZ* owner_conv = (LDKCResult_InvoiceNoneZ*)(owner & ~1);
6679         LDKInvoice ret_var = CResult_InvoiceNoneZ_get_ok(owner_conv);
6680         uintptr_t ret_ref = 0;
6681         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6682         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6684         ret_ref = (uintptr_t)ret_var.inner;
6685         if (ret_var.is_owned) {
6686                 ret_ref |= 1;
6687         }
6688         return ret_ref;
6689 }
6690
6691 static inline void CResult_InvoiceNoneZ_get_err(LDKCResult_InvoiceNoneZ *NONNULL_PTR owner){
6692 CHECK(!owner->result_ok);
6693         return *owner->contents.err;
6694 }
6695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6696         LDKCResult_InvoiceNoneZ* owner_conv = (LDKCResult_InvoiceNoneZ*)(owner & ~1);
6697         CResult_InvoiceNoneZ_get_err(owner_conv);
6698 }
6699
6700 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceNoneZ_get_ok(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR owner){
6701 CHECK(owner->result_ok);
6702         return SignedRawInvoice_clone(&*owner->contents.result);
6703 }
6704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6705         LDKCResult_SignedRawInvoiceNoneZ* owner_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(owner & ~1);
6706         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceNoneZ_get_ok(owner_conv);
6707         uintptr_t ret_ref = 0;
6708         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6709         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6711         ret_ref = (uintptr_t)ret_var.inner;
6712         if (ret_var.is_owned) {
6713                 ret_ref |= 1;
6714         }
6715         return ret_ref;
6716 }
6717
6718 static inline void CResult_SignedRawInvoiceNoneZ_get_err(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR owner){
6719 CHECK(!owner->result_ok);
6720         return *owner->contents.err;
6721 }
6722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6723         LDKCResult_SignedRawInvoiceNoneZ* owner_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(owner & ~1);
6724         CResult_SignedRawInvoiceNoneZ_get_err(owner_conv);
6725 }
6726
6727 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6728         return RawInvoice_clone(&owner->a);
6729 }
6730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6731         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6732         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
6733         uintptr_t ret_ref = 0;
6734         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6735         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6737         ret_ref = (uintptr_t)ret_var.inner;
6738         if (ret_var.is_owned) {
6739                 ret_ref |= 1;
6740         }
6741         return ret_ref;
6742 }
6743
6744 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6745         return ThirtyTwoBytes_clone(&owner->b);
6746 }
6747 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6748         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6749         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6750         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
6751         return ret_arr;
6752 }
6753
6754 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6755         return InvoiceSignature_clone(&owner->c);
6756 }
6757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
6758         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6759         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
6760         uintptr_t ret_ref = 0;
6761         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6762         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6764         ret_ref = (uintptr_t)ret_var.inner;
6765         if (ret_var.is_owned) {
6766                 ret_ref |= 1;
6767         }
6768         return ret_ref;
6769 }
6770
6771 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
6772 CHECK(owner->result_ok);
6773         return PayeePubKey_clone(&*owner->contents.result);
6774 }
6775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6776         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
6777         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
6778         uintptr_t ret_ref = 0;
6779         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6780         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6781         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6782         ret_ref = (uintptr_t)ret_var.inner;
6783         if (ret_var.is_owned) {
6784                 ret_ref |= 1;
6785         }
6786         return ret_ref;
6787 }
6788
6789 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
6790 CHECK(!owner->result_ok);
6791         return *owner->contents.err;
6792 }
6793 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6794         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
6795         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
6796         return ret_conv;
6797 }
6798
6799 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
6800         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
6801         for (size_t i = 0; i < ret.datalen; i++) {
6802                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
6803         }
6804         return ret;
6805 }
6806 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6807 CHECK(owner->result_ok);
6808         return PositiveTimestamp_clone(&*owner->contents.result);
6809 }
6810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6811         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6812         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
6813         uintptr_t ret_ref = 0;
6814         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6815         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6817         ret_ref = (uintptr_t)ret_var.inner;
6818         if (ret_var.is_owned) {
6819                 ret_ref |= 1;
6820         }
6821         return ret_ref;
6822 }
6823
6824 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6825 CHECK(!owner->result_ok);
6826         return CreationError_clone(&*owner->contents.err);
6827 }
6828 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6829         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6830         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
6831         return ret_conv;
6832 }
6833
6834 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6835 CHECK(owner->result_ok);
6836         return *owner->contents.result;
6837 }
6838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6839         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6840         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
6841 }
6842
6843 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6844 CHECK(!owner->result_ok);
6845         return SemanticError_clone(&*owner->contents.err);
6846 }
6847 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6848         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6849         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
6850         return ret_conv;
6851 }
6852
6853 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6854 CHECK(owner->result_ok);
6855         return Invoice_clone(&*owner->contents.result);
6856 }
6857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6858         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6859         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
6860         uintptr_t ret_ref = 0;
6861         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6862         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6864         ret_ref = (uintptr_t)ret_var.inner;
6865         if (ret_var.is_owned) {
6866                 ret_ref |= 1;
6867         }
6868         return ret_ref;
6869 }
6870
6871 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6872 CHECK(!owner->result_ok);
6873         return SemanticError_clone(&*owner->contents.err);
6874 }
6875 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6876         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6877         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
6878         return ret_conv;
6879 }
6880
6881 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6882 CHECK(owner->result_ok);
6883         return Description_clone(&*owner->contents.result);
6884 }
6885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6886         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6887         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
6888         uintptr_t ret_ref = 0;
6889         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6890         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6892         ret_ref = (uintptr_t)ret_var.inner;
6893         if (ret_var.is_owned) {
6894                 ret_ref |= 1;
6895         }
6896         return ret_ref;
6897 }
6898
6899 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6900 CHECK(!owner->result_ok);
6901         return CreationError_clone(&*owner->contents.err);
6902 }
6903 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6904         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6905         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
6906         return ret_conv;
6907 }
6908
6909 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6910 CHECK(owner->result_ok);
6911         return PrivateRoute_clone(&*owner->contents.result);
6912 }
6913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6914         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
6915         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
6916         uintptr_t ret_ref = 0;
6917         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6918         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6920         ret_ref = (uintptr_t)ret_var.inner;
6921         if (ret_var.is_owned) {
6922                 ret_ref |= 1;
6923         }
6924         return ret_ref;
6925 }
6926
6927 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6928 CHECK(!owner->result_ok);
6929         return CreationError_clone(&*owner->contents.err);
6930 }
6931 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6932         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
6933         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
6934         return ret_conv;
6935 }
6936
6937 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6938 CHECK(owner->result_ok);
6939         return *owner->contents.result;
6940 }
6941 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6942         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
6943         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
6944         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
6945         return ret_conv;
6946 }
6947
6948 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6949 CHECK(!owner->result_ok);
6950         return *owner->contents.err;
6951 }
6952 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6953         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
6954         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
6955         return ret_conv;
6956 }
6957
6958 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6959 CHECK(owner->result_ok);
6960         return ChannelMonitorUpdate_clone(&*owner->contents.result);
6961 }
6962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6963         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
6964         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
6965         uintptr_t ret_ref = 0;
6966         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6967         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6969         ret_ref = (uintptr_t)ret_var.inner;
6970         if (ret_var.is_owned) {
6971                 ret_ref |= 1;
6972         }
6973         return ret_ref;
6974 }
6975
6976 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6977 CHECK(!owner->result_ok);
6978         return DecodeError_clone(&*owner->contents.err);
6979 }
6980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6981         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
6982         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
6983         uintptr_t ret_ref = 0;
6984         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6985         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6987         ret_ref = (uintptr_t)ret_var.inner;
6988         if (ret_var.is_owned) {
6989                 ret_ref |= 1;
6990         }
6991         return ret_ref;
6992 }
6993
6994 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
6995 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
6996 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
6997 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
6998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
6999         LDKCOption_MonitorEventZ_Some_class =
7000                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
7001         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
7002         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
7003         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
7004         LDKCOption_MonitorEventZ_None_class =
7005                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
7006         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
7007         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
7008         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
7009 }
7010 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7011         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
7012         switch(obj->tag) {
7013                 case LDKCOption_MonitorEventZ_Some: {
7014                         uintptr_t some_ref = ((uintptr_t)&obj->some) | 1;
7015                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
7016                 }
7017                 case LDKCOption_MonitorEventZ_None: {
7018                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
7019                 }
7020                 default: abort();
7021         }
7022 }
7023 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
7024 CHECK(owner->result_ok);
7025         return COption_MonitorEventZ_clone(&*owner->contents.result);
7026 }
7027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7028         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
7029         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
7030         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
7031         uintptr_t ret_ref = (uintptr_t)ret_copy;
7032         return ret_ref;
7033 }
7034
7035 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
7036 CHECK(!owner->result_ok);
7037         return DecodeError_clone(&*owner->contents.err);
7038 }
7039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7040         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
7041         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
7042         uintptr_t ret_ref = 0;
7043         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7044         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7046         ret_ref = (uintptr_t)ret_var.inner;
7047         if (ret_var.is_owned) {
7048                 ret_ref |= 1;
7049         }
7050         return ret_ref;
7051 }
7052
7053 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
7054 CHECK(owner->result_ok);
7055         return HTLCUpdate_clone(&*owner->contents.result);
7056 }
7057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7058         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
7059         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
7060         uintptr_t ret_ref = 0;
7061         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7062         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7064         ret_ref = (uintptr_t)ret_var.inner;
7065         if (ret_var.is_owned) {
7066                 ret_ref |= 1;
7067         }
7068         return ret_ref;
7069 }
7070
7071 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
7072 CHECK(!owner->result_ok);
7073         return DecodeError_clone(&*owner->contents.err);
7074 }
7075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7076         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
7077         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
7078         uintptr_t ret_ref = 0;
7079         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7080         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7082         ret_ref = (uintptr_t)ret_var.inner;
7083         if (ret_var.is_owned) {
7084                 ret_ref |= 1;
7085         }
7086         return ret_ref;
7087 }
7088
7089 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
7090         return OutPoint_clone(&owner->a);
7091 }
7092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7093         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
7094         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
7095         uintptr_t ret_ref = 0;
7096         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7097         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7099         ret_ref = (uintptr_t)ret_var.inner;
7100         if (ret_var.is_owned) {
7101                 ret_ref |= 1;
7102         }
7103         return ret_ref;
7104 }
7105
7106 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
7107         return CVec_u8Z_clone(&owner->b);
7108 }
7109 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7110         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
7111         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
7112         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7113         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7114         CVec_u8Z_free(ret_var);
7115         return ret_arr;
7116 }
7117
7118 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
7119         return owner->a;
7120 }
7121 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7122         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
7123         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(owner_conv);
7124         return ret_val;
7125 }
7126
7127 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
7128         return CVec_u8Z_clone(&owner->b);
7129 }
7130 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7131         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
7132         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
7133         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7134         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7135         CVec_u8Z_free(ret_var);
7136         return ret_arr;
7137 }
7138
7139 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
7140         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
7141         for (size_t i = 0; i < ret.datalen; i++) {
7142                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
7143         }
7144         return ret;
7145 }
7146 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
7147         return ThirtyTwoBytes_clone(&owner->a);
7148 }
7149 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7150         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
7151         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7152         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
7153         return ret_arr;
7154 }
7155
7156 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
7157         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
7158 }
7159 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7160         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
7161         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
7162         int64_tArray ret_arr = NULL;
7163         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7164         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7165         for (size_t v = 0; v < ret_var.datalen; v++) {
7166                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
7167                 *ret_conv_21_conv = ret_var.data[v];
7168                 ret_arr_ptr[v] = ((uintptr_t)ret_conv_21_conv);
7169         }
7170         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7171         FREE(ret_var.data);
7172         return ret_arr;
7173 }
7174
7175 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
7176         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 };
7177         for (size_t i = 0; i < ret.datalen; i++) {
7178                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
7179         }
7180         return ret;
7181 }
7182 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
7183         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
7184         for (size_t i = 0; i < ret.datalen; i++) {
7185                 ret.data[i] = Event_clone(&orig->data[i]);
7186         }
7187         return ret;
7188 }
7189 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
7190         return owner->a;
7191 }
7192 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7193         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
7194         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(owner_conv);
7195         return ret_val;
7196 }
7197
7198 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
7199         return TxOut_clone(&owner->b);
7200 }
7201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7202         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
7203         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
7204         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
7205         return (uintptr_t)ret_ref;
7206 }
7207
7208 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
7209         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
7210         for (size_t i = 0; i < ret.datalen; i++) {
7211                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
7212         }
7213         return ret;
7214 }
7215 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
7216         return ThirtyTwoBytes_clone(&owner->a);
7217 }
7218 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7219         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
7220         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7221         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
7222         return ret_arr;
7223 }
7224
7225 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
7226         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
7227 }
7228 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7229         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
7230         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
7231         int64_tArray ret_arr = NULL;
7232         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7233         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7234         for (size_t u = 0; u < ret_var.datalen; u++) {
7235                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7236                 *ret_conv_20_conv = ret_var.data[u];
7237                 ret_arr_ptr[u] = ((uintptr_t)ret_conv_20_conv);
7238         }
7239         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7240         FREE(ret_var.data);
7241         return ret_arr;
7242 }
7243
7244 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
7245         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 };
7246         for (size_t i = 0; i < ret.datalen; i++) {
7247                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
7248         }
7249         return ret;
7250 }
7251 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
7252 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
7253 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
7254 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
7255 static jclass LDKBalance_ContentiousClaimable_class = NULL;
7256 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
7257 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
7258 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
7259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
7260         LDKBalance_ClaimableOnChannelClose_class =
7261                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
7262         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
7263         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
7264         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
7265         LDKBalance_ClaimableAwaitingConfirmations_class =
7266                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
7267         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
7268         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
7269         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
7270         LDKBalance_ContentiousClaimable_class =
7271                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
7272         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
7273         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
7274         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
7275         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
7276                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout"));
7277         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
7278         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
7279         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
7280 }
7281 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7282         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
7283         switch(obj->tag) {
7284                 case LDKBalance_ClaimableOnChannelClose: {
7285                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, obj->claimable_on_channel_close.claimable_amount_satoshis);
7286                 }
7287                 case LDKBalance_ClaimableAwaitingConfirmations: {
7288                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, obj->claimable_awaiting_confirmations.claimable_amount_satoshis, obj->claimable_awaiting_confirmations.confirmation_height);
7289                 }
7290                 case LDKBalance_ContentiousClaimable: {
7291                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, obj->contentious_claimable.claimable_amount_satoshis, obj->contentious_claimable.timeout_height);
7292                 }
7293                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
7294                         return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis, obj->maybe_claimable_htlc_awaiting_timeout.claimable_height);
7295                 }
7296                 default: abort();
7297         }
7298 }
7299 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
7300         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
7301         for (size_t i = 0; i < ret.datalen; i++) {
7302                 ret.data[i] = Balance_clone(&orig->data[i]);
7303         }
7304         return ret;
7305 }
7306 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
7307 CHECK(owner->result_ok);
7308         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
7309 }
7310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7311         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
7312         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
7313         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
7314         return ((uintptr_t)ret_conv);
7315 }
7316
7317 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
7318 CHECK(!owner->result_ok);
7319         return DecodeError_clone(&*owner->contents.err);
7320 }
7321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7322         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
7323         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
7324         uintptr_t ret_ref = 0;
7325         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7326         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7328         ret_ref = (uintptr_t)ret_var.inner;
7329         if (ret_var.is_owned) {
7330                 ret_ref |= 1;
7331         }
7332         return ret_ref;
7333 }
7334
7335 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
7336 CHECK(owner->result_ok);
7337         return *owner->contents.result;
7338 }
7339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7340         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
7341         CResult_NoneLightningErrorZ_get_ok(owner_conv);
7342 }
7343
7344 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
7345 CHECK(!owner->result_ok);
7346         return LightningError_clone(&*owner->contents.err);
7347 }
7348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7349         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
7350         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
7351         uintptr_t ret_ref = 0;
7352         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7353         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7355         ret_ref = (uintptr_t)ret_var.inner;
7356         if (ret_var.is_owned) {
7357                 ret_ref |= 1;
7358         }
7359         return ret_ref;
7360 }
7361
7362 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
7363         return owner->a;
7364 }
7365 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7366         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
7367         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
7368         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
7369         return ret_arr;
7370 }
7371
7372 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
7373         return Type_clone(&owner->b);
7374 }
7375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7376         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
7377         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
7378         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
7379         return (uintptr_t)ret_ret;
7380 }
7381
7382 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
7383         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
7384         for (size_t i = 0; i < ret.datalen; i++) {
7385                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
7386         }
7387         return ret;
7388 }
7389 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
7390 CHECK(owner->result_ok);
7391         return *owner->contents.result;
7392 }
7393 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7394         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
7395         jboolean ret_val = CResult_boolLightningErrorZ_get_ok(owner_conv);
7396         return ret_val;
7397 }
7398
7399 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
7400 CHECK(!owner->result_ok);
7401         return LightningError_clone(&*owner->contents.err);
7402 }
7403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7404         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
7405         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
7406         uintptr_t ret_ref = 0;
7407         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7408         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7410         ret_ref = (uintptr_t)ret_var.inner;
7411         if (ret_var.is_owned) {
7412                 ret_ref |= 1;
7413         }
7414         return ret_ref;
7415 }
7416
7417 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
7418         return ChannelAnnouncement_clone(&owner->a);
7419 }
7420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7421         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
7422         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
7423         uintptr_t ret_ref = 0;
7424         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7425         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7427         ret_ref = (uintptr_t)ret_var.inner;
7428         if (ret_var.is_owned) {
7429                 ret_ref |= 1;
7430         }
7431         return ret_ref;
7432 }
7433
7434 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
7435         return ChannelUpdate_clone(&owner->b);
7436 }
7437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7438         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
7439         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
7440         uintptr_t ret_ref = 0;
7441         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7442         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7444         ret_ref = (uintptr_t)ret_var.inner;
7445         if (ret_var.is_owned) {
7446                 ret_ref |= 1;
7447         }
7448         return ret_ref;
7449 }
7450
7451 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
7452         return ChannelUpdate_clone(&owner->c);
7453 }
7454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
7455         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
7456         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
7457         uintptr_t ret_ref = 0;
7458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7461         ret_ref = (uintptr_t)ret_var.inner;
7462         if (ret_var.is_owned) {
7463                 ret_ref |= 1;
7464         }
7465         return ret_ref;
7466 }
7467
7468 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
7469         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
7470         for (size_t i = 0; i < ret.datalen; i++) {
7471                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
7472         }
7473         return ret;
7474 }
7475 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
7476         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
7477         for (size_t i = 0; i < ret.datalen; i++) {
7478                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
7479         }
7480         return ret;
7481 }
7482 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7483 CHECK(owner->result_ok);
7484         return CVec_u8Z_clone(&*owner->contents.result);
7485 }
7486 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7487         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
7488         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
7489         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7490         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7491         CVec_u8Z_free(ret_var);
7492         return ret_arr;
7493 }
7494
7495 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7496 CHECK(!owner->result_ok);
7497         return PeerHandleError_clone(&*owner->contents.err);
7498 }
7499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7500         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
7501         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
7502         uintptr_t ret_ref = 0;
7503         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7504         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7506         ret_ref = (uintptr_t)ret_var.inner;
7507         if (ret_var.is_owned) {
7508                 ret_ref |= 1;
7509         }
7510         return ret_ref;
7511 }
7512
7513 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
7514 CHECK(owner->result_ok);
7515         return *owner->contents.result;
7516 }
7517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7518         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
7519         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
7520 }
7521
7522 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
7523 CHECK(!owner->result_ok);
7524         return PeerHandleError_clone(&*owner->contents.err);
7525 }
7526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7527         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
7528         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
7529         uintptr_t ret_ref = 0;
7530         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7531         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7533         ret_ref = (uintptr_t)ret_var.inner;
7534         if (ret_var.is_owned) {
7535                 ret_ref |= 1;
7536         }
7537         return ret_ref;
7538 }
7539
7540 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
7541 CHECK(owner->result_ok);
7542         return *owner->contents.result;
7543 }
7544 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7545         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
7546         jboolean ret_val = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
7547         return ret_val;
7548 }
7549
7550 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
7551 CHECK(!owner->result_ok);
7552         return PeerHandleError_clone(&*owner->contents.err);
7553 }
7554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7555         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
7556         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
7557         uintptr_t ret_ref = 0;
7558         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7559         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7561         ret_ref = (uintptr_t)ret_var.inner;
7562         if (ret_var.is_owned) {
7563                 ret_ref |= 1;
7564         }
7565         return ret_ref;
7566 }
7567
7568 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
7569 CHECK(owner->result_ok);
7570         return NodeId_clone(&*owner->contents.result);
7571 }
7572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7573         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
7574         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
7575         uintptr_t ret_ref = 0;
7576         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7577         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7578         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7579         ret_ref = (uintptr_t)ret_var.inner;
7580         if (ret_var.is_owned) {
7581                 ret_ref |= 1;
7582         }
7583         return ret_ref;
7584 }
7585
7586 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
7587 CHECK(!owner->result_ok);
7588         return DecodeError_clone(&*owner->contents.err);
7589 }
7590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7591         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
7592         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
7593         uintptr_t ret_ref = 0;
7594         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7595         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7596         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7597         ret_ref = (uintptr_t)ret_var.inner;
7598         if (ret_var.is_owned) {
7599                 ret_ref |= 1;
7600         }
7601         return ret_ref;
7602 }
7603
7604 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
7605 CHECK(owner->result_ok);
7606         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
7607 }
7608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7609         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
7610         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
7611         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
7612         uintptr_t ret_ref = (uintptr_t)ret_copy;
7613         return ret_ref;
7614 }
7615
7616 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
7617 CHECK(!owner->result_ok);
7618         return DecodeError_clone(&*owner->contents.err);
7619 }
7620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7621         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
7622         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
7623         uintptr_t ret_ref = 0;
7624         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7625         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7627         ret_ref = (uintptr_t)ret_var.inner;
7628         if (ret_var.is_owned) {
7629                 ret_ref |= 1;
7630         }
7631         return ret_ref;
7632 }
7633
7634 typedef struct LDKAccess_JCalls {
7635         atomic_size_t refcnt;
7636         JavaVM *vm;
7637         jweak o;
7638         jmethodID get_utxo_meth;
7639 } LDKAccess_JCalls;
7640 static void LDKAccess_JCalls_free(void* this_arg) {
7641         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
7642         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7643                 JNIEnv *env;
7644                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7645                 if (get_jenv_res == JNI_EDETACHED) {
7646                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7647                 } else {
7648                         DO_ASSERT(get_jenv_res == JNI_OK);
7649                 }
7650                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7651                 if (get_jenv_res == JNI_EDETACHED) {
7652                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7653                 }
7654                 FREE(j_calls);
7655         }
7656 }
7657 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
7658         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
7659         JNIEnv *env;
7660         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7661         if (get_jenv_res == JNI_EDETACHED) {
7662                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7663         } else {
7664                 DO_ASSERT(get_jenv_res == JNI_OK);
7665         }
7666         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
7667         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
7668         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7669         CHECK(obj != NULL);
7670         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
7671         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7672                 (*env)->ExceptionDescribe(env);
7673                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
7674         }
7675         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
7676         CHECK_ACCESS(ret_ptr);
7677         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
7678         FREE((void*)ret);
7679         if (get_jenv_res == JNI_EDETACHED) {
7680                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7681         }
7682         return ret_conv;
7683 }
7684 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
7685         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
7686         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7687 }
7688 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
7689         jclass c = (*env)->GetObjectClass(env, o);
7690         CHECK(c != NULL);
7691         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
7692         atomic_init(&calls->refcnt, 1);
7693         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7694         calls->o = (*env)->NewWeakGlobalRef(env, o);
7695         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
7696         CHECK(calls->get_utxo_meth != NULL);
7697
7698         LDKAccess ret = {
7699                 .this_arg = (void*) calls,
7700                 .get_utxo = get_utxo_LDKAccess_jcall,
7701                 .free = LDKAccess_JCalls_free,
7702         };
7703         return ret;
7704 }
7705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
7706         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
7707         *res_ptr = LDKAccess_init(env, clz, o);
7708         return (uint64_t)res_ptr;
7709 }
7710 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) {
7711         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7712         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7713         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
7714         unsigned char genesis_hash_arr[32];
7715         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
7716         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
7717         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
7718         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7719         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
7720         return (uintptr_t)ret_conv;
7721 }
7722
7723 static jclass LDKCOption_AccessZ_Some_class = NULL;
7724 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
7725 static jclass LDKCOption_AccessZ_None_class = NULL;
7726 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
7727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
7728         LDKCOption_AccessZ_Some_class =
7729                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
7730         CHECK(LDKCOption_AccessZ_Some_class != NULL);
7731         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
7732         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
7733         LDKCOption_AccessZ_None_class =
7734                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
7735         CHECK(LDKCOption_AccessZ_None_class != NULL);
7736         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
7737         CHECK(LDKCOption_AccessZ_None_meth != NULL);
7738 }
7739 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7740         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
7741         switch(obj->tag) {
7742                 case LDKCOption_AccessZ_Some: {
7743                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
7744                         *some_ret = obj->some;
7745                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
7746                         if ((*some_ret).free == LDKAccess_JCalls_free) {
7747                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7748                                 LDKAccess_JCalls_cloned(&(*some_ret));
7749                         }
7750                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (uintptr_t)some_ret);
7751                 }
7752                 case LDKCOption_AccessZ_None: {
7753                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
7754                 }
7755                 default: abort();
7756         }
7757 }
7758 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
7759 CHECK(owner->result_ok);
7760         return ChannelUpdateInfo_clone(&*owner->contents.result);
7761 }
7762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7763         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
7764         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
7765         uintptr_t ret_ref = 0;
7766         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7767         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7769         ret_ref = (uintptr_t)ret_var.inner;
7770         if (ret_var.is_owned) {
7771                 ret_ref |= 1;
7772         }
7773         return ret_ref;
7774 }
7775
7776 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
7777 CHECK(!owner->result_ok);
7778         return DecodeError_clone(&*owner->contents.err);
7779 }
7780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7781         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
7782         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
7783         uintptr_t ret_ref = 0;
7784         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7785         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7787         ret_ref = (uintptr_t)ret_var.inner;
7788         if (ret_var.is_owned) {
7789                 ret_ref |= 1;
7790         }
7791         return ret_ref;
7792 }
7793
7794 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
7795 CHECK(owner->result_ok);
7796         return ChannelInfo_clone(&*owner->contents.result);
7797 }
7798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7799         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
7800         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
7801         uintptr_t ret_ref = 0;
7802         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7803         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7805         ret_ref = (uintptr_t)ret_var.inner;
7806         if (ret_var.is_owned) {
7807                 ret_ref |= 1;
7808         }
7809         return ret_ref;
7810 }
7811
7812 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
7813 CHECK(!owner->result_ok);
7814         return DecodeError_clone(&*owner->contents.err);
7815 }
7816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7817         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
7818         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
7819         uintptr_t ret_ref = 0;
7820         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7821         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7823         ret_ref = (uintptr_t)ret_var.inner;
7824         if (ret_var.is_owned) {
7825                 ret_ref |= 1;
7826         }
7827         return ret_ref;
7828 }
7829
7830 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
7831 CHECK(owner->result_ok);
7832         return RoutingFees_clone(&*owner->contents.result);
7833 }
7834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7835         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
7836         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
7837         uintptr_t ret_ref = 0;
7838         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7839         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7841         ret_ref = (uintptr_t)ret_var.inner;
7842         if (ret_var.is_owned) {
7843                 ret_ref |= 1;
7844         }
7845         return ret_ref;
7846 }
7847
7848 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
7849 CHECK(!owner->result_ok);
7850         return DecodeError_clone(&*owner->contents.err);
7851 }
7852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7853         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
7854         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
7855         uintptr_t ret_ref = 0;
7856         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7857         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7859         ret_ref = (uintptr_t)ret_var.inner;
7860         if (ret_var.is_owned) {
7861                 ret_ref |= 1;
7862         }
7863         return ret_ref;
7864 }
7865
7866 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
7867 CHECK(owner->result_ok);
7868         return NodeAnnouncementInfo_clone(&*owner->contents.result);
7869 }
7870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7871         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
7872         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
7873         uintptr_t ret_ref = 0;
7874         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7875         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7877         ret_ref = (uintptr_t)ret_var.inner;
7878         if (ret_var.is_owned) {
7879                 ret_ref |= 1;
7880         }
7881         return ret_ref;
7882 }
7883
7884 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
7885 CHECK(!owner->result_ok);
7886         return DecodeError_clone(&*owner->contents.err);
7887 }
7888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7889         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
7890         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
7891         uintptr_t ret_ref = 0;
7892         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7893         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7895         ret_ref = (uintptr_t)ret_var.inner;
7896         if (ret_var.is_owned) {
7897                 ret_ref |= 1;
7898         }
7899         return ret_ref;
7900 }
7901
7902 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
7903         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
7904         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
7905         return ret;
7906 }
7907 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
7908 CHECK(owner->result_ok);
7909         return NodeInfo_clone(&*owner->contents.result);
7910 }
7911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7912         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
7913         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
7914         uintptr_t ret_ref = 0;
7915         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7916         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7918         ret_ref = (uintptr_t)ret_var.inner;
7919         if (ret_var.is_owned) {
7920                 ret_ref |= 1;
7921         }
7922         return ret_ref;
7923 }
7924
7925 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
7926 CHECK(!owner->result_ok);
7927         return DecodeError_clone(&*owner->contents.err);
7928 }
7929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7930         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
7931         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
7932         uintptr_t ret_ref = 0;
7933         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7934         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7936         ret_ref = (uintptr_t)ret_var.inner;
7937         if (ret_var.is_owned) {
7938                 ret_ref |= 1;
7939         }
7940         return ret_ref;
7941 }
7942
7943 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
7944 CHECK(owner->result_ok);
7945         return NetworkGraph_clone(&*owner->contents.result);
7946 }
7947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7948         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
7949         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
7950         uintptr_t ret_ref = 0;
7951         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7952         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7954         ret_ref = (uintptr_t)ret_var.inner;
7955         if (ret_var.is_owned) {
7956                 ret_ref |= 1;
7957         }
7958         return ret_ref;
7959 }
7960
7961 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
7962 CHECK(!owner->result_ok);
7963         return DecodeError_clone(&*owner->contents.err);
7964 }
7965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7966         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
7967         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
7968         uintptr_t ret_ref = 0;
7969         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7970         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7972         ret_ref = (uintptr_t)ret_var.inner;
7973         if (ret_var.is_owned) {
7974                 ret_ref |= 1;
7975         }
7976         return ret_ref;
7977 }
7978
7979 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
7980 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
7981 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
7982 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
7983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
7984         LDKCOption_CVec_NetAddressZZ_Some_class =
7985                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
7986         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
7987         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
7988         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
7989         LDKCOption_CVec_NetAddressZZ_None_class =
7990                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
7991         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
7992         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
7993         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
7994 }
7995 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7996         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
7997         switch(obj->tag) {
7998                 case LDKCOption_CVec_NetAddressZZ_Some: {
7999                         LDKCVec_NetAddressZ some_var = obj->some;
8000                         int64_tArray some_arr = NULL;
8001                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
8002                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
8003                         for (size_t m = 0; m < some_var.datalen; m++) {
8004                                 uintptr_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
8005                                 some_arr_ptr[m] = some_conv_12_ref;
8006                         }
8007                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
8008                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
8009                 }
8010                 case LDKCOption_CVec_NetAddressZZ_None: {
8011                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
8012                 }
8013                 default: abort();
8014         }
8015 }
8016 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8017 CHECK(owner->result_ok);
8018         return NetAddress_clone(&*owner->contents.result);
8019 }
8020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8021         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8022         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
8023         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
8024         uintptr_t ret_ref = (uintptr_t)ret_copy;
8025         return ret_ref;
8026 }
8027
8028 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8029 CHECK(!owner->result_ok);
8030         return DecodeError_clone(&*owner->contents.err);
8031 }
8032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8033         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8034         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
8035         uintptr_t ret_ref = 0;
8036         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8037         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8039         ret_ref = (uintptr_t)ret_var.inner;
8040         if (ret_var.is_owned) {
8041                 ret_ref |= 1;
8042         }
8043         return ret_ref;
8044 }
8045
8046 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
8047         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
8048         for (size_t i = 0; i < ret.datalen; i++) {
8049                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
8050         }
8051         return ret;
8052 }
8053 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
8054         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
8055         for (size_t i = 0; i < ret.datalen; i++) {
8056                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
8057         }
8058         return ret;
8059 }
8060 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
8061         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
8062         for (size_t i = 0; i < ret.datalen; i++) {
8063                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
8064         }
8065         return ret;
8066 }
8067 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
8068         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
8069         for (size_t i = 0; i < ret.datalen; i++) {
8070                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
8071         }
8072         return ret;
8073 }
8074 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8075 CHECK(owner->result_ok);
8076         return AcceptChannel_clone(&*owner->contents.result);
8077 }
8078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8079         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8080         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
8081         uintptr_t ret_ref = 0;
8082         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8083         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8085         ret_ref = (uintptr_t)ret_var.inner;
8086         if (ret_var.is_owned) {
8087                 ret_ref |= 1;
8088         }
8089         return ret_ref;
8090 }
8091
8092 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8093 CHECK(!owner->result_ok);
8094         return DecodeError_clone(&*owner->contents.err);
8095 }
8096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8097         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8098         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
8099         uintptr_t ret_ref = 0;
8100         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8101         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8103         ret_ref = (uintptr_t)ret_var.inner;
8104         if (ret_var.is_owned) {
8105                 ret_ref |= 1;
8106         }
8107         return ret_ref;
8108 }
8109
8110 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8111 CHECK(owner->result_ok);
8112         return AnnouncementSignatures_clone(&*owner->contents.result);
8113 }
8114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8115         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8116         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
8117         uintptr_t ret_ref = 0;
8118         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8119         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8121         ret_ref = (uintptr_t)ret_var.inner;
8122         if (ret_var.is_owned) {
8123                 ret_ref |= 1;
8124         }
8125         return ret_ref;
8126 }
8127
8128 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8129 CHECK(!owner->result_ok);
8130         return DecodeError_clone(&*owner->contents.err);
8131 }
8132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8133         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8134         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
8135         uintptr_t ret_ref = 0;
8136         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8137         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8139         ret_ref = (uintptr_t)ret_var.inner;
8140         if (ret_var.is_owned) {
8141                 ret_ref |= 1;
8142         }
8143         return ret_ref;
8144 }
8145
8146 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8147 CHECK(owner->result_ok);
8148         return ChannelReestablish_clone(&*owner->contents.result);
8149 }
8150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8151         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8152         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
8153         uintptr_t ret_ref = 0;
8154         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8155         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8157         ret_ref = (uintptr_t)ret_var.inner;
8158         if (ret_var.is_owned) {
8159                 ret_ref |= 1;
8160         }
8161         return ret_ref;
8162 }
8163
8164 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8165 CHECK(!owner->result_ok);
8166         return DecodeError_clone(&*owner->contents.err);
8167 }
8168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8169         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8170         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
8171         uintptr_t ret_ref = 0;
8172         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8173         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8175         ret_ref = (uintptr_t)ret_var.inner;
8176         if (ret_var.is_owned) {
8177                 ret_ref |= 1;
8178         }
8179         return ret_ref;
8180 }
8181
8182 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8183 CHECK(owner->result_ok);
8184         return ClosingSigned_clone(&*owner->contents.result);
8185 }
8186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8187         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8188         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
8189         uintptr_t ret_ref = 0;
8190         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8191         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8193         ret_ref = (uintptr_t)ret_var.inner;
8194         if (ret_var.is_owned) {
8195                 ret_ref |= 1;
8196         }
8197         return ret_ref;
8198 }
8199
8200 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8201 CHECK(!owner->result_ok);
8202         return DecodeError_clone(&*owner->contents.err);
8203 }
8204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8205         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8206         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
8207         uintptr_t ret_ref = 0;
8208         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8209         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8211         ret_ref = (uintptr_t)ret_var.inner;
8212         if (ret_var.is_owned) {
8213                 ret_ref |= 1;
8214         }
8215         return ret_ref;
8216 }
8217
8218 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8219 CHECK(owner->result_ok);
8220         return ClosingSignedFeeRange_clone(&*owner->contents.result);
8221 }
8222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8223         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
8224         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
8225         uintptr_t ret_ref = 0;
8226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8229         ret_ref = (uintptr_t)ret_var.inner;
8230         if (ret_var.is_owned) {
8231                 ret_ref |= 1;
8232         }
8233         return ret_ref;
8234 }
8235
8236 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8237 CHECK(!owner->result_ok);
8238         return DecodeError_clone(&*owner->contents.err);
8239 }
8240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8241         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
8242         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
8243         uintptr_t ret_ref = 0;
8244         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8245         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8247         ret_ref = (uintptr_t)ret_var.inner;
8248         if (ret_var.is_owned) {
8249                 ret_ref |= 1;
8250         }
8251         return ret_ref;
8252 }
8253
8254 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8255 CHECK(owner->result_ok);
8256         return CommitmentSigned_clone(&*owner->contents.result);
8257 }
8258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8259         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
8260         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
8261         uintptr_t ret_ref = 0;
8262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8265         ret_ref = (uintptr_t)ret_var.inner;
8266         if (ret_var.is_owned) {
8267                 ret_ref |= 1;
8268         }
8269         return ret_ref;
8270 }
8271
8272 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8273 CHECK(!owner->result_ok);
8274         return DecodeError_clone(&*owner->contents.err);
8275 }
8276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8277         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
8278         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
8279         uintptr_t ret_ref = 0;
8280         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8281         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8283         ret_ref = (uintptr_t)ret_var.inner;
8284         if (ret_var.is_owned) {
8285                 ret_ref |= 1;
8286         }
8287         return ret_ref;
8288 }
8289
8290 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8291 CHECK(owner->result_ok);
8292         return FundingCreated_clone(&*owner->contents.result);
8293 }
8294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8295         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
8296         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
8297         uintptr_t ret_ref = 0;
8298         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8299         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8300         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8301         ret_ref = (uintptr_t)ret_var.inner;
8302         if (ret_var.is_owned) {
8303                 ret_ref |= 1;
8304         }
8305         return ret_ref;
8306 }
8307
8308 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8309 CHECK(!owner->result_ok);
8310         return DecodeError_clone(&*owner->contents.err);
8311 }
8312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8313         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
8314         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
8315         uintptr_t ret_ref = 0;
8316         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8317         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8319         ret_ref = (uintptr_t)ret_var.inner;
8320         if (ret_var.is_owned) {
8321                 ret_ref |= 1;
8322         }
8323         return ret_ref;
8324 }
8325
8326 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8327 CHECK(owner->result_ok);
8328         return FundingSigned_clone(&*owner->contents.result);
8329 }
8330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8331         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
8332         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
8333         uintptr_t ret_ref = 0;
8334         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8335         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8337         ret_ref = (uintptr_t)ret_var.inner;
8338         if (ret_var.is_owned) {
8339                 ret_ref |= 1;
8340         }
8341         return ret_ref;
8342 }
8343
8344 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8345 CHECK(!owner->result_ok);
8346         return DecodeError_clone(&*owner->contents.err);
8347 }
8348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8349         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
8350         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
8351         uintptr_t ret_ref = 0;
8352         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8353         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8355         ret_ref = (uintptr_t)ret_var.inner;
8356         if (ret_var.is_owned) {
8357                 ret_ref |= 1;
8358         }
8359         return ret_ref;
8360 }
8361
8362 static inline struct LDKFundingLocked CResult_FundingLockedDecodeErrorZ_get_ok(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
8363 CHECK(owner->result_ok);
8364         return FundingLocked_clone(&*owner->contents.result);
8365 }
8366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8367         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
8368         LDKFundingLocked ret_var = CResult_FundingLockedDecodeErrorZ_get_ok(owner_conv);
8369         uintptr_t ret_ref = 0;
8370         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8371         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8373         ret_ref = (uintptr_t)ret_var.inner;
8374         if (ret_var.is_owned) {
8375                 ret_ref |= 1;
8376         }
8377         return ret_ref;
8378 }
8379
8380 static inline struct LDKDecodeError CResult_FundingLockedDecodeErrorZ_get_err(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
8381 CHECK(!owner->result_ok);
8382         return DecodeError_clone(&*owner->contents.err);
8383 }
8384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8385         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
8386         LDKDecodeError ret_var = CResult_FundingLockedDecodeErrorZ_get_err(owner_conv);
8387         uintptr_t ret_ref = 0;
8388         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8389         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8391         ret_ref = (uintptr_t)ret_var.inner;
8392         if (ret_var.is_owned) {
8393                 ret_ref |= 1;
8394         }
8395         return ret_ref;
8396 }
8397
8398 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8399 CHECK(owner->result_ok);
8400         return Init_clone(&*owner->contents.result);
8401 }
8402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8403         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
8404         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
8405         uintptr_t ret_ref = 0;
8406         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8407         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8409         ret_ref = (uintptr_t)ret_var.inner;
8410         if (ret_var.is_owned) {
8411                 ret_ref |= 1;
8412         }
8413         return ret_ref;
8414 }
8415
8416 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8417 CHECK(!owner->result_ok);
8418         return DecodeError_clone(&*owner->contents.err);
8419 }
8420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8421         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
8422         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
8423         uintptr_t ret_ref = 0;
8424         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8425         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8427         ret_ref = (uintptr_t)ret_var.inner;
8428         if (ret_var.is_owned) {
8429                 ret_ref |= 1;
8430         }
8431         return ret_ref;
8432 }
8433
8434 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8435 CHECK(owner->result_ok);
8436         return OpenChannel_clone(&*owner->contents.result);
8437 }
8438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8439         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
8440         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
8441         uintptr_t ret_ref = 0;
8442         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8443         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8445         ret_ref = (uintptr_t)ret_var.inner;
8446         if (ret_var.is_owned) {
8447                 ret_ref |= 1;
8448         }
8449         return ret_ref;
8450 }
8451
8452 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8453 CHECK(!owner->result_ok);
8454         return DecodeError_clone(&*owner->contents.err);
8455 }
8456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8457         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
8458         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
8459         uintptr_t ret_ref = 0;
8460         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8461         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8463         ret_ref = (uintptr_t)ret_var.inner;
8464         if (ret_var.is_owned) {
8465                 ret_ref |= 1;
8466         }
8467         return ret_ref;
8468 }
8469
8470 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8471 CHECK(owner->result_ok);
8472         return RevokeAndACK_clone(&*owner->contents.result);
8473 }
8474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8475         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
8476         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
8477         uintptr_t ret_ref = 0;
8478         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8479         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8481         ret_ref = (uintptr_t)ret_var.inner;
8482         if (ret_var.is_owned) {
8483                 ret_ref |= 1;
8484         }
8485         return ret_ref;
8486 }
8487
8488 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8489 CHECK(!owner->result_ok);
8490         return DecodeError_clone(&*owner->contents.err);
8491 }
8492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8493         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
8494         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
8495         uintptr_t ret_ref = 0;
8496         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8497         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8499         ret_ref = (uintptr_t)ret_var.inner;
8500         if (ret_var.is_owned) {
8501                 ret_ref |= 1;
8502         }
8503         return ret_ref;
8504 }
8505
8506 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8507 CHECK(owner->result_ok);
8508         return Shutdown_clone(&*owner->contents.result);
8509 }
8510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8511         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
8512         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
8513         uintptr_t ret_ref = 0;
8514         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8515         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8517         ret_ref = (uintptr_t)ret_var.inner;
8518         if (ret_var.is_owned) {
8519                 ret_ref |= 1;
8520         }
8521         return ret_ref;
8522 }
8523
8524 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8525 CHECK(!owner->result_ok);
8526         return DecodeError_clone(&*owner->contents.err);
8527 }
8528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8529         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
8530         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
8531         uintptr_t ret_ref = 0;
8532         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8533         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8535         ret_ref = (uintptr_t)ret_var.inner;
8536         if (ret_var.is_owned) {
8537                 ret_ref |= 1;
8538         }
8539         return ret_ref;
8540 }
8541
8542 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8543 CHECK(owner->result_ok);
8544         return UpdateFailHTLC_clone(&*owner->contents.result);
8545 }
8546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8547         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
8548         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
8549         uintptr_t ret_ref = 0;
8550         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8551         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8553         ret_ref = (uintptr_t)ret_var.inner;
8554         if (ret_var.is_owned) {
8555                 ret_ref |= 1;
8556         }
8557         return ret_ref;
8558 }
8559
8560 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8561 CHECK(!owner->result_ok);
8562         return DecodeError_clone(&*owner->contents.err);
8563 }
8564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8565         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
8566         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
8567         uintptr_t ret_ref = 0;
8568         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8569         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8571         ret_ref = (uintptr_t)ret_var.inner;
8572         if (ret_var.is_owned) {
8573                 ret_ref |= 1;
8574         }
8575         return ret_ref;
8576 }
8577
8578 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
8579 CHECK(owner->result_ok);
8580         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
8581 }
8582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8583         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
8584         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
8585         uintptr_t ret_ref = 0;
8586         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8587         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8589         ret_ref = (uintptr_t)ret_var.inner;
8590         if (ret_var.is_owned) {
8591                 ret_ref |= 1;
8592         }
8593         return ret_ref;
8594 }
8595
8596 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
8597 CHECK(!owner->result_ok);
8598         return DecodeError_clone(&*owner->contents.err);
8599 }
8600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8601         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
8602         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
8603         uintptr_t ret_ref = 0;
8604         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8605         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8607         ret_ref = (uintptr_t)ret_var.inner;
8608         if (ret_var.is_owned) {
8609                 ret_ref |= 1;
8610         }
8611         return ret_ref;
8612 }
8613
8614 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
8615 CHECK(owner->result_ok);
8616         return UpdateFee_clone(&*owner->contents.result);
8617 }
8618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8619         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
8620         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
8621         uintptr_t ret_ref = 0;
8622         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8623         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8625         ret_ref = (uintptr_t)ret_var.inner;
8626         if (ret_var.is_owned) {
8627                 ret_ref |= 1;
8628         }
8629         return ret_ref;
8630 }
8631
8632 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
8633 CHECK(!owner->result_ok);
8634         return DecodeError_clone(&*owner->contents.err);
8635 }
8636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8637         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
8638         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
8639         uintptr_t ret_ref = 0;
8640         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8641         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8643         ret_ref = (uintptr_t)ret_var.inner;
8644         if (ret_var.is_owned) {
8645                 ret_ref |= 1;
8646         }
8647         return ret_ref;
8648 }
8649
8650 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
8651 CHECK(owner->result_ok);
8652         return UpdateFulfillHTLC_clone(&*owner->contents.result);
8653 }
8654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8655         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
8656         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
8657         uintptr_t ret_ref = 0;
8658         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8659         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8661         ret_ref = (uintptr_t)ret_var.inner;
8662         if (ret_var.is_owned) {
8663                 ret_ref |= 1;
8664         }
8665         return ret_ref;
8666 }
8667
8668 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
8669 CHECK(!owner->result_ok);
8670         return DecodeError_clone(&*owner->contents.err);
8671 }
8672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8673         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
8674         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
8675         uintptr_t ret_ref = 0;
8676         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8677         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8679         ret_ref = (uintptr_t)ret_var.inner;
8680         if (ret_var.is_owned) {
8681                 ret_ref |= 1;
8682         }
8683         return ret_ref;
8684 }
8685
8686 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
8687 CHECK(owner->result_ok);
8688         return UpdateAddHTLC_clone(&*owner->contents.result);
8689 }
8690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8691         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
8692         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
8693         uintptr_t ret_ref = 0;
8694         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8695         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8697         ret_ref = (uintptr_t)ret_var.inner;
8698         if (ret_var.is_owned) {
8699                 ret_ref |= 1;
8700         }
8701         return ret_ref;
8702 }
8703
8704 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
8705 CHECK(!owner->result_ok);
8706         return DecodeError_clone(&*owner->contents.err);
8707 }
8708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8709         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
8710         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
8711         uintptr_t ret_ref = 0;
8712         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8713         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8715         ret_ref = (uintptr_t)ret_var.inner;
8716         if (ret_var.is_owned) {
8717                 ret_ref |= 1;
8718         }
8719         return ret_ref;
8720 }
8721
8722 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
8723 CHECK(owner->result_ok);
8724         return Ping_clone(&*owner->contents.result);
8725 }
8726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8727         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
8728         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
8729         uintptr_t ret_ref = 0;
8730         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8731         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8733         ret_ref = (uintptr_t)ret_var.inner;
8734         if (ret_var.is_owned) {
8735                 ret_ref |= 1;
8736         }
8737         return ret_ref;
8738 }
8739
8740 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
8741 CHECK(!owner->result_ok);
8742         return DecodeError_clone(&*owner->contents.err);
8743 }
8744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8745         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
8746         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
8747         uintptr_t ret_ref = 0;
8748         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8749         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8751         ret_ref = (uintptr_t)ret_var.inner;
8752         if (ret_var.is_owned) {
8753                 ret_ref |= 1;
8754         }
8755         return ret_ref;
8756 }
8757
8758 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
8759 CHECK(owner->result_ok);
8760         return Pong_clone(&*owner->contents.result);
8761 }
8762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8763         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
8764         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
8765         uintptr_t ret_ref = 0;
8766         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8767         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8769         ret_ref = (uintptr_t)ret_var.inner;
8770         if (ret_var.is_owned) {
8771                 ret_ref |= 1;
8772         }
8773         return ret_ref;
8774 }
8775
8776 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
8777 CHECK(!owner->result_ok);
8778         return DecodeError_clone(&*owner->contents.err);
8779 }
8780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8781         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
8782         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
8783         uintptr_t ret_ref = 0;
8784         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8785         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8787         ret_ref = (uintptr_t)ret_var.inner;
8788         if (ret_var.is_owned) {
8789                 ret_ref |= 1;
8790         }
8791         return ret_ref;
8792 }
8793
8794 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8795 CHECK(owner->result_ok);
8796         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
8797 }
8798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8799         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
8800         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
8801         uintptr_t ret_ref = 0;
8802         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8803         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8805         ret_ref = (uintptr_t)ret_var.inner;
8806         if (ret_var.is_owned) {
8807                 ret_ref |= 1;
8808         }
8809         return ret_ref;
8810 }
8811
8812 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8813 CHECK(!owner->result_ok);
8814         return DecodeError_clone(&*owner->contents.err);
8815 }
8816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8817         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
8818         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
8819         uintptr_t ret_ref = 0;
8820         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8821         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8823         ret_ref = (uintptr_t)ret_var.inner;
8824         if (ret_var.is_owned) {
8825                 ret_ref |= 1;
8826         }
8827         return ret_ref;
8828 }
8829
8830 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8831 CHECK(owner->result_ok);
8832         return ChannelAnnouncement_clone(&*owner->contents.result);
8833 }
8834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8835         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
8836         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
8837         uintptr_t ret_ref = 0;
8838         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8839         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8841         ret_ref = (uintptr_t)ret_var.inner;
8842         if (ret_var.is_owned) {
8843                 ret_ref |= 1;
8844         }
8845         return ret_ref;
8846 }
8847
8848 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8849 CHECK(!owner->result_ok);
8850         return DecodeError_clone(&*owner->contents.err);
8851 }
8852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8853         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
8854         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
8855         uintptr_t ret_ref = 0;
8856         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8857         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8859         ret_ref = (uintptr_t)ret_var.inner;
8860         if (ret_var.is_owned) {
8861                 ret_ref |= 1;
8862         }
8863         return ret_ref;
8864 }
8865
8866 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8867 CHECK(owner->result_ok);
8868         return UnsignedChannelUpdate_clone(&*owner->contents.result);
8869 }
8870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8871         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
8872         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
8873         uintptr_t ret_ref = 0;
8874         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8875         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8877         ret_ref = (uintptr_t)ret_var.inner;
8878         if (ret_var.is_owned) {
8879                 ret_ref |= 1;
8880         }
8881         return ret_ref;
8882 }
8883
8884 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8885 CHECK(!owner->result_ok);
8886         return DecodeError_clone(&*owner->contents.err);
8887 }
8888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8889         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
8890         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
8891         uintptr_t ret_ref = 0;
8892         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8893         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8895         ret_ref = (uintptr_t)ret_var.inner;
8896         if (ret_var.is_owned) {
8897                 ret_ref |= 1;
8898         }
8899         return ret_ref;
8900 }
8901
8902 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8903 CHECK(owner->result_ok);
8904         return ChannelUpdate_clone(&*owner->contents.result);
8905 }
8906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8907         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
8908         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
8909         uintptr_t ret_ref = 0;
8910         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8911         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8913         ret_ref = (uintptr_t)ret_var.inner;
8914         if (ret_var.is_owned) {
8915                 ret_ref |= 1;
8916         }
8917         return ret_ref;
8918 }
8919
8920 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8921 CHECK(!owner->result_ok);
8922         return DecodeError_clone(&*owner->contents.err);
8923 }
8924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8925         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
8926         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
8927         uintptr_t ret_ref = 0;
8928         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8929         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8931         ret_ref = (uintptr_t)ret_var.inner;
8932         if (ret_var.is_owned) {
8933                 ret_ref |= 1;
8934         }
8935         return ret_ref;
8936 }
8937
8938 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
8939 CHECK(owner->result_ok);
8940         return ErrorMessage_clone(&*owner->contents.result);
8941 }
8942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8943         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
8944         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
8945         uintptr_t ret_ref = 0;
8946         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8947         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8949         ret_ref = (uintptr_t)ret_var.inner;
8950         if (ret_var.is_owned) {
8951                 ret_ref |= 1;
8952         }
8953         return ret_ref;
8954 }
8955
8956 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
8957 CHECK(!owner->result_ok);
8958         return DecodeError_clone(&*owner->contents.err);
8959 }
8960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8961         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
8962         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
8963         uintptr_t ret_ref = 0;
8964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8967         ret_ref = (uintptr_t)ret_var.inner;
8968         if (ret_var.is_owned) {
8969                 ret_ref |= 1;
8970         }
8971         return ret_ref;
8972 }
8973
8974 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
8975 CHECK(owner->result_ok);
8976         return WarningMessage_clone(&*owner->contents.result);
8977 }
8978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8979         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
8980         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
8981         uintptr_t ret_ref = 0;
8982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8985         ret_ref = (uintptr_t)ret_var.inner;
8986         if (ret_var.is_owned) {
8987                 ret_ref |= 1;
8988         }
8989         return ret_ref;
8990 }
8991
8992 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
8993 CHECK(!owner->result_ok);
8994         return DecodeError_clone(&*owner->contents.err);
8995 }
8996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8997         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
8998         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
8999         uintptr_t ret_ref = 0;
9000         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9001         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9003         ret_ref = (uintptr_t)ret_var.inner;
9004         if (ret_var.is_owned) {
9005                 ret_ref |= 1;
9006         }
9007         return ret_ref;
9008 }
9009
9010 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9011 CHECK(owner->result_ok);
9012         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
9013 }
9014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9015         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9016         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9017         uintptr_t ret_ref = 0;
9018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9021         ret_ref = (uintptr_t)ret_var.inner;
9022         if (ret_var.is_owned) {
9023                 ret_ref |= 1;
9024         }
9025         return ret_ref;
9026 }
9027
9028 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9029 CHECK(!owner->result_ok);
9030         return DecodeError_clone(&*owner->contents.err);
9031 }
9032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9033         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9034         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9035         uintptr_t ret_ref = 0;
9036         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9037         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9039         ret_ref = (uintptr_t)ret_var.inner;
9040         if (ret_var.is_owned) {
9041                 ret_ref |= 1;
9042         }
9043         return ret_ref;
9044 }
9045
9046 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9047 CHECK(owner->result_ok);
9048         return NodeAnnouncement_clone(&*owner->contents.result);
9049 }
9050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9051         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9052         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9053         uintptr_t ret_ref = 0;
9054         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9055         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9057         ret_ref = (uintptr_t)ret_var.inner;
9058         if (ret_var.is_owned) {
9059                 ret_ref |= 1;
9060         }
9061         return ret_ref;
9062 }
9063
9064 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9065 CHECK(!owner->result_ok);
9066         return DecodeError_clone(&*owner->contents.err);
9067 }
9068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9069         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9070         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9071         uintptr_t ret_ref = 0;
9072         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9073         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9075         ret_ref = (uintptr_t)ret_var.inner;
9076         if (ret_var.is_owned) {
9077                 ret_ref |= 1;
9078         }
9079         return ret_ref;
9080 }
9081
9082 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9083 CHECK(owner->result_ok);
9084         return QueryShortChannelIds_clone(&*owner->contents.result);
9085 }
9086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9087         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9088         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
9089         uintptr_t ret_ref = 0;
9090         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9091         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9093         ret_ref = (uintptr_t)ret_var.inner;
9094         if (ret_var.is_owned) {
9095                 ret_ref |= 1;
9096         }
9097         return ret_ref;
9098 }
9099
9100 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9101 CHECK(!owner->result_ok);
9102         return DecodeError_clone(&*owner->contents.err);
9103 }
9104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9105         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9106         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
9107         uintptr_t ret_ref = 0;
9108         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9109         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9110         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9111         ret_ref = (uintptr_t)ret_var.inner;
9112         if (ret_var.is_owned) {
9113                 ret_ref |= 1;
9114         }
9115         return ret_ref;
9116 }
9117
9118 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9119 CHECK(owner->result_ok);
9120         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
9121 }
9122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9123         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9124         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
9125         uintptr_t ret_ref = 0;
9126         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9127         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9128         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9129         ret_ref = (uintptr_t)ret_var.inner;
9130         if (ret_var.is_owned) {
9131                 ret_ref |= 1;
9132         }
9133         return ret_ref;
9134 }
9135
9136 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9137 CHECK(!owner->result_ok);
9138         return DecodeError_clone(&*owner->contents.err);
9139 }
9140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9141         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9142         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
9143         uintptr_t ret_ref = 0;
9144         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9145         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9147         ret_ref = (uintptr_t)ret_var.inner;
9148         if (ret_var.is_owned) {
9149                 ret_ref |= 1;
9150         }
9151         return ret_ref;
9152 }
9153
9154 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9155 CHECK(owner->result_ok);
9156         return QueryChannelRange_clone(&*owner->contents.result);
9157 }
9158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9159         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9160         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
9161         uintptr_t ret_ref = 0;
9162         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9163         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9165         ret_ref = (uintptr_t)ret_var.inner;
9166         if (ret_var.is_owned) {
9167                 ret_ref |= 1;
9168         }
9169         return ret_ref;
9170 }
9171
9172 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9173 CHECK(!owner->result_ok);
9174         return DecodeError_clone(&*owner->contents.err);
9175 }
9176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9177         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9178         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
9179         uintptr_t ret_ref = 0;
9180         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9181         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9182         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9183         ret_ref = (uintptr_t)ret_var.inner;
9184         if (ret_var.is_owned) {
9185                 ret_ref |= 1;
9186         }
9187         return ret_ref;
9188 }
9189
9190 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9191 CHECK(owner->result_ok);
9192         return ReplyChannelRange_clone(&*owner->contents.result);
9193 }
9194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9195         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9196         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
9197         uintptr_t ret_ref = 0;
9198         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9199         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9201         ret_ref = (uintptr_t)ret_var.inner;
9202         if (ret_var.is_owned) {
9203                 ret_ref |= 1;
9204         }
9205         return ret_ref;
9206 }
9207
9208 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9209 CHECK(!owner->result_ok);
9210         return DecodeError_clone(&*owner->contents.err);
9211 }
9212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9213         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9214         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
9215         uintptr_t ret_ref = 0;
9216         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9217         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9219         ret_ref = (uintptr_t)ret_var.inner;
9220         if (ret_var.is_owned) {
9221                 ret_ref |= 1;
9222         }
9223         return ret_ref;
9224 }
9225
9226 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9227 CHECK(owner->result_ok);
9228         return GossipTimestampFilter_clone(&*owner->contents.result);
9229 }
9230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9231         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
9232         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
9233         uintptr_t ret_ref = 0;
9234         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9235         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9237         ret_ref = (uintptr_t)ret_var.inner;
9238         if (ret_var.is_owned) {
9239                 ret_ref |= 1;
9240         }
9241         return ret_ref;
9242 }
9243
9244 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9245 CHECK(!owner->result_ok);
9246         return DecodeError_clone(&*owner->contents.err);
9247 }
9248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9249         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
9250         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
9251         uintptr_t ret_ref = 0;
9252         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9253         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9255         ret_ref = (uintptr_t)ret_var.inner;
9256         if (ret_var.is_owned) {
9257                 ret_ref |= 1;
9258         }
9259         return ret_ref;
9260 }
9261
9262 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
9263         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
9264         for (size_t i = 0; i < ret.datalen; i++) {
9265                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
9266         }
9267         return ret;
9268 }
9269 static jclass LDKSignOrCreationError_SignError_class = NULL;
9270 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
9271 static jclass LDKSignOrCreationError_CreationError_class = NULL;
9272 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
9273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
9274         LDKSignOrCreationError_SignError_class =
9275                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
9276         CHECK(LDKSignOrCreationError_SignError_class != NULL);
9277         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
9278         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
9279         LDKSignOrCreationError_CreationError_class =
9280                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
9281         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
9282         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
9283         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
9284 }
9285 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9286         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
9287         switch(obj->tag) {
9288                 case LDKSignOrCreationError_SignError: {
9289                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
9290                 }
9291                 case LDKSignOrCreationError_CreationError: {
9292                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
9293                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
9294                 }
9295                 default: abort();
9296         }
9297 }
9298 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9299 CHECK(owner->result_ok);
9300         return Invoice_clone(&*owner->contents.result);
9301 }
9302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9303         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
9304         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
9305         uintptr_t ret_ref = 0;
9306         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9307         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9308         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9309         ret_ref = (uintptr_t)ret_var.inner;
9310         if (ret_var.is_owned) {
9311                 ret_ref |= 1;
9312         }
9313         return ret_ref;
9314 }
9315
9316 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9317 CHECK(!owner->result_ok);
9318         return SignOrCreationError_clone(&*owner->contents.err);
9319 }
9320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9321         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
9322         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
9323         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
9324         uintptr_t ret_ref = (uintptr_t)ret_copy;
9325         return ret_ref;
9326 }
9327
9328 typedef struct LDKFilter_JCalls {
9329         atomic_size_t refcnt;
9330         JavaVM *vm;
9331         jweak o;
9332         jmethodID register_tx_meth;
9333         jmethodID register_output_meth;
9334 } LDKFilter_JCalls;
9335 static void LDKFilter_JCalls_free(void* this_arg) {
9336         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9337         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9338                 JNIEnv *env;
9339                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9340                 if (get_jenv_res == JNI_EDETACHED) {
9341                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9342                 } else {
9343                         DO_ASSERT(get_jenv_res == JNI_OK);
9344                 }
9345                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9346                 if (get_jenv_res == JNI_EDETACHED) {
9347                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9348                 }
9349                 FREE(j_calls);
9350         }
9351 }
9352 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
9353         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9354         JNIEnv *env;
9355         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9356         if (get_jenv_res == JNI_EDETACHED) {
9357                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9358         } else {
9359                 DO_ASSERT(get_jenv_res == JNI_OK);
9360         }
9361         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
9362         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
9363         LDKu8slice script_pubkey_var = script_pubkey;
9364         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
9365         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
9366         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9367         CHECK(obj != NULL);
9368         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
9369         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9370                 (*env)->ExceptionDescribe(env);
9371                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
9372         }
9373         if (get_jenv_res == JNI_EDETACHED) {
9374                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9375         }
9376 }
9377 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
9378         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9379         JNIEnv *env;
9380         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9381         if (get_jenv_res == JNI_EDETACHED) {
9382                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9383         } else {
9384                 DO_ASSERT(get_jenv_res == JNI_OK);
9385         }
9386         LDKWatchedOutput output_var = output;
9387         uintptr_t output_ref = 0;
9388         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9389         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9390         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
9391         output_ref = (uintptr_t)output_var.inner;
9392         if (output_var.is_owned) {
9393                 output_ref |= 1;
9394         }
9395         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9396         CHECK(obj != NULL);
9397         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
9398         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9399                 (*env)->ExceptionDescribe(env);
9400                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
9401         }
9402         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9403         CHECK_ACCESS(ret_ptr);
9404         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
9405         FREE((void*)ret);
9406         if (get_jenv_res == JNI_EDETACHED) {
9407                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9408         }
9409         return ret_conv;
9410 }
9411 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
9412         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
9413         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9414 }
9415 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
9416         jclass c = (*env)->GetObjectClass(env, o);
9417         CHECK(c != NULL);
9418         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
9419         atomic_init(&calls->refcnt, 1);
9420         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9421         calls->o = (*env)->NewWeakGlobalRef(env, o);
9422         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
9423         CHECK(calls->register_tx_meth != NULL);
9424         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
9425         CHECK(calls->register_output_meth != NULL);
9426
9427         LDKFilter ret = {
9428                 .this_arg = (void*) calls,
9429                 .register_tx = register_tx_LDKFilter_jcall,
9430                 .register_output = register_output_LDKFilter_jcall,
9431                 .free = LDKFilter_JCalls_free,
9432         };
9433         return ret;
9434 }
9435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
9436         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
9437         *res_ptr = LDKFilter_init(env, clz, o);
9438         return (uint64_t)res_ptr;
9439 }
9440 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) {
9441         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9442         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9443         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
9444         unsigned char txid_arr[32];
9445         CHECK((*env)->GetArrayLength(env, txid) == 32);
9446         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
9447         unsigned char (*txid_ref)[32] = &txid_arr;
9448         LDKu8slice script_pubkey_ref;
9449         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
9450         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
9451         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
9452         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
9453 }
9454
9455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
9456         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9457         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9458         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
9459         LDKWatchedOutput output_conv;
9460         output_conv.inner = (void*)(output & (~1));
9461         output_conv.is_owned = (output & 1) || (output == 0);
9462         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
9463         output_conv = WatchedOutput_clone(&output_conv);
9464         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9465         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
9466         uintptr_t ret_ref = (uintptr_t)ret_copy;
9467         return ret_ref;
9468 }
9469
9470 static jclass LDKCOption_FilterZ_Some_class = NULL;
9471 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
9472 static jclass LDKCOption_FilterZ_None_class = NULL;
9473 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
9474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
9475         LDKCOption_FilterZ_Some_class =
9476                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
9477         CHECK(LDKCOption_FilterZ_Some_class != NULL);
9478         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
9479         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
9480         LDKCOption_FilterZ_None_class =
9481                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
9482         CHECK(LDKCOption_FilterZ_None_class != NULL);
9483         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
9484         CHECK(LDKCOption_FilterZ_None_meth != NULL);
9485 }
9486 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9487         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
9488         switch(obj->tag) {
9489                 case LDKCOption_FilterZ_Some: {
9490                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
9491                         *some_ret = obj->some;
9492                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
9493                         if ((*some_ret).free == LDKFilter_JCalls_free) {
9494                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9495                                 LDKFilter_JCalls_cloned(&(*some_ret));
9496                         }
9497                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (uintptr_t)some_ret);
9498                 }
9499                 case LDKCOption_FilterZ_None: {
9500                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
9501                 }
9502                 default: abort();
9503         }
9504 }
9505 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
9506 CHECK(owner->result_ok);
9507         return &*owner->contents.result;
9508 }
9509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9510         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
9511         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
9512         uintptr_t ret_ref = 0;
9513         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9514         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9516         ret_ref = (uintptr_t)ret_var.inner & ~1;
9517         return ret_ref;
9518 }
9519
9520 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
9521 CHECK(!owner->result_ok);
9522         return *owner->contents.err;
9523 }
9524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9525         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
9526         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
9527 }
9528
9529 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
9530         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
9531         for (size_t i = 0; i < ret.datalen; i++) {
9532                 ret.data[i] = OutPoint_clone(&orig->data[i]);
9533         }
9534         return ret;
9535 }
9536 typedef struct LDKMessageSendEventsProvider_JCalls {
9537         atomic_size_t refcnt;
9538         JavaVM *vm;
9539         jweak o;
9540         jmethodID get_and_clear_pending_msg_events_meth;
9541 } LDKMessageSendEventsProvider_JCalls;
9542 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
9543         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
9544         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9545                 JNIEnv *env;
9546                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9547                 if (get_jenv_res == JNI_EDETACHED) {
9548                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9549                 } else {
9550                         DO_ASSERT(get_jenv_res == JNI_OK);
9551                 }
9552                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9553                 if (get_jenv_res == JNI_EDETACHED) {
9554                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9555                 }
9556                 FREE(j_calls);
9557         }
9558 }
9559 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
9560         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
9561         JNIEnv *env;
9562         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9563         if (get_jenv_res == JNI_EDETACHED) {
9564                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9565         } else {
9566                 DO_ASSERT(get_jenv_res == JNI_OK);
9567         }
9568         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9569         CHECK(obj != NULL);
9570         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
9571         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9572                 (*env)->ExceptionDescribe(env);
9573                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
9574         }
9575         LDKCVec_MessageSendEventZ ret_constr;
9576         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9577         if (ret_constr.datalen > 0)
9578                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
9579         else
9580                 ret_constr.data = NULL;
9581         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9582         for (size_t s = 0; s < ret_constr.datalen; s++) {
9583                 int64_t ret_conv_18 = ret_vals[s];
9584                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
9585                 CHECK_ACCESS(ret_conv_18_ptr);
9586                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
9587                 FREE((void*)ret_conv_18);
9588                 ret_constr.data[s] = ret_conv_18_conv;
9589         }
9590         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9591         if (get_jenv_res == JNI_EDETACHED) {
9592                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9593         }
9594         return ret_constr;
9595 }
9596 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
9597         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
9598         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9599 }
9600 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
9601         jclass c = (*env)->GetObjectClass(env, o);
9602         CHECK(c != NULL);
9603         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
9604         atomic_init(&calls->refcnt, 1);
9605         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9606         calls->o = (*env)->NewWeakGlobalRef(env, o);
9607         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
9608         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
9609
9610         LDKMessageSendEventsProvider ret = {
9611                 .this_arg = (void*) calls,
9612                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
9613                 .free = LDKMessageSendEventsProvider_JCalls_free,
9614         };
9615         return ret;
9616 }
9617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
9618         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
9619         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
9620         return (uint64_t)res_ptr;
9621 }
9622 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
9623         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9624         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9625         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
9626         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
9627         int64_tArray ret_arr = NULL;
9628         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9629         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9630         for (size_t s = 0; s < ret_var.datalen; s++) {
9631                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
9632                 *ret_conv_18_copy = ret_var.data[s];
9633                 uintptr_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
9634                 ret_arr_ptr[s] = ret_conv_18_ref;
9635         }
9636         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9637         FREE(ret_var.data);
9638         return ret_arr;
9639 }
9640
9641 typedef struct LDKEventHandler_JCalls {
9642         atomic_size_t refcnt;
9643         JavaVM *vm;
9644         jweak o;
9645         jmethodID handle_event_meth;
9646 } LDKEventHandler_JCalls;
9647 static void LDKEventHandler_JCalls_free(void* this_arg) {
9648         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
9649         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9650                 JNIEnv *env;
9651                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9652                 if (get_jenv_res == JNI_EDETACHED) {
9653                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9654                 } else {
9655                         DO_ASSERT(get_jenv_res == JNI_OK);
9656                 }
9657                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9658                 if (get_jenv_res == JNI_EDETACHED) {
9659                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9660                 }
9661                 FREE(j_calls);
9662         }
9663 }
9664 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
9665         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
9666         JNIEnv *env;
9667         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9668         if (get_jenv_res == JNI_EDETACHED) {
9669                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9670         } else {
9671                 DO_ASSERT(get_jenv_res == JNI_OK);
9672         }
9673         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
9674         *ret_event = Event_clone(event);
9675         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9676         CHECK(obj != NULL);
9677         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (uintptr_t)ret_event);
9678         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9679                 (*env)->ExceptionDescribe(env);
9680                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
9681         }
9682         if (get_jenv_res == JNI_EDETACHED) {
9683                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9684         }
9685 }
9686 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
9687         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
9688         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9689 }
9690 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
9691         jclass c = (*env)->GetObjectClass(env, o);
9692         CHECK(c != NULL);
9693         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
9694         atomic_init(&calls->refcnt, 1);
9695         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9696         calls->o = (*env)->NewWeakGlobalRef(env, o);
9697         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
9698         CHECK(calls->handle_event_meth != NULL);
9699
9700         LDKEventHandler ret = {
9701                 .this_arg = (void*) calls,
9702                 .handle_event = handle_event_LDKEventHandler_jcall,
9703                 .free = LDKEventHandler_JCalls_free,
9704         };
9705         return ret;
9706 }
9707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
9708         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
9709         *res_ptr = LDKEventHandler_init(env, clz, o);
9710         return (uint64_t)res_ptr;
9711 }
9712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
9713         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9714         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9715         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
9716         LDKEvent* event_conv = (LDKEvent*)event;
9717         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
9718 }
9719
9720 typedef struct LDKEventsProvider_JCalls {
9721         atomic_size_t refcnt;
9722         JavaVM *vm;
9723         jweak o;
9724         jmethodID process_pending_events_meth;
9725 } LDKEventsProvider_JCalls;
9726 static void LDKEventsProvider_JCalls_free(void* this_arg) {
9727         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
9728         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9729                 JNIEnv *env;
9730                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9731                 if (get_jenv_res == JNI_EDETACHED) {
9732                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9733                 } else {
9734                         DO_ASSERT(get_jenv_res == JNI_OK);
9735                 }
9736                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9737                 if (get_jenv_res == JNI_EDETACHED) {
9738                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9739                 }
9740                 FREE(j_calls);
9741         }
9742 }
9743 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
9744         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
9745         JNIEnv *env;
9746         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9747         if (get_jenv_res == JNI_EDETACHED) {
9748                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9749         } else {
9750                 DO_ASSERT(get_jenv_res == JNI_OK);
9751         }
9752         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
9753         *handler_ret = handler;
9754         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9755         CHECK(obj != NULL);
9756         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uintptr_t)handler_ret);
9757         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9758                 (*env)->ExceptionDescribe(env);
9759                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
9760         }
9761         if (get_jenv_res == JNI_EDETACHED) {
9762                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9763         }
9764 }
9765 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
9766         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
9767         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9768 }
9769 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
9770         jclass c = (*env)->GetObjectClass(env, o);
9771         CHECK(c != NULL);
9772         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
9773         atomic_init(&calls->refcnt, 1);
9774         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9775         calls->o = (*env)->NewWeakGlobalRef(env, o);
9776         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
9777         CHECK(calls->process_pending_events_meth != NULL);
9778
9779         LDKEventsProvider ret = {
9780                 .this_arg = (void*) calls,
9781                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
9782                 .free = LDKEventsProvider_JCalls_free,
9783         };
9784         return ret;
9785 }
9786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
9787         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
9788         *res_ptr = LDKEventsProvider_init(env, clz, o);
9789         return (uint64_t)res_ptr;
9790 }
9791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
9792         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9793         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9794         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
9795         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
9796         CHECK_ACCESS(handler_ptr);
9797         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
9798         if (handler_conv.free == LDKEventHandler_JCalls_free) {
9799                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9800                 LDKEventHandler_JCalls_cloned(&handler_conv);
9801         }
9802         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
9803 }
9804
9805 typedef struct LDKListen_JCalls {
9806         atomic_size_t refcnt;
9807         JavaVM *vm;
9808         jweak o;
9809         jmethodID block_connected_meth;
9810         jmethodID block_disconnected_meth;
9811 } LDKListen_JCalls;
9812 static void LDKListen_JCalls_free(void* this_arg) {
9813         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9814         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9815                 JNIEnv *env;
9816                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9817                 if (get_jenv_res == JNI_EDETACHED) {
9818                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9819                 } else {
9820                         DO_ASSERT(get_jenv_res == JNI_OK);
9821                 }
9822                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9823                 if (get_jenv_res == JNI_EDETACHED) {
9824                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9825                 }
9826                 FREE(j_calls);
9827         }
9828 }
9829 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
9830         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9831         JNIEnv *env;
9832         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9833         if (get_jenv_res == JNI_EDETACHED) {
9834                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9835         } else {
9836                 DO_ASSERT(get_jenv_res == JNI_OK);
9837         }
9838         LDKu8slice block_var = block;
9839         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
9840         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
9841         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9842         CHECK(obj != NULL);
9843         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
9844         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9845                 (*env)->ExceptionDescribe(env);
9846                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
9847         }
9848         if (get_jenv_res == JNI_EDETACHED) {
9849                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9850         }
9851 }
9852 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
9853         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9854         JNIEnv *env;
9855         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9856         if (get_jenv_res == JNI_EDETACHED) {
9857                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9858         } else {
9859                 DO_ASSERT(get_jenv_res == JNI_OK);
9860         }
9861         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
9862         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
9863         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9864         CHECK(obj != NULL);
9865         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
9866         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9867                 (*env)->ExceptionDescribe(env);
9868                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
9869         }
9870         if (get_jenv_res == JNI_EDETACHED) {
9871                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9872         }
9873 }
9874 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
9875         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
9876         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9877 }
9878 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
9879         jclass c = (*env)->GetObjectClass(env, o);
9880         CHECK(c != NULL);
9881         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
9882         atomic_init(&calls->refcnt, 1);
9883         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9884         calls->o = (*env)->NewWeakGlobalRef(env, o);
9885         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
9886         CHECK(calls->block_connected_meth != NULL);
9887         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
9888         CHECK(calls->block_disconnected_meth != NULL);
9889
9890         LDKListen ret = {
9891                 .this_arg = (void*) calls,
9892                 .block_connected = block_connected_LDKListen_jcall,
9893                 .block_disconnected = block_disconnected_LDKListen_jcall,
9894                 .free = LDKListen_JCalls_free,
9895         };
9896         return ret;
9897 }
9898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
9899         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
9900         *res_ptr = LDKListen_init(env, clz, o);
9901         return (uint64_t)res_ptr;
9902 }
9903 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) {
9904         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9905         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9906         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
9907         LDKu8slice block_ref;
9908         block_ref.datalen = (*env)->GetArrayLength(env, block);
9909         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
9910         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
9911         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
9912 }
9913
9914 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) {
9915         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9916         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9917         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
9918         unsigned char header_arr[80];
9919         CHECK((*env)->GetArrayLength(env, header) == 80);
9920         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
9921         unsigned char (*header_ref)[80] = &header_arr;
9922         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
9923 }
9924
9925 typedef struct LDKConfirm_JCalls {
9926         atomic_size_t refcnt;
9927         JavaVM *vm;
9928         jweak o;
9929         jmethodID transactions_confirmed_meth;
9930         jmethodID transaction_unconfirmed_meth;
9931         jmethodID best_block_updated_meth;
9932         jmethodID get_relevant_txids_meth;
9933 } LDKConfirm_JCalls;
9934 static void LDKConfirm_JCalls_free(void* this_arg) {
9935         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9936         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9937                 JNIEnv *env;
9938                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9939                 if (get_jenv_res == JNI_EDETACHED) {
9940                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9941                 } else {
9942                         DO_ASSERT(get_jenv_res == JNI_OK);
9943                 }
9944                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9945                 if (get_jenv_res == JNI_EDETACHED) {
9946                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9947                 }
9948                 FREE(j_calls);
9949         }
9950 }
9951 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
9952         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9953         JNIEnv *env;
9954         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9955         if (get_jenv_res == JNI_EDETACHED) {
9956                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9957         } else {
9958                 DO_ASSERT(get_jenv_res == JNI_OK);
9959         }
9960         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
9961         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
9962         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
9963         int64_tArray txdata_arr = NULL;
9964         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
9965         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
9966         for (size_t c = 0; c < txdata_var.datalen; c++) {
9967                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9968                 *txdata_conv_28_conv = txdata_var.data[c];
9969                 txdata_arr_ptr[c] = ((uintptr_t)txdata_conv_28_conv);
9970         }
9971         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
9972         FREE(txdata_var.data);
9973         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9974         CHECK(obj != NULL);
9975         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
9976         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9977                 (*env)->ExceptionDescribe(env);
9978                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
9979         }
9980         if (get_jenv_res == JNI_EDETACHED) {
9981                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9982         }
9983 }
9984 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
9985         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9986         JNIEnv *env;
9987         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9988         if (get_jenv_res == JNI_EDETACHED) {
9989                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9990         } else {
9991                 DO_ASSERT(get_jenv_res == JNI_OK);
9992         }
9993         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
9994         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
9995         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9996         CHECK(obj != NULL);
9997         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
9998         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9999                 (*env)->ExceptionDescribe(env);
10000                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
10001         }
10002         if (get_jenv_res == JNI_EDETACHED) {
10003                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10004         }
10005 }
10006 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
10007         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10008         JNIEnv *env;
10009         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10010         if (get_jenv_res == JNI_EDETACHED) {
10011                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10012         } else {
10013                 DO_ASSERT(get_jenv_res == JNI_OK);
10014         }
10015         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10016         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10017         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10018         CHECK(obj != NULL);
10019         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
10020         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10021                 (*env)->ExceptionDescribe(env);
10022                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
10023         }
10024         if (get_jenv_res == JNI_EDETACHED) {
10025                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10026         }
10027 }
10028 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
10029         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10030         JNIEnv *env;
10031         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10032         if (get_jenv_res == JNI_EDETACHED) {
10033                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10034         } else {
10035                 DO_ASSERT(get_jenv_res == JNI_OK);
10036         }
10037         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10038         CHECK(obj != NULL);
10039         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
10040         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10041                 (*env)->ExceptionDescribe(env);
10042                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
10043         }
10044         LDKCVec_TxidZ ret_constr;
10045         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10046         if (ret_constr.datalen > 0)
10047                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
10048         else
10049                 ret_constr.data = NULL;
10050         for (size_t i = 0; i < ret_constr.datalen; i++) {
10051                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
10052                 LDKThirtyTwoBytes ret_conv_8_ref;
10053                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
10054                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
10055                 ret_constr.data[i] = ret_conv_8_ref;
10056         }
10057         if (get_jenv_res == JNI_EDETACHED) {
10058                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10059         }
10060         return ret_constr;
10061 }
10062 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
10063         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
10064         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10065 }
10066 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
10067         jclass c = (*env)->GetObjectClass(env, o);
10068         CHECK(c != NULL);
10069         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
10070         atomic_init(&calls->refcnt, 1);
10071         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10072         calls->o = (*env)->NewWeakGlobalRef(env, o);
10073         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
10074         CHECK(calls->transactions_confirmed_meth != NULL);
10075         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
10076         CHECK(calls->transaction_unconfirmed_meth != NULL);
10077         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
10078         CHECK(calls->best_block_updated_meth != NULL);
10079         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
10080         CHECK(calls->get_relevant_txids_meth != NULL);
10081
10082         LDKConfirm ret = {
10083                 .this_arg = (void*) calls,
10084                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
10085                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
10086                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
10087                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
10088                 .free = LDKConfirm_JCalls_free,
10089         };
10090         return ret;
10091 }
10092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
10093         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
10094         *res_ptr = LDKConfirm_init(env, clz, o);
10095         return (uint64_t)res_ptr;
10096 }
10097 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) {
10098         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10099         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10100         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10101         unsigned char header_arr[80];
10102         CHECK((*env)->GetArrayLength(env, header) == 80);
10103         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10104         unsigned char (*header_ref)[80] = &header_arr;
10105         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
10106         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
10107         if (txdata_constr.datalen > 0)
10108                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10109         else
10110                 txdata_constr.data = NULL;
10111         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
10112         for (size_t c = 0; c < txdata_constr.datalen; c++) {
10113                 int64_t txdata_conv_28 = txdata_vals[c];
10114                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
10115                 CHECK_ACCESS(txdata_conv_28_ptr);
10116                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
10117                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
10118                 txdata_constr.data[c] = txdata_conv_28_conv;
10119         }
10120         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
10121         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
10122 }
10123
10124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
10125         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10126         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10127         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10128         unsigned char txid_arr[32];
10129         CHECK((*env)->GetArrayLength(env, txid) == 32);
10130         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
10131         unsigned char (*txid_ref)[32] = &txid_arr;
10132         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
10133 }
10134
10135 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) {
10136         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10137         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10138         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10139         unsigned char header_arr[80];
10140         CHECK((*env)->GetArrayLength(env, header) == 80);
10141         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10142         unsigned char (*header_ref)[80] = &header_arr;
10143         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
10144 }
10145
10146 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
10147         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10148         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10149         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10150         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
10151         jobjectArray ret_arr = NULL;
10152         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
10153         ;
10154         for (size_t i = 0; i < ret_var.datalen; i++) {
10155                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
10156                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
10157                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
10158         }
10159         
10160         FREE(ret_var.data);
10161         return ret_arr;
10162 }
10163
10164 typedef struct LDKPersist_JCalls {
10165         atomic_size_t refcnt;
10166         JavaVM *vm;
10167         jweak o;
10168         jmethodID persist_new_channel_meth;
10169         jmethodID update_persisted_channel_meth;
10170 } LDKPersist_JCalls;
10171 static void LDKPersist_JCalls_free(void* this_arg) {
10172         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10173         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10174                 JNIEnv *env;
10175                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10176                 if (get_jenv_res == JNI_EDETACHED) {
10177                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10178                 } else {
10179                         DO_ASSERT(get_jenv_res == JNI_OK);
10180                 }
10181                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10182                 if (get_jenv_res == JNI_EDETACHED) {
10183                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10184                 }
10185                 FREE(j_calls);
10186         }
10187 }
10188 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
10189         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10190         JNIEnv *env;
10191         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10192         if (get_jenv_res == JNI_EDETACHED) {
10193                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10194         } else {
10195                 DO_ASSERT(get_jenv_res == JNI_OK);
10196         }
10197         LDKOutPoint channel_id_var = channel_id;
10198         uintptr_t channel_id_ref = 0;
10199         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10200         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10201         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
10202         channel_id_ref = (uintptr_t)channel_id_var.inner;
10203         if (channel_id_var.is_owned) {
10204                 channel_id_ref |= 1;
10205         }
10206         LDKChannelMonitor data_var = *data;
10207         uintptr_t data_ref = 0;
10208         data_var = ChannelMonitor_clone(data);
10209         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10210         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10211         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
10212         data_ref = (uintptr_t)data_var.inner;
10213         if (data_var.is_owned) {
10214                 data_ref |= 1;
10215         }
10216         LDKMonitorUpdateId update_id_var = update_id;
10217         uintptr_t update_id_ref = 0;
10218         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10219         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10220         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
10221         update_id_ref = (uintptr_t)update_id_var.inner;
10222         if (update_id_var.is_owned) {
10223                 update_id_ref |= 1;
10224         }
10225         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10226         CHECK(obj != NULL);
10227         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
10228         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10229                 (*env)->ExceptionDescribe(env);
10230                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
10231         }
10232         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10233         CHECK_ACCESS(ret_ptr);
10234         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
10235         FREE((void*)ret);
10236         if (get_jenv_res == JNI_EDETACHED) {
10237                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10238         }
10239         return ret_conv;
10240 }
10241 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
10242         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10243         JNIEnv *env;
10244         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10245         if (get_jenv_res == JNI_EDETACHED) {
10246                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10247         } else {
10248                 DO_ASSERT(get_jenv_res == JNI_OK);
10249         }
10250         LDKOutPoint channel_id_var = channel_id;
10251         uintptr_t channel_id_ref = 0;
10252         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10253         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10254         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
10255         channel_id_ref = (uintptr_t)channel_id_var.inner;
10256         if (channel_id_var.is_owned) {
10257                 channel_id_ref |= 1;
10258         }
10259         LDKChannelMonitorUpdate update_var = *update;
10260         uintptr_t update_ref = 0;
10261         if ((uintptr_t)update_var.inner > 4096) {
10262                 update_var = ChannelMonitorUpdate_clone(update);
10263                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10264                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10265         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
10266                 update_ref = (uintptr_t)update_var.inner;
10267                 if (update_var.is_owned) {
10268                         update_ref |= 1;
10269                 }
10270         }
10271         LDKChannelMonitor data_var = *data;
10272         uintptr_t data_ref = 0;
10273         data_var = ChannelMonitor_clone(data);
10274         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10275         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10276         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
10277         data_ref = (uintptr_t)data_var.inner;
10278         if (data_var.is_owned) {
10279                 data_ref |= 1;
10280         }
10281         LDKMonitorUpdateId update_id_var = update_id;
10282         uintptr_t update_id_ref = 0;
10283         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10284         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10285         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
10286         update_id_ref = (uintptr_t)update_id_var.inner;
10287         if (update_id_var.is_owned) {
10288                 update_id_ref |= 1;
10289         }
10290         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10291         CHECK(obj != NULL);
10292         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
10293         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10294                 (*env)->ExceptionDescribe(env);
10295                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
10296         }
10297         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10298         CHECK_ACCESS(ret_ptr);
10299         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
10300         FREE((void*)ret);
10301         if (get_jenv_res == JNI_EDETACHED) {
10302                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10303         }
10304         return ret_conv;
10305 }
10306 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
10307         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
10308         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10309 }
10310 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
10311         jclass c = (*env)->GetObjectClass(env, o);
10312         CHECK(c != NULL);
10313         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
10314         atomic_init(&calls->refcnt, 1);
10315         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10316         calls->o = (*env)->NewWeakGlobalRef(env, o);
10317         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
10318         CHECK(calls->persist_new_channel_meth != NULL);
10319         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
10320         CHECK(calls->update_persisted_channel_meth != NULL);
10321
10322         LDKPersist ret = {
10323                 .this_arg = (void*) calls,
10324                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
10325                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
10326                 .free = LDKPersist_JCalls_free,
10327         };
10328         return ret;
10329 }
10330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
10331         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
10332         *res_ptr = LDKPersist_init(env, clz, o);
10333         return (uint64_t)res_ptr;
10334 }
10335 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) {
10336         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10337         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10338         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
10339         LDKOutPoint channel_id_conv;
10340         channel_id_conv.inner = (void*)(channel_id & (~1));
10341         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
10342         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
10343         channel_id_conv = OutPoint_clone(&channel_id_conv);
10344         LDKChannelMonitor data_conv;
10345         data_conv.inner = (void*)(data & (~1));
10346         data_conv.is_owned = false;
10347         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
10348         LDKMonitorUpdateId update_id_conv;
10349         update_id_conv.inner = (void*)(update_id & (~1));
10350         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
10351         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
10352         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
10353         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10354         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
10355         return (uintptr_t)ret_conv;
10356 }
10357
10358 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) {
10359         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10360         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10361         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
10362         LDKOutPoint channel_id_conv;
10363         channel_id_conv.inner = (void*)(channel_id & (~1));
10364         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
10365         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
10366         channel_id_conv = OutPoint_clone(&channel_id_conv);
10367         LDKChannelMonitorUpdate update_conv;
10368         update_conv.inner = (void*)(update & (~1));
10369         update_conv.is_owned = false;
10370         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
10371         LDKChannelMonitor data_conv;
10372         data_conv.inner = (void*)(data & (~1));
10373         data_conv.is_owned = false;
10374         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
10375         LDKMonitorUpdateId update_id_conv;
10376         update_id_conv.inner = (void*)(update_id & (~1));
10377         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
10378         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
10379         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
10380         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10381         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
10382         return (uintptr_t)ret_conv;
10383 }
10384
10385 typedef struct LDKChannelMessageHandler_JCalls {
10386         atomic_size_t refcnt;
10387         JavaVM *vm;
10388         jweak o;
10389         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
10390         jmethodID handle_open_channel_meth;
10391         jmethodID handle_accept_channel_meth;
10392         jmethodID handle_funding_created_meth;
10393         jmethodID handle_funding_signed_meth;
10394         jmethodID handle_funding_locked_meth;
10395         jmethodID handle_shutdown_meth;
10396         jmethodID handle_closing_signed_meth;
10397         jmethodID handle_update_add_htlc_meth;
10398         jmethodID handle_update_fulfill_htlc_meth;
10399         jmethodID handle_update_fail_htlc_meth;
10400         jmethodID handle_update_fail_malformed_htlc_meth;
10401         jmethodID handle_commitment_signed_meth;
10402         jmethodID handle_revoke_and_ack_meth;
10403         jmethodID handle_update_fee_meth;
10404         jmethodID handle_announcement_signatures_meth;
10405         jmethodID peer_disconnected_meth;
10406         jmethodID peer_connected_meth;
10407         jmethodID handle_channel_reestablish_meth;
10408         jmethodID handle_channel_update_meth;
10409         jmethodID handle_error_meth;
10410 } LDKChannelMessageHandler_JCalls;
10411 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
10412         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10413         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10414                 JNIEnv *env;
10415                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10416                 if (get_jenv_res == JNI_EDETACHED) {
10417                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10418                 } else {
10419                         DO_ASSERT(get_jenv_res == JNI_OK);
10420                 }
10421                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10422                 if (get_jenv_res == JNI_EDETACHED) {
10423                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10424                 }
10425                 FREE(j_calls);
10426         }
10427 }
10428 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
10429         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10430         JNIEnv *env;
10431         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10432         if (get_jenv_res == JNI_EDETACHED) {
10433                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10434         } else {
10435                 DO_ASSERT(get_jenv_res == JNI_OK);
10436         }
10437         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10438         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10439         LDKInitFeatures their_features_var = their_features;
10440         uintptr_t their_features_ref = 0;
10441         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10442         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10443         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10444         their_features_ref = (uintptr_t)their_features_var.inner;
10445         if (their_features_var.is_owned) {
10446                 their_features_ref |= 1;
10447         }
10448         LDKOpenChannel msg_var = *msg;
10449         uintptr_t msg_ref = 0;
10450         msg_var = OpenChannel_clone(msg);
10451         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10452         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10453         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10454         msg_ref = (uintptr_t)msg_var.inner;
10455         if (msg_var.is_owned) {
10456                 msg_ref |= 1;
10457         }
10458         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10459         CHECK(obj != NULL);
10460         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
10461         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10462                 (*env)->ExceptionDescribe(env);
10463                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
10464         }
10465         if (get_jenv_res == JNI_EDETACHED) {
10466                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10467         }
10468 }
10469 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
10470         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10471         JNIEnv *env;
10472         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10473         if (get_jenv_res == JNI_EDETACHED) {
10474                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10475         } else {
10476                 DO_ASSERT(get_jenv_res == JNI_OK);
10477         }
10478         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10479         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10480         LDKInitFeatures their_features_var = their_features;
10481         uintptr_t their_features_ref = 0;
10482         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10483         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10484         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10485         their_features_ref = (uintptr_t)their_features_var.inner;
10486         if (their_features_var.is_owned) {
10487                 their_features_ref |= 1;
10488         }
10489         LDKAcceptChannel msg_var = *msg;
10490         uintptr_t msg_ref = 0;
10491         msg_var = AcceptChannel_clone(msg);
10492         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10493         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10494         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10495         msg_ref = (uintptr_t)msg_var.inner;
10496         if (msg_var.is_owned) {
10497                 msg_ref |= 1;
10498         }
10499         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10500         CHECK(obj != NULL);
10501         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
10502         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10503                 (*env)->ExceptionDescribe(env);
10504                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
10505         }
10506         if (get_jenv_res == JNI_EDETACHED) {
10507                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10508         }
10509 }
10510 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
10511         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10512         JNIEnv *env;
10513         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10514         if (get_jenv_res == JNI_EDETACHED) {
10515                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10516         } else {
10517                 DO_ASSERT(get_jenv_res == JNI_OK);
10518         }
10519         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10520         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10521         LDKFundingCreated msg_var = *msg;
10522         uintptr_t msg_ref = 0;
10523         msg_var = FundingCreated_clone(msg);
10524         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10525         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10526         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10527         msg_ref = (uintptr_t)msg_var.inner;
10528         if (msg_var.is_owned) {
10529                 msg_ref |= 1;
10530         }
10531         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10532         CHECK(obj != NULL);
10533         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
10534         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10535                 (*env)->ExceptionDescribe(env);
10536                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
10537         }
10538         if (get_jenv_res == JNI_EDETACHED) {
10539                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10540         }
10541 }
10542 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
10543         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10544         JNIEnv *env;
10545         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10546         if (get_jenv_res == JNI_EDETACHED) {
10547                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10548         } else {
10549                 DO_ASSERT(get_jenv_res == JNI_OK);
10550         }
10551         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10552         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10553         LDKFundingSigned msg_var = *msg;
10554         uintptr_t msg_ref = 0;
10555         msg_var = FundingSigned_clone(msg);
10556         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10557         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10558         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10559         msg_ref = (uintptr_t)msg_var.inner;
10560         if (msg_var.is_owned) {
10561                 msg_ref |= 1;
10562         }
10563         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10564         CHECK(obj != NULL);
10565         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
10566         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10567                 (*env)->ExceptionDescribe(env);
10568                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
10569         }
10570         if (get_jenv_res == JNI_EDETACHED) {
10571                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10572         }
10573 }
10574 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
10575         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10576         JNIEnv *env;
10577         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10578         if (get_jenv_res == JNI_EDETACHED) {
10579                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10580         } else {
10581                 DO_ASSERT(get_jenv_res == JNI_OK);
10582         }
10583         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10584         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10585         LDKFundingLocked msg_var = *msg;
10586         uintptr_t msg_ref = 0;
10587         msg_var = FundingLocked_clone(msg);
10588         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10589         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10590         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10591         msg_ref = (uintptr_t)msg_var.inner;
10592         if (msg_var.is_owned) {
10593                 msg_ref |= 1;
10594         }
10595         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10596         CHECK(obj != NULL);
10597         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
10598         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10599                 (*env)->ExceptionDescribe(env);
10600                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
10601         }
10602         if (get_jenv_res == JNI_EDETACHED) {
10603                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10604         }
10605 }
10606 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
10607         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10608         JNIEnv *env;
10609         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10610         if (get_jenv_res == JNI_EDETACHED) {
10611                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10612         } else {
10613                 DO_ASSERT(get_jenv_res == JNI_OK);
10614         }
10615         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10616         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10617         LDKInitFeatures their_features_var = *their_features;
10618         uintptr_t their_features_ref = 0;
10619         their_features_var = InitFeatures_clone(their_features);
10620         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10621         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10622         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10623         their_features_ref = (uintptr_t)their_features_var.inner;
10624         if (their_features_var.is_owned) {
10625                 their_features_ref |= 1;
10626         }
10627         LDKShutdown msg_var = *msg;
10628         uintptr_t msg_ref = 0;
10629         msg_var = Shutdown_clone(msg);
10630         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10631         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10632         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10633         msg_ref = (uintptr_t)msg_var.inner;
10634         if (msg_var.is_owned) {
10635                 msg_ref |= 1;
10636         }
10637         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10638         CHECK(obj != NULL);
10639         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
10640         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10641                 (*env)->ExceptionDescribe(env);
10642                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
10643         }
10644         if (get_jenv_res == JNI_EDETACHED) {
10645                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10646         }
10647 }
10648 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
10649         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10650         JNIEnv *env;
10651         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10652         if (get_jenv_res == JNI_EDETACHED) {
10653                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10654         } else {
10655                 DO_ASSERT(get_jenv_res == JNI_OK);
10656         }
10657         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10658         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10659         LDKClosingSigned msg_var = *msg;
10660         uintptr_t msg_ref = 0;
10661         msg_var = ClosingSigned_clone(msg);
10662         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10663         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10664         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10665         msg_ref = (uintptr_t)msg_var.inner;
10666         if (msg_var.is_owned) {
10667                 msg_ref |= 1;
10668         }
10669         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10670         CHECK(obj != NULL);
10671         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
10672         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10673                 (*env)->ExceptionDescribe(env);
10674                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
10675         }
10676         if (get_jenv_res == JNI_EDETACHED) {
10677                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10678         }
10679 }
10680 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
10681         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10682         JNIEnv *env;
10683         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10684         if (get_jenv_res == JNI_EDETACHED) {
10685                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10686         } else {
10687                 DO_ASSERT(get_jenv_res == JNI_OK);
10688         }
10689         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10690         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10691         LDKUpdateAddHTLC msg_var = *msg;
10692         uintptr_t msg_ref = 0;
10693         msg_var = UpdateAddHTLC_clone(msg);
10694         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10695         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10696         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10697         msg_ref = (uintptr_t)msg_var.inner;
10698         if (msg_var.is_owned) {
10699                 msg_ref |= 1;
10700         }
10701         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10702         CHECK(obj != NULL);
10703         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
10704         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10705                 (*env)->ExceptionDescribe(env);
10706                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
10707         }
10708         if (get_jenv_res == JNI_EDETACHED) {
10709                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10710         }
10711 }
10712 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
10713         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10714         JNIEnv *env;
10715         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10716         if (get_jenv_res == JNI_EDETACHED) {
10717                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10718         } else {
10719                 DO_ASSERT(get_jenv_res == JNI_OK);
10720         }
10721         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10722         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10723         LDKUpdateFulfillHTLC msg_var = *msg;
10724         uintptr_t msg_ref = 0;
10725         msg_var = UpdateFulfillHTLC_clone(msg);
10726         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10727         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10728         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10729         msg_ref = (uintptr_t)msg_var.inner;
10730         if (msg_var.is_owned) {
10731                 msg_ref |= 1;
10732         }
10733         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10734         CHECK(obj != NULL);
10735         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
10736         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10737                 (*env)->ExceptionDescribe(env);
10738                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
10739         }
10740         if (get_jenv_res == JNI_EDETACHED) {
10741                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10742         }
10743 }
10744 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
10745         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10746         JNIEnv *env;
10747         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10748         if (get_jenv_res == JNI_EDETACHED) {
10749                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10750         } else {
10751                 DO_ASSERT(get_jenv_res == JNI_OK);
10752         }
10753         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10754         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10755         LDKUpdateFailHTLC msg_var = *msg;
10756         uintptr_t msg_ref = 0;
10757         msg_var = UpdateFailHTLC_clone(msg);
10758         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10759         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10760         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10761         msg_ref = (uintptr_t)msg_var.inner;
10762         if (msg_var.is_owned) {
10763                 msg_ref |= 1;
10764         }
10765         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10766         CHECK(obj != NULL);
10767         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
10768         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10769                 (*env)->ExceptionDescribe(env);
10770                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
10771         }
10772         if (get_jenv_res == JNI_EDETACHED) {
10773                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10774         }
10775 }
10776 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
10777         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10778         JNIEnv *env;
10779         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10780         if (get_jenv_res == JNI_EDETACHED) {
10781                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10782         } else {
10783                 DO_ASSERT(get_jenv_res == JNI_OK);
10784         }
10785         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10786         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10787         LDKUpdateFailMalformedHTLC msg_var = *msg;
10788         uintptr_t msg_ref = 0;
10789         msg_var = UpdateFailMalformedHTLC_clone(msg);
10790         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10791         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10792         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10793         msg_ref = (uintptr_t)msg_var.inner;
10794         if (msg_var.is_owned) {
10795                 msg_ref |= 1;
10796         }
10797         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10798         CHECK(obj != NULL);
10799         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
10800         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10801                 (*env)->ExceptionDescribe(env);
10802                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
10803         }
10804         if (get_jenv_res == JNI_EDETACHED) {
10805                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10806         }
10807 }
10808 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
10809         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10810         JNIEnv *env;
10811         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10812         if (get_jenv_res == JNI_EDETACHED) {
10813                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10814         } else {
10815                 DO_ASSERT(get_jenv_res == JNI_OK);
10816         }
10817         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10818         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10819         LDKCommitmentSigned msg_var = *msg;
10820         uintptr_t msg_ref = 0;
10821         msg_var = CommitmentSigned_clone(msg);
10822         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10823         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10824         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10825         msg_ref = (uintptr_t)msg_var.inner;
10826         if (msg_var.is_owned) {
10827                 msg_ref |= 1;
10828         }
10829         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10830         CHECK(obj != NULL);
10831         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
10832         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10833                 (*env)->ExceptionDescribe(env);
10834                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
10835         }
10836         if (get_jenv_res == JNI_EDETACHED) {
10837                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10838         }
10839 }
10840 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
10841         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10842         JNIEnv *env;
10843         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10844         if (get_jenv_res == JNI_EDETACHED) {
10845                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10846         } else {
10847                 DO_ASSERT(get_jenv_res == JNI_OK);
10848         }
10849         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10850         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10851         LDKRevokeAndACK msg_var = *msg;
10852         uintptr_t msg_ref = 0;
10853         msg_var = RevokeAndACK_clone(msg);
10854         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10855         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10856         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10857         msg_ref = (uintptr_t)msg_var.inner;
10858         if (msg_var.is_owned) {
10859                 msg_ref |= 1;
10860         }
10861         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10862         CHECK(obj != NULL);
10863         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
10864         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10865                 (*env)->ExceptionDescribe(env);
10866                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
10867         }
10868         if (get_jenv_res == JNI_EDETACHED) {
10869                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10870         }
10871 }
10872 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
10873         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10874         JNIEnv *env;
10875         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10876         if (get_jenv_res == JNI_EDETACHED) {
10877                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10878         } else {
10879                 DO_ASSERT(get_jenv_res == JNI_OK);
10880         }
10881         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10882         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10883         LDKUpdateFee msg_var = *msg;
10884         uintptr_t msg_ref = 0;
10885         msg_var = UpdateFee_clone(msg);
10886         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10887         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10888         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10889         msg_ref = (uintptr_t)msg_var.inner;
10890         if (msg_var.is_owned) {
10891                 msg_ref |= 1;
10892         }
10893         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10894         CHECK(obj != NULL);
10895         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
10896         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10897                 (*env)->ExceptionDescribe(env);
10898                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
10899         }
10900         if (get_jenv_res == JNI_EDETACHED) {
10901                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10902         }
10903 }
10904 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
10905         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10906         JNIEnv *env;
10907         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10908         if (get_jenv_res == JNI_EDETACHED) {
10909                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10910         } else {
10911                 DO_ASSERT(get_jenv_res == JNI_OK);
10912         }
10913         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10914         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10915         LDKAnnouncementSignatures msg_var = *msg;
10916         uintptr_t msg_ref = 0;
10917         msg_var = AnnouncementSignatures_clone(msg);
10918         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10919         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10920         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10921         msg_ref = (uintptr_t)msg_var.inner;
10922         if (msg_var.is_owned) {
10923                 msg_ref |= 1;
10924         }
10925         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10926         CHECK(obj != NULL);
10927         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
10928         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10929                 (*env)->ExceptionDescribe(env);
10930                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
10931         }
10932         if (get_jenv_res == JNI_EDETACHED) {
10933                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10934         }
10935 }
10936 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
10937         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10938         JNIEnv *env;
10939         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10940         if (get_jenv_res == JNI_EDETACHED) {
10941                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10942         } else {
10943                 DO_ASSERT(get_jenv_res == JNI_OK);
10944         }
10945         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10946         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10947         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10948         CHECK(obj != NULL);
10949         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
10950         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10951                 (*env)->ExceptionDescribe(env);
10952                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
10953         }
10954         if (get_jenv_res == JNI_EDETACHED) {
10955                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10956         }
10957 }
10958 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
10959         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10960         JNIEnv *env;
10961         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10962         if (get_jenv_res == JNI_EDETACHED) {
10963                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10964         } else {
10965                 DO_ASSERT(get_jenv_res == JNI_OK);
10966         }
10967         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10968         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10969         LDKInit msg_var = *msg;
10970         uintptr_t msg_ref = 0;
10971         msg_var = Init_clone(msg);
10972         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10973         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10974         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10975         msg_ref = (uintptr_t)msg_var.inner;
10976         if (msg_var.is_owned) {
10977                 msg_ref |= 1;
10978         }
10979         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10980         CHECK(obj != NULL);
10981         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
10982         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10983                 (*env)->ExceptionDescribe(env);
10984                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
10985         }
10986         if (get_jenv_res == JNI_EDETACHED) {
10987                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10988         }
10989 }
10990 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
10991         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10992         JNIEnv *env;
10993         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10994         if (get_jenv_res == JNI_EDETACHED) {
10995                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10996         } else {
10997                 DO_ASSERT(get_jenv_res == JNI_OK);
10998         }
10999         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11000         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11001         LDKChannelReestablish msg_var = *msg;
11002         uintptr_t msg_ref = 0;
11003         msg_var = ChannelReestablish_clone(msg);
11004         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11005         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11006         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11007         msg_ref = (uintptr_t)msg_var.inner;
11008         if (msg_var.is_owned) {
11009                 msg_ref |= 1;
11010         }
11011         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11012         CHECK(obj != NULL);
11013         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
11014         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11015                 (*env)->ExceptionDescribe(env);
11016                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
11017         }
11018         if (get_jenv_res == JNI_EDETACHED) {
11019                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11020         }
11021 }
11022 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
11023         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11024         JNIEnv *env;
11025         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11026         if (get_jenv_res == JNI_EDETACHED) {
11027                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11028         } else {
11029                 DO_ASSERT(get_jenv_res == JNI_OK);
11030         }
11031         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11032         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11033         LDKChannelUpdate msg_var = *msg;
11034         uintptr_t msg_ref = 0;
11035         msg_var = ChannelUpdate_clone(msg);
11036         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11037         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11038         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11039         msg_ref = (uintptr_t)msg_var.inner;
11040         if (msg_var.is_owned) {
11041                 msg_ref |= 1;
11042         }
11043         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11044         CHECK(obj != NULL);
11045         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
11046         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11047                 (*env)->ExceptionDescribe(env);
11048                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
11049         }
11050         if (get_jenv_res == JNI_EDETACHED) {
11051                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11052         }
11053 }
11054 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
11055         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11056         JNIEnv *env;
11057         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11058         if (get_jenv_res == JNI_EDETACHED) {
11059                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11060         } else {
11061                 DO_ASSERT(get_jenv_res == JNI_OK);
11062         }
11063         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11064         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11065         LDKErrorMessage msg_var = *msg;
11066         uintptr_t msg_ref = 0;
11067         msg_var = ErrorMessage_clone(msg);
11068         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11069         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11070         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11071         msg_ref = (uintptr_t)msg_var.inner;
11072         if (msg_var.is_owned) {
11073                 msg_ref |= 1;
11074         }
11075         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11076         CHECK(obj != NULL);
11077         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
11078         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11079                 (*env)->ExceptionDescribe(env);
11080                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
11081         }
11082         if (get_jenv_res == JNI_EDETACHED) {
11083                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11084         }
11085 }
11086 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
11087         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
11088         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11089         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
11090 }
11091 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11092         jclass c = (*env)->GetObjectClass(env, o);
11093         CHECK(c != NULL);
11094         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
11095         atomic_init(&calls->refcnt, 1);
11096         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11097         calls->o = (*env)->NewWeakGlobalRef(env, o);
11098         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
11099         CHECK(calls->handle_open_channel_meth != NULL);
11100         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
11101         CHECK(calls->handle_accept_channel_meth != NULL);
11102         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
11103         CHECK(calls->handle_funding_created_meth != NULL);
11104         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
11105         CHECK(calls->handle_funding_signed_meth != NULL);
11106         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
11107         CHECK(calls->handle_funding_locked_meth != NULL);
11108         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
11109         CHECK(calls->handle_shutdown_meth != NULL);
11110         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
11111         CHECK(calls->handle_closing_signed_meth != NULL);
11112         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
11113         CHECK(calls->handle_update_add_htlc_meth != NULL);
11114         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
11115         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
11116         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
11117         CHECK(calls->handle_update_fail_htlc_meth != NULL);
11118         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
11119         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
11120         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
11121         CHECK(calls->handle_commitment_signed_meth != NULL);
11122         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
11123         CHECK(calls->handle_revoke_and_ack_meth != NULL);
11124         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
11125         CHECK(calls->handle_update_fee_meth != NULL);
11126         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
11127         CHECK(calls->handle_announcement_signatures_meth != NULL);
11128         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
11129         CHECK(calls->peer_disconnected_meth != NULL);
11130         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
11131         CHECK(calls->peer_connected_meth != NULL);
11132         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
11133         CHECK(calls->handle_channel_reestablish_meth != NULL);
11134         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
11135         CHECK(calls->handle_channel_update_meth != NULL);
11136         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
11137         CHECK(calls->handle_error_meth != NULL);
11138
11139         LDKChannelMessageHandler ret = {
11140                 .this_arg = (void*) calls,
11141                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
11142                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
11143                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
11144                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
11145                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
11146                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
11147                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
11148                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
11149                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
11150                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
11151                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
11152                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
11153                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
11154                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
11155                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
11156                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
11157                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
11158                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
11159                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
11160                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
11161                 .free = LDKChannelMessageHandler_JCalls_free,
11162                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
11163         };
11164         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
11165         return ret;
11166 }
11167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11168         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
11169         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
11170         return (uint64_t)res_ptr;
11171 }
11172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
11173         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
11174         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
11175         DO_ASSERT((res_ptr & 1) == 0);
11176         return (int64_t)(res_ptr | 1);
11177 }
11178 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) {
11179         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11180         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11181         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11182         LDKPublicKey their_node_id_ref;
11183         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11184         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11185         LDKInitFeatures their_features_conv;
11186         their_features_conv.inner = (void*)(their_features & (~1));
11187         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
11188         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11189         their_features_conv = InitFeatures_clone(&their_features_conv);
11190         LDKOpenChannel msg_conv;
11191         msg_conv.inner = (void*)(msg & (~1));
11192         msg_conv.is_owned = false;
11193         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11194         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
11195 }
11196
11197 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) {
11198         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11199         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11200         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11201         LDKPublicKey their_node_id_ref;
11202         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11203         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11204         LDKInitFeatures their_features_conv;
11205         their_features_conv.inner = (void*)(their_features & (~1));
11206         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
11207         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11208         their_features_conv = InitFeatures_clone(&their_features_conv);
11209         LDKAcceptChannel msg_conv;
11210         msg_conv.inner = (void*)(msg & (~1));
11211         msg_conv.is_owned = false;
11212         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11213         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
11214 }
11215
11216 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) {
11217         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11218         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11219         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11220         LDKPublicKey their_node_id_ref;
11221         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11222         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11223         LDKFundingCreated msg_conv;
11224         msg_conv.inner = (void*)(msg & (~1));
11225         msg_conv.is_owned = false;
11226         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11227         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11228 }
11229
11230 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) {
11231         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11232         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11233         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11234         LDKPublicKey their_node_id_ref;
11235         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11236         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11237         LDKFundingSigned msg_conv;
11238         msg_conv.inner = (void*)(msg & (~1));
11239         msg_conv.is_owned = false;
11240         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11241         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11242 }
11243
11244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
11245         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11246         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11247         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11248         LDKPublicKey their_node_id_ref;
11249         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11250         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11251         LDKFundingLocked msg_conv;
11252         msg_conv.inner = (void*)(msg & (~1));
11253         msg_conv.is_owned = false;
11254         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11255         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11256 }
11257
11258 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) {
11259         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11260         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11261         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11262         LDKPublicKey their_node_id_ref;
11263         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11264         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11265         LDKInitFeatures their_features_conv;
11266         their_features_conv.inner = (void*)(their_features & (~1));
11267         their_features_conv.is_owned = false;
11268         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11269         LDKShutdown msg_conv;
11270         msg_conv.inner = (void*)(msg & (~1));
11271         msg_conv.is_owned = false;
11272         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11273         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
11274 }
11275
11276 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) {
11277         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11278         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11279         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11280         LDKPublicKey their_node_id_ref;
11281         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11282         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11283         LDKClosingSigned msg_conv;
11284         msg_conv.inner = (void*)(msg & (~1));
11285         msg_conv.is_owned = false;
11286         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11287         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11288 }
11289
11290 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) {
11291         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11292         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11293         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11294         LDKPublicKey their_node_id_ref;
11295         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11296         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11297         LDKUpdateAddHTLC msg_conv;
11298         msg_conv.inner = (void*)(msg & (~1));
11299         msg_conv.is_owned = false;
11300         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11301         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11302 }
11303
11304 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) {
11305         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11306         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11307         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11308         LDKPublicKey their_node_id_ref;
11309         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11310         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11311         LDKUpdateFulfillHTLC msg_conv;
11312         msg_conv.inner = (void*)(msg & (~1));
11313         msg_conv.is_owned = false;
11314         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11315         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11316 }
11317
11318 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) {
11319         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11320         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11321         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11322         LDKPublicKey their_node_id_ref;
11323         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11324         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11325         LDKUpdateFailHTLC msg_conv;
11326         msg_conv.inner = (void*)(msg & (~1));
11327         msg_conv.is_owned = false;
11328         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11329         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11330 }
11331
11332 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) {
11333         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11334         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11335         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11336         LDKPublicKey their_node_id_ref;
11337         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11338         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11339         LDKUpdateFailMalformedHTLC msg_conv;
11340         msg_conv.inner = (void*)(msg & (~1));
11341         msg_conv.is_owned = false;
11342         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11343         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11344 }
11345
11346 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) {
11347         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11348         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11349         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11350         LDKPublicKey their_node_id_ref;
11351         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11352         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11353         LDKCommitmentSigned msg_conv;
11354         msg_conv.inner = (void*)(msg & (~1));
11355         msg_conv.is_owned = false;
11356         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11357         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11358 }
11359
11360 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) {
11361         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11362         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11363         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11364         LDKPublicKey their_node_id_ref;
11365         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11366         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11367         LDKRevokeAndACK msg_conv;
11368         msg_conv.inner = (void*)(msg & (~1));
11369         msg_conv.is_owned = false;
11370         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11371         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11372 }
11373
11374 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) {
11375         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11376         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11377         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11378         LDKPublicKey their_node_id_ref;
11379         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11380         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11381         LDKUpdateFee msg_conv;
11382         msg_conv.inner = (void*)(msg & (~1));
11383         msg_conv.is_owned = false;
11384         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11385         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11386 }
11387
11388 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) {
11389         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11390         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11391         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11392         LDKPublicKey their_node_id_ref;
11393         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11394         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11395         LDKAnnouncementSignatures msg_conv;
11396         msg_conv.inner = (void*)(msg & (~1));
11397         msg_conv.is_owned = false;
11398         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11399         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11400 }
11401
11402 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) {
11403         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11404         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11405         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11406         LDKPublicKey their_node_id_ref;
11407         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11408         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11409         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
11410 }
11411
11412 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) {
11413         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11414         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11415         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11416         LDKPublicKey their_node_id_ref;
11417         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11418         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11419         LDKInit msg_conv;
11420         msg_conv.inner = (void*)(msg & (~1));
11421         msg_conv.is_owned = false;
11422         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11423         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11424 }
11425
11426 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) {
11427         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11428         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11429         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11430         LDKPublicKey their_node_id_ref;
11431         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11432         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11433         LDKChannelReestablish msg_conv;
11434         msg_conv.inner = (void*)(msg & (~1));
11435         msg_conv.is_owned = false;
11436         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11437         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11438 }
11439
11440 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) {
11441         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11442         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11443         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11444         LDKPublicKey their_node_id_ref;
11445         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11446         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11447         LDKChannelUpdate msg_conv;
11448         msg_conv.inner = (void*)(msg & (~1));
11449         msg_conv.is_owned = false;
11450         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11451         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11452 }
11453
11454 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) {
11455         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11456         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11457         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11458         LDKPublicKey their_node_id_ref;
11459         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11460         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11461         LDKErrorMessage msg_conv;
11462         msg_conv.inner = (void*)(msg & (~1));
11463         msg_conv.is_owned = false;
11464         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11465         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11466 }
11467
11468 typedef struct LDKRoutingMessageHandler_JCalls {
11469         atomic_size_t refcnt;
11470         JavaVM *vm;
11471         jweak o;
11472         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
11473         jmethodID handle_node_announcement_meth;
11474         jmethodID handle_channel_announcement_meth;
11475         jmethodID handle_channel_update_meth;
11476         jmethodID get_next_channel_announcements_meth;
11477         jmethodID get_next_node_announcements_meth;
11478         jmethodID sync_routing_table_meth;
11479         jmethodID handle_reply_channel_range_meth;
11480         jmethodID handle_reply_short_channel_ids_end_meth;
11481         jmethodID handle_query_channel_range_meth;
11482         jmethodID handle_query_short_channel_ids_meth;
11483 } LDKRoutingMessageHandler_JCalls;
11484 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
11485         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11486         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11487                 JNIEnv *env;
11488                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11489                 if (get_jenv_res == JNI_EDETACHED) {
11490                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11491                 } else {
11492                         DO_ASSERT(get_jenv_res == JNI_OK);
11493                 }
11494                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11495                 if (get_jenv_res == JNI_EDETACHED) {
11496                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11497                 }
11498                 FREE(j_calls);
11499         }
11500 }
11501 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
11502         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11503         JNIEnv *env;
11504         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11505         if (get_jenv_res == JNI_EDETACHED) {
11506                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11507         } else {
11508                 DO_ASSERT(get_jenv_res == JNI_OK);
11509         }
11510         LDKNodeAnnouncement msg_var = *msg;
11511         uintptr_t msg_ref = 0;
11512         msg_var = NodeAnnouncement_clone(msg);
11513         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11514         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11515         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11516         msg_ref = (uintptr_t)msg_var.inner;
11517         if (msg_var.is_owned) {
11518                 msg_ref |= 1;
11519         }
11520         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11521         CHECK(obj != NULL);
11522         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
11523         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11524                 (*env)->ExceptionDescribe(env);
11525                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
11526         }
11527         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11528         CHECK_ACCESS(ret_ptr);
11529         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11530         FREE((void*)ret);
11531         if (get_jenv_res == JNI_EDETACHED) {
11532                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11533         }
11534         return ret_conv;
11535 }
11536 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
11537         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11538         JNIEnv *env;
11539         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11540         if (get_jenv_res == JNI_EDETACHED) {
11541                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11542         } else {
11543                 DO_ASSERT(get_jenv_res == JNI_OK);
11544         }
11545         LDKChannelAnnouncement msg_var = *msg;
11546         uintptr_t msg_ref = 0;
11547         msg_var = ChannelAnnouncement_clone(msg);
11548         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11549         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11550         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11551         msg_ref = (uintptr_t)msg_var.inner;
11552         if (msg_var.is_owned) {
11553                 msg_ref |= 1;
11554         }
11555         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11556         CHECK(obj != NULL);
11557         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
11558         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11559                 (*env)->ExceptionDescribe(env);
11560                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
11561         }
11562         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11563         CHECK_ACCESS(ret_ptr);
11564         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11565         FREE((void*)ret);
11566         if (get_jenv_res == JNI_EDETACHED) {
11567                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11568         }
11569         return ret_conv;
11570 }
11571 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
11572         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11573         JNIEnv *env;
11574         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11575         if (get_jenv_res == JNI_EDETACHED) {
11576                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11577         } else {
11578                 DO_ASSERT(get_jenv_res == JNI_OK);
11579         }
11580         LDKChannelUpdate msg_var = *msg;
11581         uintptr_t msg_ref = 0;
11582         msg_var = ChannelUpdate_clone(msg);
11583         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11584         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11585         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11586         msg_ref = (uintptr_t)msg_var.inner;
11587         if (msg_var.is_owned) {
11588                 msg_ref |= 1;
11589         }
11590         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11591         CHECK(obj != NULL);
11592         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
11593         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11594                 (*env)->ExceptionDescribe(env);
11595                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
11596         }
11597         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11598         CHECK_ACCESS(ret_ptr);
11599         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11600         FREE((void*)ret);
11601         if (get_jenv_res == JNI_EDETACHED) {
11602                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11603         }
11604         return ret_conv;
11605 }
11606 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
11607         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11608         JNIEnv *env;
11609         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11610         if (get_jenv_res == JNI_EDETACHED) {
11611                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11612         } else {
11613                 DO_ASSERT(get_jenv_res == JNI_OK);
11614         }
11615         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11616         CHECK(obj != NULL);
11617         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
11618         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11619                 (*env)->ExceptionDescribe(env);
11620                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
11621         }
11622         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
11623         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11624         if (ret_constr.datalen > 0)
11625                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11626         else
11627                 ret_constr.data = NULL;
11628         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
11629         for (size_t h = 0; h < ret_constr.datalen; h++) {
11630                 int64_t ret_conv_59 = ret_vals[h];
11631                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
11632                 CHECK_ACCESS(ret_conv_59_ptr);
11633                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
11634                 FREE((void*)ret_conv_59);
11635                 ret_constr.data[h] = ret_conv_59_conv;
11636         }
11637         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
11638         if (get_jenv_res == JNI_EDETACHED) {
11639                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11640         }
11641         return ret_constr;
11642 }
11643 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
11644         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11645         JNIEnv *env;
11646         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11647         if (get_jenv_res == JNI_EDETACHED) {
11648                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11649         } else {
11650                 DO_ASSERT(get_jenv_res == JNI_OK);
11651         }
11652         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
11653         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
11654         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11655         CHECK(obj != NULL);
11656         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
11657         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11658                 (*env)->ExceptionDescribe(env);
11659                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
11660         }
11661         LDKCVec_NodeAnnouncementZ ret_constr;
11662         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11663         if (ret_constr.datalen > 0)
11664                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11665         else
11666                 ret_constr.data = NULL;
11667         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
11668         for (size_t s = 0; s < ret_constr.datalen; s++) {
11669                 int64_t ret_conv_18 = ret_vals[s];
11670                 LDKNodeAnnouncement ret_conv_18_conv;
11671                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
11672                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
11673                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
11674                 ret_constr.data[s] = ret_conv_18_conv;
11675         }
11676         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
11677         if (get_jenv_res == JNI_EDETACHED) {
11678                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11679         }
11680         return ret_constr;
11681 }
11682 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
11683         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11684         JNIEnv *env;
11685         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11686         if (get_jenv_res == JNI_EDETACHED) {
11687                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11688         } else {
11689                 DO_ASSERT(get_jenv_res == JNI_OK);
11690         }
11691         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11692         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11693         LDKInit init_var = *init;
11694         uintptr_t init_ref = 0;
11695         init_var = Init_clone(init);
11696         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11697         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11698         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
11699         init_ref = (uintptr_t)init_var.inner;
11700         if (init_var.is_owned) {
11701                 init_ref |= 1;
11702         }
11703         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11704         CHECK(obj != NULL);
11705         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
11706         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11707                 (*env)->ExceptionDescribe(env);
11708                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
11709         }
11710         if (get_jenv_res == JNI_EDETACHED) {
11711                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11712         }
11713 }
11714 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
11715         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11716         JNIEnv *env;
11717         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11718         if (get_jenv_res == JNI_EDETACHED) {
11719                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11720         } else {
11721                 DO_ASSERT(get_jenv_res == JNI_OK);
11722         }
11723         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11724         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11725         LDKReplyChannelRange msg_var = msg;
11726         uintptr_t msg_ref = 0;
11727         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11728         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11729         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11730         msg_ref = (uintptr_t)msg_var.inner;
11731         if (msg_var.is_owned) {
11732                 msg_ref |= 1;
11733         }
11734         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11735         CHECK(obj != NULL);
11736         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
11737         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11738                 (*env)->ExceptionDescribe(env);
11739                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
11740         }
11741         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11742         CHECK_ACCESS(ret_ptr);
11743         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
11744         FREE((void*)ret);
11745         if (get_jenv_res == JNI_EDETACHED) {
11746                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11747         }
11748         return ret_conv;
11749 }
11750 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
11751         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11752         JNIEnv *env;
11753         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11754         if (get_jenv_res == JNI_EDETACHED) {
11755                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11756         } else {
11757                 DO_ASSERT(get_jenv_res == JNI_OK);
11758         }
11759         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11760         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11761         LDKReplyShortChannelIdsEnd msg_var = msg;
11762         uintptr_t msg_ref = 0;
11763         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11764         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11765         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11766         msg_ref = (uintptr_t)msg_var.inner;
11767         if (msg_var.is_owned) {
11768                 msg_ref |= 1;
11769         }
11770         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11771         CHECK(obj != NULL);
11772         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
11773         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11774                 (*env)->ExceptionDescribe(env);
11775                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
11776         }
11777         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11778         CHECK_ACCESS(ret_ptr);
11779         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
11780         FREE((void*)ret);
11781         if (get_jenv_res == JNI_EDETACHED) {
11782                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11783         }
11784         return ret_conv;
11785 }
11786 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
11787         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11788         JNIEnv *env;
11789         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11790         if (get_jenv_res == JNI_EDETACHED) {
11791                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11792         } else {
11793                 DO_ASSERT(get_jenv_res == JNI_OK);
11794         }
11795         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11796         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11797         LDKQueryChannelRange msg_var = msg;
11798         uintptr_t msg_ref = 0;
11799         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11800         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11801         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11802         msg_ref = (uintptr_t)msg_var.inner;
11803         if (msg_var.is_owned) {
11804                 msg_ref |= 1;
11805         }
11806         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11807         CHECK(obj != NULL);
11808         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
11809         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11810                 (*env)->ExceptionDescribe(env);
11811                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
11812         }
11813         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11814         CHECK_ACCESS(ret_ptr);
11815         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
11816         FREE((void*)ret);
11817         if (get_jenv_res == JNI_EDETACHED) {
11818                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11819         }
11820         return ret_conv;
11821 }
11822 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
11823         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11824         JNIEnv *env;
11825         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11826         if (get_jenv_res == JNI_EDETACHED) {
11827                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11828         } else {
11829                 DO_ASSERT(get_jenv_res == JNI_OK);
11830         }
11831         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11832         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11833         LDKQueryShortChannelIds msg_var = msg;
11834         uintptr_t msg_ref = 0;
11835         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11836         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11837         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11838         msg_ref = (uintptr_t)msg_var.inner;
11839         if (msg_var.is_owned) {
11840                 msg_ref |= 1;
11841         }
11842         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11843         CHECK(obj != NULL);
11844         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
11845         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11846                 (*env)->ExceptionDescribe(env);
11847                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
11848         }
11849         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11850         CHECK_ACCESS(ret_ptr);
11851         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
11852         FREE((void*)ret);
11853         if (get_jenv_res == JNI_EDETACHED) {
11854                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11855         }
11856         return ret_conv;
11857 }
11858 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
11859         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
11860         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11861         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
11862 }
11863 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11864         jclass c = (*env)->GetObjectClass(env, o);
11865         CHECK(c != NULL);
11866         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
11867         atomic_init(&calls->refcnt, 1);
11868         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11869         calls->o = (*env)->NewWeakGlobalRef(env, o);
11870         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
11871         CHECK(calls->handle_node_announcement_meth != NULL);
11872         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
11873         CHECK(calls->handle_channel_announcement_meth != NULL);
11874         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
11875         CHECK(calls->handle_channel_update_meth != NULL);
11876         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
11877         CHECK(calls->get_next_channel_announcements_meth != NULL);
11878         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
11879         CHECK(calls->get_next_node_announcements_meth != NULL);
11880         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
11881         CHECK(calls->sync_routing_table_meth != NULL);
11882         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
11883         CHECK(calls->handle_reply_channel_range_meth != NULL);
11884         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
11885         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
11886         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
11887         CHECK(calls->handle_query_channel_range_meth != NULL);
11888         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
11889         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
11890
11891         LDKRoutingMessageHandler ret = {
11892                 .this_arg = (void*) calls,
11893                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
11894                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
11895                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
11896                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
11897                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
11898                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
11899                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
11900                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
11901                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
11902                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
11903                 .free = LDKRoutingMessageHandler_JCalls_free,
11904                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
11905         };
11906         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
11907         return ret;
11908 }
11909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11910         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
11911         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
11912         return (uint64_t)res_ptr;
11913 }
11914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
11915         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
11916         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
11917         DO_ASSERT((res_ptr & 1) == 0);
11918         return (int64_t)(res_ptr | 1);
11919 }
11920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
11921         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11922         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11923         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
11924         LDKNodeAnnouncement msg_conv;
11925         msg_conv.inner = (void*)(msg & (~1));
11926         msg_conv.is_owned = false;
11927         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11928         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11929         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
11930         return (uintptr_t)ret_conv;
11931 }
11932
11933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
11934         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11935         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11936         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
11937         LDKChannelAnnouncement msg_conv;
11938         msg_conv.inner = (void*)(msg & (~1));
11939         msg_conv.is_owned = false;
11940         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11941         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11942         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
11943         return (uintptr_t)ret_conv;
11944 }
11945
11946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
11947         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11948         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11949         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
11950         LDKChannelUpdate msg_conv;
11951         msg_conv.inner = (void*)(msg & (~1));
11952         msg_conv.is_owned = false;
11953         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11954         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11955         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
11956         return (uintptr_t)ret_conv;
11957 }
11958
11959 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) {
11960         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11961         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11962         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
11963         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
11964         int64_tArray ret_arr = NULL;
11965         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11966         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11967         for (size_t h = 0; h < ret_var.datalen; h++) {
11968                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11969                 *ret_conv_59_conv = ret_var.data[h];
11970                 ret_arr_ptr[h] = ((uintptr_t)ret_conv_59_conv);
11971         }
11972         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11973         FREE(ret_var.data);
11974         return ret_arr;
11975 }
11976
11977 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) {
11978         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11979         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11980         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
11981         LDKPublicKey starting_point_ref;
11982         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
11983         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
11984         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
11985         int64_tArray ret_arr = NULL;
11986         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11987         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11988         for (size_t s = 0; s < ret_var.datalen; s++) {
11989                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
11990                 uintptr_t ret_conv_18_ref = 0;
11991                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11992                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11993                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
11994                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
11995                 if (ret_conv_18_var.is_owned) {
11996                         ret_conv_18_ref |= 1;
11997                 }
11998                 ret_arr_ptr[s] = ret_conv_18_ref;
11999         }
12000         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12001         FREE(ret_var.data);
12002         return ret_arr;
12003 }
12004
12005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1sync_1routing_1table(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t init) {
12006         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12007         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12008         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12009         LDKPublicKey their_node_id_ref;
12010         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12011         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12012         LDKInit init_conv;
12013         init_conv.inner = (void*)(init & (~1));
12014         init_conv.is_owned = false;
12015         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
12016         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
12017 }
12018
12019 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) {
12020         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12021         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12022         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12023         LDKPublicKey their_node_id_ref;
12024         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12025         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12026         LDKReplyChannelRange msg_conv;
12027         msg_conv.inner = (void*)(msg & (~1));
12028         msg_conv.is_owned = (msg & 1) || (msg == 0);
12029         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12030         msg_conv = ReplyChannelRange_clone(&msg_conv);
12031         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12032         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12033         return (uintptr_t)ret_conv;
12034 }
12035
12036 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) {
12037         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12038         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12039         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12040         LDKPublicKey their_node_id_ref;
12041         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12042         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12043         LDKReplyShortChannelIdsEnd msg_conv;
12044         msg_conv.inner = (void*)(msg & (~1));
12045         msg_conv.is_owned = (msg & 1) || (msg == 0);
12046         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12047         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
12048         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12049         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12050         return (uintptr_t)ret_conv;
12051 }
12052
12053 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) {
12054         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12055         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12056         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12057         LDKPublicKey their_node_id_ref;
12058         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12059         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12060         LDKQueryChannelRange msg_conv;
12061         msg_conv.inner = (void*)(msg & (~1));
12062         msg_conv.is_owned = (msg & 1) || (msg == 0);
12063         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12064         msg_conv = QueryChannelRange_clone(&msg_conv);
12065         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12066         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12067         return (uintptr_t)ret_conv;
12068 }
12069
12070 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) {
12071         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12072         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12073         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12074         LDKPublicKey their_node_id_ref;
12075         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12076         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12077         LDKQueryShortChannelIds msg_conv;
12078         msg_conv.inner = (void*)(msg & (~1));
12079         msg_conv.is_owned = (msg & 1) || (msg == 0);
12080         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12081         msg_conv = QueryShortChannelIds_clone(&msg_conv);
12082         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12083         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12084         return (uintptr_t)ret_conv;
12085 }
12086
12087 typedef struct LDKCustomMessageReader_JCalls {
12088         atomic_size_t refcnt;
12089         JavaVM *vm;
12090         jweak o;
12091         jmethodID read_meth;
12092 } LDKCustomMessageReader_JCalls;
12093 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
12094         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
12095         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12096                 JNIEnv *env;
12097                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12098                 if (get_jenv_res == JNI_EDETACHED) {
12099                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12100                 } else {
12101                         DO_ASSERT(get_jenv_res == JNI_OK);
12102                 }
12103                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12104                 if (get_jenv_res == JNI_EDETACHED) {
12105                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12106                 }
12107                 FREE(j_calls);
12108         }
12109 }
12110 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
12111         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
12112         JNIEnv *env;
12113         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12114         if (get_jenv_res == JNI_EDETACHED) {
12115                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12116         } else {
12117                 DO_ASSERT(get_jenv_res == JNI_OK);
12118         }
12119         LDKu8slice buffer_var = buffer;
12120         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
12121         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
12122         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12123         CHECK(obj != NULL);
12124         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type, buffer_arr);
12125         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12126                 (*env)->ExceptionDescribe(env);
12127                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
12128         }
12129         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12130         CHECK_ACCESS(ret_ptr);
12131         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
12132         FREE((void*)ret);
12133         if (get_jenv_res == JNI_EDETACHED) {
12134                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12135         }
12136         return ret_conv;
12137 }
12138 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
12139         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
12140         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12141 }
12142 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
12143         jclass c = (*env)->GetObjectClass(env, o);
12144         CHECK(c != NULL);
12145         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
12146         atomic_init(&calls->refcnt, 1);
12147         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12148         calls->o = (*env)->NewWeakGlobalRef(env, o);
12149         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
12150         CHECK(calls->read_meth != NULL);
12151
12152         LDKCustomMessageReader ret = {
12153                 .this_arg = (void*) calls,
12154                 .read = read_LDKCustomMessageReader_jcall,
12155                 .free = LDKCustomMessageReader_JCalls_free,
12156         };
12157         return ret;
12158 }
12159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
12160         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
12161         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
12162         return (uint64_t)res_ptr;
12163 }
12164 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) {
12165         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12166         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12167         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
12168         LDKu8slice buffer_ref;
12169         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
12170         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
12171         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12172         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
12173         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
12174         return (uintptr_t)ret_conv;
12175 }
12176
12177 typedef struct LDKCustomMessageHandler_JCalls {
12178         atomic_size_t refcnt;
12179         JavaVM *vm;
12180         jweak o;
12181         LDKCustomMessageReader_JCalls* CustomMessageReader;
12182         jmethodID handle_custom_message_meth;
12183         jmethodID get_and_clear_pending_msg_meth;
12184 } LDKCustomMessageHandler_JCalls;
12185 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
12186         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12187         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12188                 JNIEnv *env;
12189                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12190                 if (get_jenv_res == JNI_EDETACHED) {
12191                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12192                 } else {
12193                         DO_ASSERT(get_jenv_res == JNI_OK);
12194                 }
12195                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12196                 if (get_jenv_res == JNI_EDETACHED) {
12197                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12198                 }
12199                 FREE(j_calls);
12200         }
12201 }
12202 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
12203         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12204         JNIEnv *env;
12205         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12206         if (get_jenv_res == JNI_EDETACHED) {
12207                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12208         } else {
12209                 DO_ASSERT(get_jenv_res == JNI_OK);
12210         }
12211         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
12212         *msg_ret = msg;
12213         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
12214         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
12215         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12216         CHECK(obj != NULL);
12217         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (uintptr_t)msg_ret, sender_node_id_arr);
12218         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12219                 (*env)->ExceptionDescribe(env);
12220                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
12221         }
12222         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12223         CHECK_ACCESS(ret_ptr);
12224         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12225         FREE((void*)ret);
12226         if (get_jenv_res == JNI_EDETACHED) {
12227                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12228         }
12229         return ret_conv;
12230 }
12231 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
12232         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12233         JNIEnv *env;
12234         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12235         if (get_jenv_res == JNI_EDETACHED) {
12236                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12237         } else {
12238                 DO_ASSERT(get_jenv_res == JNI_OK);
12239         }
12240         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12241         CHECK(obj != NULL);
12242         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
12243         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12244                 (*env)->ExceptionDescribe(env);
12245                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
12246         }
12247         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
12248         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12249         if (ret_constr.datalen > 0)
12250                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
12251         else
12252                 ret_constr.data = NULL;
12253         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12254         for (size_t z = 0; z < ret_constr.datalen; z++) {
12255                 int64_t ret_conv_25 = ret_vals[z];
12256                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
12257                 CHECK_ACCESS(ret_conv_25_ptr);
12258                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
12259                 FREE((void*)ret_conv_25);
12260                 ret_constr.data[z] = ret_conv_25_conv;
12261         }
12262         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12263         if (get_jenv_res == JNI_EDETACHED) {
12264                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12265         }
12266         return ret_constr;
12267 }
12268 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
12269         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
12270         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12271         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
12272 }
12273 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
12274         jclass c = (*env)->GetObjectClass(env, o);
12275         CHECK(c != NULL);
12276         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
12277         atomic_init(&calls->refcnt, 1);
12278         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12279         calls->o = (*env)->NewWeakGlobalRef(env, o);
12280         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
12281         CHECK(calls->handle_custom_message_meth != NULL);
12282         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
12283         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
12284
12285         LDKCustomMessageHandler ret = {
12286                 .this_arg = (void*) calls,
12287                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
12288                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
12289                 .free = LDKCustomMessageHandler_JCalls_free,
12290                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
12291         };
12292         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
12293         return ret;
12294 }
12295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
12296         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
12297         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
12298         return (uint64_t)res_ptr;
12299 }
12300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
12301         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
12302         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
12303         DO_ASSERT((res_ptr & 1) == 0);
12304         return (int64_t)(res_ptr | 1);
12305 }
12306 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) {
12307         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12308         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12309         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
12310         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
12311         CHECK_ACCESS(msg_ptr);
12312         LDKType msg_conv = *(LDKType*)(msg_ptr);
12313         if (msg_conv.free == LDKType_JCalls_free) {
12314                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12315                 LDKType_JCalls_cloned(&msg_conv);
12316         }
12317         LDKPublicKey sender_node_id_ref;
12318         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
12319         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
12320         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12321         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
12322         return (uintptr_t)ret_conv;
12323 }
12324
12325 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
12326         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12327         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12328         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
12329         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
12330         int64_tArray ret_arr = NULL;
12331         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12332         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12333         for (size_t z = 0; z < ret_var.datalen; z++) {
12334                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
12335                 *ret_conv_25_conv = ret_var.data[z];
12336                 ret_arr_ptr[z] = ((uintptr_t)ret_conv_25_conv);
12337         }
12338         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12339         FREE(ret_var.data);
12340         return ret_arr;
12341 }
12342
12343 typedef struct LDKSocketDescriptor_JCalls {
12344         atomic_size_t refcnt;
12345         JavaVM *vm;
12346         jweak o;
12347         jmethodID send_data_meth;
12348         jmethodID disconnect_socket_meth;
12349         jmethodID eq_meth;
12350         jmethodID hash_meth;
12351 } LDKSocketDescriptor_JCalls;
12352 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
12353         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12354         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12355                 JNIEnv *env;
12356                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12357                 if (get_jenv_res == JNI_EDETACHED) {
12358                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12359                 } else {
12360                         DO_ASSERT(get_jenv_res == JNI_OK);
12361                 }
12362                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12363                 if (get_jenv_res == JNI_EDETACHED) {
12364                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12365                 }
12366                 FREE(j_calls);
12367         }
12368 }
12369 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
12370         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_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         LDKu8slice data_var = data;
12379         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
12380         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
12381         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12382         CHECK(obj != NULL);
12383         intptr_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
12384         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12385                 (*env)->ExceptionDescribe(env);
12386                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
12387         }
12388         if (get_jenv_res == JNI_EDETACHED) {
12389                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12390         }
12391         return ret;
12392 }
12393 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
12394         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12395         JNIEnv *env;
12396         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12397         if (get_jenv_res == JNI_EDETACHED) {
12398                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12399         } else {
12400                 DO_ASSERT(get_jenv_res == JNI_OK);
12401         }
12402         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12403         CHECK(obj != NULL);
12404         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
12405         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12406                 (*env)->ExceptionDescribe(env);
12407                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
12408         }
12409         if (get_jenv_res == JNI_EDETACHED) {
12410                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12411         }
12412 }
12413 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
12414         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12415         JNIEnv *env;
12416         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12417         if (get_jenv_res == JNI_EDETACHED) {
12418                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12419         } else {
12420                 DO_ASSERT(get_jenv_res == JNI_OK);
12421         }
12422         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
12423         *other_arg_clone = SocketDescriptor_clone(other_arg);
12424         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12425         CHECK(obj != NULL);
12426         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uintptr_t)other_arg_clone);
12427         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12428                 (*env)->ExceptionDescribe(env);
12429                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
12430         }
12431         if (get_jenv_res == JNI_EDETACHED) {
12432                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12433         }
12434         return ret;
12435 }
12436 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
12437         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12438         JNIEnv *env;
12439         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12440         if (get_jenv_res == JNI_EDETACHED) {
12441                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12442         } else {
12443                 DO_ASSERT(get_jenv_res == JNI_OK);
12444         }
12445         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12446         CHECK(obj != NULL);
12447         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
12448         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12449                 (*env)->ExceptionDescribe(env);
12450                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor 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         return ret;
12456 }
12457 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
12458         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
12459         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12460 }
12461 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
12462         jclass c = (*env)->GetObjectClass(env, o);
12463         CHECK(c != NULL);
12464         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
12465         atomic_init(&calls->refcnt, 1);
12466         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12467         calls->o = (*env)->NewWeakGlobalRef(env, o);
12468         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
12469         CHECK(calls->send_data_meth != NULL);
12470         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
12471         CHECK(calls->disconnect_socket_meth != NULL);
12472         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
12473         CHECK(calls->eq_meth != NULL);
12474         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
12475         CHECK(calls->hash_meth != NULL);
12476
12477         LDKSocketDescriptor ret = {
12478                 .this_arg = (void*) calls,
12479                 .send_data = send_data_LDKSocketDescriptor_jcall,
12480                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
12481                 .eq = eq_LDKSocketDescriptor_jcall,
12482                 .hash = hash_LDKSocketDescriptor_jcall,
12483                 .cloned = LDKSocketDescriptor_JCalls_cloned,
12484                 .free = LDKSocketDescriptor_JCalls_free,
12485         };
12486         return ret;
12487 }
12488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
12489         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
12490         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
12491         return (uint64_t)res_ptr;
12492 }
12493 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1send_1data(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray data, jboolean resume_read) {
12494         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12495         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12496         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12497         LDKu8slice data_ref;
12498         data_ref.datalen = (*env)->GetArrayLength(env, data);
12499         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
12500         intptr_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
12501         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
12502         return ret_val;
12503 }
12504
12505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
12506         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12507         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12508         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12509         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
12510 }
12511
12512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
12513         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12514         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12515         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12516         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
12517         return ret_val;
12518 }
12519
12520 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
12521 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
12522 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
12523 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
12524 static jclass LDKEffectiveCapacity_Total_class = NULL;
12525 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
12526 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
12527 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
12528 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
12529 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
12530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
12531         LDKEffectiveCapacity_ExactLiquidity_class =
12532                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
12533         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
12534         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
12535         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
12536         LDKEffectiveCapacity_MaximumHTLC_class =
12537                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
12538         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
12539         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
12540         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
12541         LDKEffectiveCapacity_Total_class =
12542                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
12543         CHECK(LDKEffectiveCapacity_Total_class != NULL);
12544         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(J)V");
12545         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
12546         LDKEffectiveCapacity_Infinite_class =
12547                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
12548         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
12549         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
12550         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
12551         LDKEffectiveCapacity_Unknown_class =
12552                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
12553         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
12554         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
12555         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
12556 }
12557 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
12558         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
12559         switch(obj->tag) {
12560                 case LDKEffectiveCapacity_ExactLiquidity: {
12561                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, obj->exact_liquidity.liquidity_msat);
12562                 }
12563                 case LDKEffectiveCapacity_MaximumHTLC: {
12564                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, obj->maximum_htlc.amount_msat);
12565                 }
12566                 case LDKEffectiveCapacity_Total: {
12567                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, obj->total.capacity_msat);
12568                 }
12569                 case LDKEffectiveCapacity_Infinite: {
12570                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
12571                 }
12572                 case LDKEffectiveCapacity_Unknown: {
12573                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
12574                 }
12575                 default: abort();
12576         }
12577 }
12578 typedef struct LDKScore_JCalls {
12579         atomic_size_t refcnt;
12580         JavaVM *vm;
12581         jweak o;
12582         jmethodID channel_penalty_msat_meth;
12583         jmethodID payment_path_failed_meth;
12584         jmethodID payment_path_successful_meth;
12585         jmethodID write_meth;
12586 } LDKScore_JCalls;
12587 static void LDKScore_JCalls_free(void* this_arg) {
12588         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
12589         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12590                 JNIEnv *env;
12591                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12592                 if (get_jenv_res == JNI_EDETACHED) {
12593                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12594                 } else {
12595                         DO_ASSERT(get_jenv_res == JNI_OK);
12596                 }
12597                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12598                 if (get_jenv_res == JNI_EDETACHED) {
12599                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12600                 }
12601                 FREE(j_calls);
12602         }
12603 }
12604 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, uint64_t send_amt_msat, uint64_t capacity_msat, const LDKNodeId * source, const LDKNodeId * target) {
12605         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
12606         JNIEnv *env;
12607         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12608         if (get_jenv_res == JNI_EDETACHED) {
12609                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12610         } else {
12611                 DO_ASSERT(get_jenv_res == JNI_OK);
12612         }
12613         LDKNodeId source_var = *source;
12614         uintptr_t source_ref = 0;
12615         source_var = NodeId_clone(source);
12616         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12617         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12618         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
12619         source_ref = (uintptr_t)source_var.inner;
12620         if (source_var.is_owned) {
12621                 source_ref |= 1;
12622         }
12623         LDKNodeId target_var = *target;
12624         uintptr_t target_ref = 0;
12625         target_var = NodeId_clone(target);
12626         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12627         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12628         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
12629         target_ref = (uintptr_t)target_var.inner;
12630         if (target_var.is_owned) {
12631                 target_ref |= 1;
12632         }
12633         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12634         CHECK(obj != NULL);
12635         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id, send_amt_msat, capacity_msat, source_ref, target_ref);
12636         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12637                 (*env)->ExceptionDescribe(env);
12638                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
12639         }
12640         if (get_jenv_res == JNI_EDETACHED) {
12641                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12642         }
12643         return ret;
12644 }
12645 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
12646         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
12647         JNIEnv *env;
12648         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12649         if (get_jenv_res == JNI_EDETACHED) {
12650                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12651         } else {
12652                 DO_ASSERT(get_jenv_res == JNI_OK);
12653         }
12654         LDKCVec_RouteHopZ path_var = path;
12655         int64_tArray path_arr = NULL;
12656         path_arr = (*env)->NewLongArray(env, path_var.datalen);
12657         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
12658         for (size_t k = 0; k < path_var.datalen; k++) {
12659                 LDKRouteHop path_conv_10_var = path_var.data[k];
12660                 uintptr_t path_conv_10_ref = 0;
12661                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12662                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12663                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
12664                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
12665                 if (path_conv_10_var.is_owned) {
12666                         path_conv_10_ref |= 1;
12667                 }
12668                 path_arr_ptr[k] = path_conv_10_ref;
12669         }
12670         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
12671         FREE(path_var.data);
12672         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12673         CHECK(obj != NULL);
12674         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id);
12675         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12676                 (*env)->ExceptionDescribe(env);
12677                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
12678         }
12679         if (get_jenv_res == JNI_EDETACHED) {
12680                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12681         }
12682 }
12683 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
12684         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
12685         JNIEnv *env;
12686         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12687         if (get_jenv_res == JNI_EDETACHED) {
12688                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12689         } else {
12690                 DO_ASSERT(get_jenv_res == JNI_OK);
12691         }
12692         LDKCVec_RouteHopZ path_var = path;
12693         int64_tArray path_arr = NULL;
12694         path_arr = (*env)->NewLongArray(env, path_var.datalen);
12695         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
12696         for (size_t k = 0; k < path_var.datalen; k++) {
12697                 LDKRouteHop path_conv_10_var = path_var.data[k];
12698                 uintptr_t path_conv_10_ref = 0;
12699                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12700                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12701                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
12702                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
12703                 if (path_conv_10_var.is_owned) {
12704                         path_conv_10_ref |= 1;
12705                 }
12706                 path_arr_ptr[k] = path_conv_10_ref;
12707         }
12708         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
12709         FREE(path_var.data);
12710         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12711         CHECK(obj != NULL);
12712         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
12713         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12714                 (*env)->ExceptionDescribe(env);
12715                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
12716         }
12717         if (get_jenv_res == JNI_EDETACHED) {
12718                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12719         }
12720 }
12721 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
12722         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
12723         JNIEnv *env;
12724         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12725         if (get_jenv_res == JNI_EDETACHED) {
12726                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12727         } else {
12728                 DO_ASSERT(get_jenv_res == JNI_OK);
12729         }
12730         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12731         CHECK(obj != NULL);
12732         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
12733         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12734                 (*env)->ExceptionDescribe(env);
12735                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
12736         }
12737         LDKCVec_u8Z ret_ref;
12738         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
12739         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
12740         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
12741         if (get_jenv_res == JNI_EDETACHED) {
12742                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12743         }
12744         return ret_ref;
12745 }
12746 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
12747         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
12748         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12749 }
12750 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
12751         jclass c = (*env)->GetObjectClass(env, o);
12752         CHECK(c != NULL);
12753         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
12754         atomic_init(&calls->refcnt, 1);
12755         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12756         calls->o = (*env)->NewWeakGlobalRef(env, o);
12757         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJJ)J");
12758         CHECK(calls->channel_penalty_msat_meth != NULL);
12759         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
12760         CHECK(calls->payment_path_failed_meth != NULL);
12761         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
12762         CHECK(calls->payment_path_successful_meth != NULL);
12763         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
12764         CHECK(calls->write_meth != NULL);
12765
12766         LDKScore ret = {
12767                 .this_arg = (void*) calls,
12768                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
12769                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
12770                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
12771                 .write = write_LDKScore_jcall,
12772                 .free = LDKScore_JCalls_free,
12773         };
12774         return ret;
12775 }
12776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
12777         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
12778         *res_ptr = LDKScore_init(env, clz, o);
12779         return (uint64_t)res_ptr;
12780 }
12781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t send_amt_msat, int64_t capacity_msat, int64_t source, int64_t target) {
12782         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12783         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12784         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
12785         LDKNodeId source_conv;
12786         source_conv.inner = (void*)(source & (~1));
12787         source_conv.is_owned = false;
12788         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
12789         LDKNodeId target_conv;
12790         target_conv.inner = (void*)(target & (~1));
12791         target_conv.is_owned = false;
12792         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
12793         int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, send_amt_msat, capacity_msat, &source_conv, &target_conv);
12794         return ret_val;
12795 }
12796
12797 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) {
12798         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12799         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12800         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
12801         LDKCVec_RouteHopZ path_constr;
12802         path_constr.datalen = (*env)->GetArrayLength(env, path);
12803         if (path_constr.datalen > 0)
12804                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12805         else
12806                 path_constr.data = NULL;
12807         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
12808         for (size_t k = 0; k < path_constr.datalen; k++) {
12809                 int64_t path_conv_10 = path_vals[k];
12810                 LDKRouteHop path_conv_10_conv;
12811                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
12812                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
12813                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
12814                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
12815                 path_constr.data[k] = path_conv_10_conv;
12816         }
12817         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
12818         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
12819 }
12820
12821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
12822         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12823         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12824         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
12825         LDKCVec_RouteHopZ path_constr;
12826         path_constr.datalen = (*env)->GetArrayLength(env, path);
12827         if (path_constr.datalen > 0)
12828                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12829         else
12830                 path_constr.data = NULL;
12831         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
12832         for (size_t k = 0; k < path_constr.datalen; k++) {
12833                 int64_t path_conv_10 = path_vals[k];
12834                 LDKRouteHop path_conv_10_conv;
12835                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
12836                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
12837                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
12838                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
12839                 path_constr.data[k] = path_conv_10_conv;
12840         }
12841         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
12842         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
12843 }
12844
12845 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
12846         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12847         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12848         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
12849         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
12850         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
12851         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
12852         CVec_u8Z_free(ret_var);
12853         return ret_arr;
12854 }
12855
12856 typedef struct LDKLockableScore_JCalls {
12857         atomic_size_t refcnt;
12858         JavaVM *vm;
12859         jweak o;
12860         jmethodID lock_meth;
12861 } LDKLockableScore_JCalls;
12862 static void LDKLockableScore_JCalls_free(void* this_arg) {
12863         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
12864         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12865                 JNIEnv *env;
12866                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12867                 if (get_jenv_res == JNI_EDETACHED) {
12868                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12869                 } else {
12870                         DO_ASSERT(get_jenv_res == JNI_OK);
12871                 }
12872                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12873                 if (get_jenv_res == JNI_EDETACHED) {
12874                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12875                 }
12876                 FREE(j_calls);
12877         }
12878 }
12879 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
12880         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
12881         JNIEnv *env;
12882         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12883         if (get_jenv_res == JNI_EDETACHED) {
12884                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12885         } else {
12886                 DO_ASSERT(get_jenv_res == JNI_OK);
12887         }
12888         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12889         CHECK(obj != NULL);
12890         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
12891         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12892                 (*env)->ExceptionDescribe(env);
12893                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
12894         }
12895         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12896         CHECK_ACCESS(ret_ptr);
12897         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
12898         if (ret_conv.free == LDKScore_JCalls_free) {
12899                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12900                 LDKScore_JCalls_cloned(&ret_conv);
12901         }// WARNING: we may need a move here but no clone is available for LDKScore
12902         
12903         if (get_jenv_res == JNI_EDETACHED) {
12904                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12905         }
12906         return ret_conv;
12907 }
12908 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
12909         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
12910         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12911 }
12912 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
12913         jclass c = (*env)->GetObjectClass(env, o);
12914         CHECK(c != NULL);
12915         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
12916         atomic_init(&calls->refcnt, 1);
12917         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12918         calls->o = (*env)->NewWeakGlobalRef(env, o);
12919         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
12920         CHECK(calls->lock_meth != NULL);
12921
12922         LDKLockableScore ret = {
12923                 .this_arg = (void*) calls,
12924                 .lock = lock_LDKLockableScore_jcall,
12925                 .free = LDKLockableScore_JCalls_free,
12926         };
12927         return ret;
12928 }
12929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
12930         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
12931         *res_ptr = LDKLockableScore_init(env, clz, o);
12932         return (uint64_t)res_ptr;
12933 }
12934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
12935         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12936         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12937         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
12938         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
12939         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
12940         return (uintptr_t)ret_ret;
12941 }
12942
12943 typedef struct LDKChannelManagerPersister_JCalls {
12944         atomic_size_t refcnt;
12945         JavaVM *vm;
12946         jweak o;
12947         jmethodID persist_manager_meth;
12948 } LDKChannelManagerPersister_JCalls;
12949 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
12950         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
12951         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12952                 JNIEnv *env;
12953                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12954                 if (get_jenv_res == JNI_EDETACHED) {
12955                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12956                 } else {
12957                         DO_ASSERT(get_jenv_res == JNI_OK);
12958                 }
12959                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12960                 if (get_jenv_res == JNI_EDETACHED) {
12961                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12962                 }
12963                 FREE(j_calls);
12964         }
12965 }
12966 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
12967         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
12968         JNIEnv *env;
12969         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12970         if (get_jenv_res == JNI_EDETACHED) {
12971                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12972         } else {
12973                 DO_ASSERT(get_jenv_res == JNI_OK);
12974         }
12975         LDKChannelManager channel_manager_var = *channel_manager;
12976         uintptr_t channel_manager_ref = 0;
12977         // WARNING: we may need a move here but no clone is available for LDKChannelManager
12978         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12979         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12980         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
12981         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
12982         if (channel_manager_var.is_owned) {
12983                 channel_manager_ref |= 1;
12984         }
12985         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12986         CHECK(obj != NULL);
12987         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
12988         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12989                 (*env)->ExceptionDescribe(env);
12990                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
12991         }
12992         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12993         CHECK_ACCESS(ret_ptr);
12994         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
12995         FREE((void*)ret);
12996         if (get_jenv_res == JNI_EDETACHED) {
12997                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12998         }
12999         return ret_conv;
13000 }
13001 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
13002         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
13003         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13004 }
13005 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
13006         jclass c = (*env)->GetObjectClass(env, o);
13007         CHECK(c != NULL);
13008         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
13009         atomic_init(&calls->refcnt, 1);
13010         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13011         calls->o = (*env)->NewWeakGlobalRef(env, o);
13012         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
13013         CHECK(calls->persist_manager_meth != NULL);
13014
13015         LDKChannelManagerPersister ret = {
13016                 .this_arg = (void*) calls,
13017                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
13018                 .free = LDKChannelManagerPersister_JCalls_free,
13019         };
13020         return ret;
13021 }
13022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
13023         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
13024         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
13025         return (uint64_t)res_ptr;
13026 }
13027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
13028         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13029         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13030         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)this_arg_ptr;
13031         LDKChannelManager channel_manager_conv;
13032         channel_manager_conv.inner = (void*)(channel_manager & (~1));
13033         channel_manager_conv.is_owned = false;
13034         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
13035         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
13036         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
13037         return (uintptr_t)ret_conv;
13038 }
13039
13040 static jclass LDKFallback_SegWitProgram_class = NULL;
13041 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
13042 static jclass LDKFallback_PubKeyHash_class = NULL;
13043 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
13044 static jclass LDKFallback_ScriptHash_class = NULL;
13045 static jmethodID LDKFallback_ScriptHash_meth = NULL;
13046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
13047         LDKFallback_SegWitProgram_class =
13048                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
13049         CHECK(LDKFallback_SegWitProgram_class != NULL);
13050         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
13051         CHECK(LDKFallback_SegWitProgram_meth != NULL);
13052         LDKFallback_PubKeyHash_class =
13053                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
13054         CHECK(LDKFallback_PubKeyHash_class != NULL);
13055         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
13056         CHECK(LDKFallback_PubKeyHash_meth != NULL);
13057         LDKFallback_ScriptHash_class =
13058                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
13059         CHECK(LDKFallback_ScriptHash_class != NULL);
13060         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
13061         CHECK(LDKFallback_ScriptHash_meth != NULL);
13062 }
13063 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
13064         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
13065         switch(obj->tag) {
13066                 case LDKFallback_SegWitProgram: {
13067                         uint8_t version_val = obj->seg_wit_program.version._0;
13068                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
13069                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
13070                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
13071                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
13072                 }
13073                 case LDKFallback_PubKeyHash: {
13074                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
13075                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
13076                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
13077                 }
13078                 case LDKFallback_ScriptHash: {
13079                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
13080                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
13081                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
13082                 }
13083                 default: abort();
13084         }
13085 }
13086 typedef struct LDKPayer_JCalls {
13087         atomic_size_t refcnt;
13088         JavaVM *vm;
13089         jweak o;
13090         jmethodID node_id_meth;
13091         jmethodID first_hops_meth;
13092         jmethodID send_payment_meth;
13093         jmethodID send_spontaneous_payment_meth;
13094         jmethodID retry_payment_meth;
13095         jmethodID abandon_payment_meth;
13096 } LDKPayer_JCalls;
13097 static void LDKPayer_JCalls_free(void* this_arg) {
13098         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13099         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13100                 JNIEnv *env;
13101                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13102                 if (get_jenv_res == JNI_EDETACHED) {
13103                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13104                 } else {
13105                         DO_ASSERT(get_jenv_res == JNI_OK);
13106                 }
13107                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13108                 if (get_jenv_res == JNI_EDETACHED) {
13109                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13110                 }
13111                 FREE(j_calls);
13112         }
13113 }
13114 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
13115         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13116         JNIEnv *env;
13117         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13118         if (get_jenv_res == JNI_EDETACHED) {
13119                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13120         } else {
13121                 DO_ASSERT(get_jenv_res == JNI_OK);
13122         }
13123         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13124         CHECK(obj != NULL);
13125         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
13126         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13127                 (*env)->ExceptionDescribe(env);
13128                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
13129         }
13130         LDKPublicKey ret_ref;
13131         CHECK((*env)->GetArrayLength(env, ret) == 33);
13132         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
13133         if (get_jenv_res == JNI_EDETACHED) {
13134                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13135         }
13136         return ret_ref;
13137 }
13138 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
13139         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13140         JNIEnv *env;
13141         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13142         if (get_jenv_res == JNI_EDETACHED) {
13143                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13144         } else {
13145                 DO_ASSERT(get_jenv_res == JNI_OK);
13146         }
13147         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13148         CHECK(obj != NULL);
13149         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
13150         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13151                 (*env)->ExceptionDescribe(env);
13152                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
13153         }
13154         LDKCVec_ChannelDetailsZ ret_constr;
13155         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13156         if (ret_constr.datalen > 0)
13157                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
13158         else
13159                 ret_constr.data = NULL;
13160         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13161         for (size_t q = 0; q < ret_constr.datalen; q++) {
13162                 int64_t ret_conv_16 = ret_vals[q];
13163                 LDKChannelDetails ret_conv_16_conv;
13164                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
13165                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
13166                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
13167                 ret_constr.data[q] = ret_conv_16_conv;
13168         }
13169         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13170         if (get_jenv_res == JNI_EDETACHED) {
13171                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13172         }
13173         return ret_constr;
13174 }
13175 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
13176         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13177         JNIEnv *env;
13178         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13179         if (get_jenv_res == JNI_EDETACHED) {
13180                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13181         } else {
13182                 DO_ASSERT(get_jenv_res == JNI_OK);
13183         }
13184         LDKRoute route_var = *route;
13185         uintptr_t route_ref = 0;
13186         route_var = Route_clone(route);
13187         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13188         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13189         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13190         route_ref = (uintptr_t)route_var.inner;
13191         if (route_var.is_owned) {
13192                 route_ref |= 1;
13193         }
13194         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
13195         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
13196         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
13197         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
13198         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13199         CHECK(obj != NULL);
13200         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
13201         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13202                 (*env)->ExceptionDescribe(env);
13203                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
13204         }
13205         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13206         CHECK_ACCESS(ret_ptr);
13207         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
13208         FREE((void*)ret);
13209         if (get_jenv_res == JNI_EDETACHED) {
13210                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13211         }
13212         return ret_conv;
13213 }
13214 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
13215         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13216         JNIEnv *env;
13217         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13218         if (get_jenv_res == JNI_EDETACHED) {
13219                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13220         } else {
13221                 DO_ASSERT(get_jenv_res == JNI_OK);
13222         }
13223         LDKRoute route_var = *route;
13224         uintptr_t route_ref = 0;
13225         route_var = Route_clone(route);
13226         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13227         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13228         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13229         route_ref = (uintptr_t)route_var.inner;
13230         if (route_var.is_owned) {
13231                 route_ref |= 1;
13232         }
13233         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
13234         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
13235         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13236         CHECK(obj != NULL);
13237         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
13238         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13239                 (*env)->ExceptionDescribe(env);
13240                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
13241         }
13242         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13243         CHECK_ACCESS(ret_ptr);
13244         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(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_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
13252         LDKPayer_JCalls *j_calls = (LDKPayer_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         LDKRoute route_var = *route;
13261         uintptr_t route_ref = 0;
13262         route_var = Route_clone(route);
13263         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13264         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13265         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13266         route_ref = (uintptr_t)route_var.inner;
13267         if (route_var.is_owned) {
13268                 route_ref |= 1;
13269         }
13270         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
13271         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
13272         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13273         CHECK(obj != NULL);
13274         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
13275         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13276                 (*env)->ExceptionDescribe(env);
13277                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
13278         }
13279         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13280         CHECK_ACCESS(ret_ptr);
13281         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
13282         FREE((void*)ret);
13283         if (get_jenv_res == JNI_EDETACHED) {
13284                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13285         }
13286         return ret_conv;
13287 }
13288 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
13289         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13290         JNIEnv *env;
13291         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13292         if (get_jenv_res == JNI_EDETACHED) {
13293                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13294         } else {
13295                 DO_ASSERT(get_jenv_res == JNI_OK);
13296         }
13297         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
13298         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
13299         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13300         CHECK(obj != NULL);
13301         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
13302         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13303                 (*env)->ExceptionDescribe(env);
13304                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
13305         }
13306         if (get_jenv_res == JNI_EDETACHED) {
13307                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13308         }
13309 }
13310 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
13311         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
13312         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13313 }
13314 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
13315         jclass c = (*env)->GetObjectClass(env, o);
13316         CHECK(c != NULL);
13317         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
13318         atomic_init(&calls->refcnt, 1);
13319         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13320         calls->o = (*env)->NewWeakGlobalRef(env, o);
13321         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
13322         CHECK(calls->node_id_meth != NULL);
13323         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
13324         CHECK(calls->first_hops_meth != NULL);
13325         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
13326         CHECK(calls->send_payment_meth != NULL);
13327         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
13328         CHECK(calls->send_spontaneous_payment_meth != NULL);
13329         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
13330         CHECK(calls->retry_payment_meth != NULL);
13331         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
13332         CHECK(calls->abandon_payment_meth != NULL);
13333
13334         LDKPayer ret = {
13335                 .this_arg = (void*) calls,
13336                 .node_id = node_id_LDKPayer_jcall,
13337                 .first_hops = first_hops_LDKPayer_jcall,
13338                 .send_payment = send_payment_LDKPayer_jcall,
13339                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
13340                 .retry_payment = retry_payment_LDKPayer_jcall,
13341                 .abandon_payment = abandon_payment_LDKPayer_jcall,
13342                 .free = LDKPayer_JCalls_free,
13343         };
13344         return ret;
13345 }
13346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
13347         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
13348         *res_ptr = LDKPayer_init(env, clz, o);
13349         return (uint64_t)res_ptr;
13350 }
13351 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
13352         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13353         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13354         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13355         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13356         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
13357         return ret_arr;
13358 }
13359
13360 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
13361         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13362         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13363         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13364         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
13365         int64_tArray ret_arr = NULL;
13366         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13367         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13368         for (size_t q = 0; q < ret_var.datalen; q++) {
13369                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13370                 uintptr_t ret_conv_16_ref = 0;
13371                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13372                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13373                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
13374                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
13375                 if (ret_conv_16_var.is_owned) {
13376                         ret_conv_16_ref |= 1;
13377                 }
13378                 ret_arr_ptr[q] = ret_conv_16_ref;
13379         }
13380         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13381         FREE(ret_var.data);
13382         return ret_arr;
13383 }
13384
13385 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) {
13386         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13387         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13388         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13389         LDKRoute route_conv;
13390         route_conv.inner = (void*)(route & (~1));
13391         route_conv.is_owned = false;
13392         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13393         LDKThirtyTwoBytes payment_hash_ref;
13394         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13395         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
13396         LDKThirtyTwoBytes payment_secret_ref;
13397         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
13398         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
13399         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13400         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
13401         return (uintptr_t)ret_conv;
13402 }
13403
13404 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) {
13405         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13406         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13407         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13408         LDKRoute route_conv;
13409         route_conv.inner = (void*)(route & (~1));
13410         route_conv.is_owned = false;
13411         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13412         LDKThirtyTwoBytes payment_preimage_ref;
13413         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
13414         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
13415         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13416         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
13417         return (uintptr_t)ret_conv;
13418 }
13419
13420 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) {
13421         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13422         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13423         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13424         LDKRoute route_conv;
13425         route_conv.inner = (void*)(route & (~1));
13426         route_conv.is_owned = false;
13427         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13428         LDKThirtyTwoBytes payment_id_ref;
13429         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
13430         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
13431         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13432         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
13433         return (uintptr_t)ret_conv;
13434 }
13435
13436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
13437         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13438         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13439         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13440         LDKThirtyTwoBytes payment_id_ref;
13441         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
13442         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
13443         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
13444 }
13445
13446 typedef struct LDKRouter_JCalls {
13447         atomic_size_t refcnt;
13448         JavaVM *vm;
13449         jweak o;
13450         jmethodID find_route_meth;
13451 } LDKRouter_JCalls;
13452 static void LDKRouter_JCalls_free(void* this_arg) {
13453         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
13454         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13455                 JNIEnv *env;
13456                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13457                 if (get_jenv_res == JNI_EDETACHED) {
13458                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13459                 } else {
13460                         DO_ASSERT(get_jenv_res == JNI_OK);
13461                 }
13462                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13463                 if (get_jenv_res == JNI_EDETACHED) {
13464                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13465                 }
13466                 FREE(j_calls);
13467         }
13468 }
13469 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) {
13470         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
13471         JNIEnv *env;
13472         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13473         if (get_jenv_res == JNI_EDETACHED) {
13474                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13475         } else {
13476                 DO_ASSERT(get_jenv_res == JNI_OK);
13477         }
13478         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
13479         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
13480         LDKRouteParameters route_params_var = *route_params;
13481         uintptr_t route_params_ref = 0;
13482         route_params_var = RouteParameters_clone(route_params);
13483         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13484         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13485         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
13486         route_params_ref = (uintptr_t)route_params_var.inner;
13487         if (route_params_var.is_owned) {
13488                 route_params_ref |= 1;
13489         }
13490         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
13491         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, *payment_hash);
13492         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
13493         int64_tArray first_hops_arr = NULL;
13494         if (first_hops != NULL) {
13495                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
13496                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
13497                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
13498                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
13499                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
13500                         uintptr_t first_hops_conv_16_ref = 0;
13501                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13502                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13503                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
13504                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
13505                         if (first_hops_conv_16_var.is_owned) {
13506                                 first_hops_conv_16_ref |= 1;
13507                         }
13508                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
13509                 }
13510                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
13511         }
13512         // WARNING: This object doesn't live past this scope, needs clone!
13513         uintptr_t ret_scorer = ((uintptr_t)scorer) | 1;
13514         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13515         CHECK(obj != NULL);
13516         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);
13517         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13518                 (*env)->ExceptionDescribe(env);
13519                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
13520         }
13521         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13522         CHECK_ACCESS(ret_ptr);
13523         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
13524         FREE((void*)ret);
13525         if (get_jenv_res == JNI_EDETACHED) {
13526                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13527         }
13528         return ret_conv;
13529 }
13530 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
13531         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
13532         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13533 }
13534 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
13535         jclass c = (*env)->GetObjectClass(env, o);
13536         CHECK(c != NULL);
13537         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
13538         atomic_init(&calls->refcnt, 1);
13539         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13540         calls->o = (*env)->NewWeakGlobalRef(env, o);
13541         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[B[JJ)J");
13542         CHECK(calls->find_route_meth != NULL);
13543
13544         LDKRouter ret = {
13545                 .this_arg = (void*) calls,
13546                 .find_route = find_route_LDKRouter_jcall,
13547                 .free = LDKRouter_JCalls_free,
13548         };
13549         return ret;
13550 }
13551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
13552         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
13553         *res_ptr = LDKRouter_init(env, clz, o);
13554         return (uint64_t)res_ptr;
13555 }
13556 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) {
13557         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13558         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13559         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
13560         LDKPublicKey payer_ref;
13561         CHECK((*env)->GetArrayLength(env, payer) == 33);
13562         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
13563         LDKRouteParameters route_params_conv;
13564         route_params_conv.inner = (void*)(route_params & (~1));
13565         route_params_conv.is_owned = false;
13566         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
13567         unsigned char payment_hash_arr[32];
13568         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13569         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
13570         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
13571         LDKCVec_ChannelDetailsZ first_hops_constr;
13572         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
13573         if (first_hops != NULL) {
13574                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
13575                 if (first_hops_constr.datalen > 0)
13576                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
13577                 else
13578                         first_hops_constr.data = NULL;
13579                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
13580                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
13581                         int64_t first_hops_conv_16 = first_hops_vals[q];
13582                         LDKChannelDetails first_hops_conv_16_conv;
13583                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
13584                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
13585                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
13586                         first_hops_constr.data[q] = first_hops_conv_16_conv;
13587                 }
13588                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
13589                 first_hops_ptr = &first_hops_constr;
13590         }
13591         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
13592         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
13593         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
13594         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
13595         *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);
13596         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
13597         return (uintptr_t)ret_conv;
13598 }
13599
13600 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
13601         LDKStr ret_str = _ldk_get_compiled_version();
13602         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
13603         Str_free(ret_str);
13604         return ret_conv;
13605 }
13606
13607 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
13608         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
13609         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
13610         Str_free(ret_str);
13611         return ret_conv;
13612 }
13613
13614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
13615         LDKTransaction _res_ref;
13616         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
13617         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
13618         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
13619         _res_ref.data_is_owned = true;
13620         Transaction_free(_res_ref);
13621 }
13622
13623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
13624         LDKCVec_u8Z script_pubkey_ref;
13625         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
13626         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
13627         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
13628         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
13629         *ret_ref = TxOut_new(script_pubkey_ref, value);
13630         return (uintptr_t)ret_ref;
13631 }
13632
13633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
13634         if ((_res & 1) != 0) return;
13635         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13636         CHECK_ACCESS(_res_ptr);
13637         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
13638         FREE((void*)_res);
13639         TxOut_free(_res_conv);
13640 }
13641
13642 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
13643         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
13644         *ret_ref = TxOut_clone(arg);
13645         return (uintptr_t)ret_ref;
13646 }
13647 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13648         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
13649         intptr_t ret_val = TxOut_clone_ptr(arg_conv);
13650         return ret_val;
13651 }
13652
13653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13654         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
13655         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
13656         *ret_ref = TxOut_clone(orig_conv);
13657         return (uintptr_t)ret_ref;
13658 }
13659
13660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
13661         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
13662         Str_free(dummy);
13663 }
13664
13665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
13666         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13667         *ret_conv = CResult_NoneNoneZ_ok();
13668         return (uintptr_t)ret_conv;
13669 }
13670
13671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
13672         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13673         *ret_conv = CResult_NoneNoneZ_err();
13674         return (uintptr_t)ret_conv;
13675 }
13676
13677 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13678         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
13679         jboolean ret_val = CResult_NoneNoneZ_is_ok(o_conv);
13680         return ret_val;
13681 }
13682
13683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13684         if ((_res & 1) != 0) return;
13685         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13686         CHECK_ACCESS(_res_ptr);
13687         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
13688         FREE((void*)_res);
13689         CResult_NoneNoneZ_free(_res_conv);
13690 }
13691
13692 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
13693         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13694         *ret_conv = CResult_NoneNoneZ_clone(arg);
13695         return (uintptr_t)ret_conv;
13696 }
13697 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13698         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
13699         intptr_t ret_val = CResult_NoneNoneZ_clone_ptr(arg_conv);
13700         return ret_val;
13701 }
13702
13703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13704         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
13705         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13706         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
13707         return (uintptr_t)ret_conv;
13708 }
13709
13710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13711         LDKCounterpartyCommitmentSecrets o_conv;
13712         o_conv.inner = (void*)(o & (~1));
13713         o_conv.is_owned = (o & 1) || (o == 0);
13714         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13715         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
13716         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
13717         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
13718         return (uintptr_t)ret_conv;
13719 }
13720
13721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13722         LDKDecodeError e_conv;
13723         e_conv.inner = (void*)(e & (~1));
13724         e_conv.is_owned = (e & 1) || (e == 0);
13725         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13726         e_conv = DecodeError_clone(&e_conv);
13727         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
13728         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
13729         return (uintptr_t)ret_conv;
13730 }
13731
13732 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13733         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
13734         jboolean ret_val = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
13735         return ret_val;
13736 }
13737
13738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13739         if ((_res & 1) != 0) return;
13740         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13741         CHECK_ACCESS(_res_ptr);
13742         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
13743         FREE((void*)_res);
13744         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
13745 }
13746
13747 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
13748         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
13749         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
13750         return (uintptr_t)ret_conv;
13751 }
13752 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13753         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
13754         intptr_t ret_val = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
13755         return ret_val;
13756 }
13757
13758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13759         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
13760         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
13761         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
13762         return (uintptr_t)ret_conv;
13763 }
13764
13765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13766         LDKSecretKey o_ref;
13767         CHECK((*env)->GetArrayLength(env, o) == 32);
13768         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
13769         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
13770         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
13771         return (uintptr_t)ret_conv;
13772 }
13773
13774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13775         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
13776         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
13777         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
13778         return (uintptr_t)ret_conv;
13779 }
13780
13781 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13782         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
13783         jboolean ret_val = CResult_SecretKeyErrorZ_is_ok(o_conv);
13784         return ret_val;
13785 }
13786
13787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13788         if ((_res & 1) != 0) return;
13789         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13790         CHECK_ACCESS(_res_ptr);
13791         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
13792         FREE((void*)_res);
13793         CResult_SecretKeyErrorZ_free(_res_conv);
13794 }
13795
13796 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
13797         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
13798         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
13799         return (uintptr_t)ret_conv;
13800 }
13801 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13802         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
13803         intptr_t ret_val = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
13804         return ret_val;
13805 }
13806
13807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13808         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
13809         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
13810         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
13811         return (uintptr_t)ret_conv;
13812 }
13813
13814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13815         LDKPublicKey o_ref;
13816         CHECK((*env)->GetArrayLength(env, o) == 33);
13817         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
13818         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13819         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
13820         return (uintptr_t)ret_conv;
13821 }
13822
13823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13824         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
13825         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13826         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
13827         return (uintptr_t)ret_conv;
13828 }
13829
13830 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13831         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
13832         jboolean ret_val = CResult_PublicKeyErrorZ_is_ok(o_conv);
13833         return ret_val;
13834 }
13835
13836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13837         if ((_res & 1) != 0) return;
13838         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13839         CHECK_ACCESS(_res_ptr);
13840         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
13841         FREE((void*)_res);
13842         CResult_PublicKeyErrorZ_free(_res_conv);
13843 }
13844
13845 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
13846         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13847         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
13848         return (uintptr_t)ret_conv;
13849 }
13850 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13851         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
13852         intptr_t ret_val = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
13853         return ret_val;
13854 }
13855
13856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13857         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
13858         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13859         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
13860         return (uintptr_t)ret_conv;
13861 }
13862
13863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13864         LDKTxCreationKeys o_conv;
13865         o_conv.inner = (void*)(o & (~1));
13866         o_conv.is_owned = (o & 1) || (o == 0);
13867         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13868         o_conv = TxCreationKeys_clone(&o_conv);
13869         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
13870         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
13871         return (uintptr_t)ret_conv;
13872 }
13873
13874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13875         LDKDecodeError e_conv;
13876         e_conv.inner = (void*)(e & (~1));
13877         e_conv.is_owned = (e & 1) || (e == 0);
13878         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13879         e_conv = DecodeError_clone(&e_conv);
13880         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
13881         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
13882         return (uintptr_t)ret_conv;
13883 }
13884
13885 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13886         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
13887         jboolean ret_val = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
13888         return ret_val;
13889 }
13890
13891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13892         if ((_res & 1) != 0) return;
13893         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13894         CHECK_ACCESS(_res_ptr);
13895         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
13896         FREE((void*)_res);
13897         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
13898 }
13899
13900 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
13901         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
13902         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
13903         return (uintptr_t)ret_conv;
13904 }
13905 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13906         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
13907         intptr_t ret_val = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
13908         return ret_val;
13909 }
13910
13911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13912         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
13913         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
13914         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
13915         return (uintptr_t)ret_conv;
13916 }
13917
13918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13919         LDKChannelPublicKeys o_conv;
13920         o_conv.inner = (void*)(o & (~1));
13921         o_conv.is_owned = (o & 1) || (o == 0);
13922         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13923         o_conv = ChannelPublicKeys_clone(&o_conv);
13924         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
13925         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
13926         return (uintptr_t)ret_conv;
13927 }
13928
13929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13930         LDKDecodeError e_conv;
13931         e_conv.inner = (void*)(e & (~1));
13932         e_conv.is_owned = (e & 1) || (e == 0);
13933         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13934         e_conv = DecodeError_clone(&e_conv);
13935         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
13936         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
13937         return (uintptr_t)ret_conv;
13938 }
13939
13940 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13941         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
13942         jboolean ret_val = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
13943         return ret_val;
13944 }
13945
13946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13947         if ((_res & 1) != 0) return;
13948         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13949         CHECK_ACCESS(_res_ptr);
13950         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
13951         FREE((void*)_res);
13952         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
13953 }
13954
13955 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
13956         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
13957         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
13958         return (uintptr_t)ret_conv;
13959 }
13960 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13961         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
13962         intptr_t ret_val = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
13963         return ret_val;
13964 }
13965
13966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13967         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
13968         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
13969         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
13970         return (uintptr_t)ret_conv;
13971 }
13972
13973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13974         LDKTxCreationKeys o_conv;
13975         o_conv.inner = (void*)(o & (~1));
13976         o_conv.is_owned = (o & 1) || (o == 0);
13977         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13978         o_conv = TxCreationKeys_clone(&o_conv);
13979         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
13980         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
13981         return (uintptr_t)ret_conv;
13982 }
13983
13984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13985         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
13986         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
13987         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
13988         return (uintptr_t)ret_conv;
13989 }
13990
13991 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13992         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
13993         jboolean ret_val = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
13994         return ret_val;
13995 }
13996
13997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13998         if ((_res & 1) != 0) return;
13999         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14000         CHECK_ACCESS(_res_ptr);
14001         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
14002         FREE((void*)_res);
14003         CResult_TxCreationKeysErrorZ_free(_res_conv);
14004 }
14005
14006 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
14007         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14008         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
14009         return (uintptr_t)ret_conv;
14010 }
14011 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14012         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
14013         intptr_t ret_val = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
14014         return ret_val;
14015 }
14016
14017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14018         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
14019         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14020         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
14021         return (uintptr_t)ret_conv;
14022 }
14023
14024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
14025         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14026         *ret_copy = COption_u32Z_some(o);
14027         uintptr_t ret_ref = (uintptr_t)ret_copy;
14028         return ret_ref;
14029 }
14030
14031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
14032         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14033         *ret_copy = COption_u32Z_none();
14034         uintptr_t ret_ref = (uintptr_t)ret_copy;
14035         return ret_ref;
14036 }
14037
14038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
14039         if ((_res & 1) != 0) return;
14040         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14041         CHECK_ACCESS(_res_ptr);
14042         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
14043         FREE((void*)_res);
14044         COption_u32Z_free(_res_conv);
14045 }
14046
14047 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
14048         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14049         *ret_copy = COption_u32Z_clone(arg);
14050 uintptr_t ret_ref = (uintptr_t)ret_copy;
14051         return ret_ref;
14052 }
14053 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14054         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
14055         intptr_t ret_val = COption_u32Z_clone_ptr(arg_conv);
14056         return ret_val;
14057 }
14058
14059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14060         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
14061         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14062         *ret_copy = COption_u32Z_clone(orig_conv);
14063         uintptr_t ret_ref = (uintptr_t)ret_copy;
14064         return ret_ref;
14065 }
14066
14067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14068         LDKHTLCOutputInCommitment o_conv;
14069         o_conv.inner = (void*)(o & (~1));
14070         o_conv.is_owned = (o & 1) || (o == 0);
14071         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14072         o_conv = HTLCOutputInCommitment_clone(&o_conv);
14073         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14074         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
14075         return (uintptr_t)ret_conv;
14076 }
14077
14078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14079         LDKDecodeError e_conv;
14080         e_conv.inner = (void*)(e & (~1));
14081         e_conv.is_owned = (e & 1) || (e == 0);
14082         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14083         e_conv = DecodeError_clone(&e_conv);
14084         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14085         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
14086         return (uintptr_t)ret_conv;
14087 }
14088
14089 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14090         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
14091         jboolean ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
14092         return ret_val;
14093 }
14094
14095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14096         if ((_res & 1) != 0) return;
14097         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14098         CHECK_ACCESS(_res_ptr);
14099         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
14100         FREE((void*)_res);
14101         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
14102 }
14103
14104 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
14105         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14106         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
14107         return (uintptr_t)ret_conv;
14108 }
14109 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14110         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
14111         intptr_t ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
14112         return ret_val;
14113 }
14114
14115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14116         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
14117         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14118         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
14119         return (uintptr_t)ret_conv;
14120 }
14121
14122 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
14123         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
14124         return ret_conv;
14125 }
14126
14127 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
14128         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
14129         return ret_conv;
14130 }
14131
14132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
14133         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
14134         COption_NoneZ_free(_res_conv);
14135 }
14136
14137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14138         LDKCounterpartyChannelTransactionParameters o_conv;
14139         o_conv.inner = (void*)(o & (~1));
14140         o_conv.is_owned = (o & 1) || (o == 0);
14141         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14142         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
14143         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14144         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
14145         return (uintptr_t)ret_conv;
14146 }
14147
14148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14149         LDKDecodeError e_conv;
14150         e_conv.inner = (void*)(e & (~1));
14151         e_conv.is_owned = (e & 1) || (e == 0);
14152         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14153         e_conv = DecodeError_clone(&e_conv);
14154         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14155         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
14156         return (uintptr_t)ret_conv;
14157 }
14158
14159 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14160         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
14161         jboolean ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
14162         return ret_val;
14163 }
14164
14165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14166         if ((_res & 1) != 0) return;
14167         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14168         CHECK_ACCESS(_res_ptr);
14169         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
14170         FREE((void*)_res);
14171         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
14172 }
14173
14174 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
14175         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14176         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
14177         return (uintptr_t)ret_conv;
14178 }
14179 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14180         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
14181         intptr_t ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
14182         return ret_val;
14183 }
14184
14185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14186         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
14187         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14188         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
14189         return (uintptr_t)ret_conv;
14190 }
14191
14192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14193         LDKChannelTransactionParameters o_conv;
14194         o_conv.inner = (void*)(o & (~1));
14195         o_conv.is_owned = (o & 1) || (o == 0);
14196         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14197         o_conv = ChannelTransactionParameters_clone(&o_conv);
14198         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14199         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
14200         return (uintptr_t)ret_conv;
14201 }
14202
14203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14204         LDKDecodeError e_conv;
14205         e_conv.inner = (void*)(e & (~1));
14206         e_conv.is_owned = (e & 1) || (e == 0);
14207         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14208         e_conv = DecodeError_clone(&e_conv);
14209         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14210         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
14211         return (uintptr_t)ret_conv;
14212 }
14213
14214 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14215         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
14216         jboolean ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
14217         return ret_val;
14218 }
14219
14220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14221         if ((_res & 1) != 0) return;
14222         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14223         CHECK_ACCESS(_res_ptr);
14224         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
14225         FREE((void*)_res);
14226         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
14227 }
14228
14229 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
14230         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14231         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
14232         return (uintptr_t)ret_conv;
14233 }
14234 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14235         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
14236         intptr_t ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
14237         return ret_val;
14238 }
14239
14240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14241         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
14242         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14243         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
14244         return (uintptr_t)ret_conv;
14245 }
14246
14247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
14248         LDKCVec_SignatureZ _res_constr;
14249         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14250         if (_res_constr.datalen > 0)
14251                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14252         else
14253                 _res_constr.data = NULL;
14254         for (size_t i = 0; i < _res_constr.datalen; i++) {
14255                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
14256                 LDKSignature _res_conv_8_ref;
14257                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
14258                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
14259                 _res_constr.data[i] = _res_conv_8_ref;
14260         }
14261         CVec_SignatureZ_free(_res_constr);
14262 }
14263
14264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14265         LDKHolderCommitmentTransaction o_conv;
14266         o_conv.inner = (void*)(o & (~1));
14267         o_conv.is_owned = (o & 1) || (o == 0);
14268         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14269         o_conv = HolderCommitmentTransaction_clone(&o_conv);
14270         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14271         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
14272         return (uintptr_t)ret_conv;
14273 }
14274
14275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14276         LDKDecodeError e_conv;
14277         e_conv.inner = (void*)(e & (~1));
14278         e_conv.is_owned = (e & 1) || (e == 0);
14279         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14280         e_conv = DecodeError_clone(&e_conv);
14281         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14282         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
14283         return (uintptr_t)ret_conv;
14284 }
14285
14286 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14287         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
14288         jboolean ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14289         return ret_val;
14290 }
14291
14292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14293         if ((_res & 1) != 0) return;
14294         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14295         CHECK_ACCESS(_res_ptr);
14296         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
14297         FREE((void*)_res);
14298         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
14299 }
14300
14301 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14302         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14303         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
14304         return (uintptr_t)ret_conv;
14305 }
14306 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14307         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
14308         intptr_t ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14309         return ret_val;
14310 }
14311
14312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14313         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
14314         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14315         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
14316         return (uintptr_t)ret_conv;
14317 }
14318
14319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14320         LDKBuiltCommitmentTransaction o_conv;
14321         o_conv.inner = (void*)(o & (~1));
14322         o_conv.is_owned = (o & 1) || (o == 0);
14323         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14324         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
14325         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14326         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
14327         return (uintptr_t)ret_conv;
14328 }
14329
14330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14331         LDKDecodeError e_conv;
14332         e_conv.inner = (void*)(e & (~1));
14333         e_conv.is_owned = (e & 1) || (e == 0);
14334         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14335         e_conv = DecodeError_clone(&e_conv);
14336         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14337         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
14338         return (uintptr_t)ret_conv;
14339 }
14340
14341 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14342         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
14343         jboolean ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14344         return ret_val;
14345 }
14346
14347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14348         if ((_res & 1) != 0) return;
14349         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14350         CHECK_ACCESS(_res_ptr);
14351         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
14352         FREE((void*)_res);
14353         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
14354 }
14355
14356 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14357         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14358         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
14359         return (uintptr_t)ret_conv;
14360 }
14361 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14362         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
14363         intptr_t ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14364         return ret_val;
14365 }
14366
14367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14368         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
14369         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14370         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
14371         return (uintptr_t)ret_conv;
14372 }
14373
14374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14375         LDKTrustedClosingTransaction o_conv;
14376         o_conv.inner = (void*)(o & (~1));
14377         o_conv.is_owned = (o & 1) || (o == 0);
14378         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14379         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
14380         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
14381         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
14382         return (uintptr_t)ret_conv;
14383 }
14384
14385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
14386         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
14387         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
14388         return (uintptr_t)ret_conv;
14389 }
14390
14391 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14392         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
14393         jboolean ret_val = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
14394         return ret_val;
14395 }
14396
14397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14398         if ((_res & 1) != 0) return;
14399         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14400         CHECK_ACCESS(_res_ptr);
14401         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
14402         FREE((void*)_res);
14403         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
14404 }
14405
14406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14407         LDKCommitmentTransaction o_conv;
14408         o_conv.inner = (void*)(o & (~1));
14409         o_conv.is_owned = (o & 1) || (o == 0);
14410         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14411         o_conv = CommitmentTransaction_clone(&o_conv);
14412         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14413         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
14414         return (uintptr_t)ret_conv;
14415 }
14416
14417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14418         LDKDecodeError e_conv;
14419         e_conv.inner = (void*)(e & (~1));
14420         e_conv.is_owned = (e & 1) || (e == 0);
14421         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14422         e_conv = DecodeError_clone(&e_conv);
14423         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14424         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
14425         return (uintptr_t)ret_conv;
14426 }
14427
14428 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14429         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
14430         jboolean ret_val = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14431         return ret_val;
14432 }
14433
14434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14435         if ((_res & 1) != 0) return;
14436         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14437         CHECK_ACCESS(_res_ptr);
14438         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
14439         FREE((void*)_res);
14440         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
14441 }
14442
14443 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14444         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14445         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
14446         return (uintptr_t)ret_conv;
14447 }
14448 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14449         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
14450         intptr_t ret_val = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14451         return ret_val;
14452 }
14453
14454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14455         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
14456         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14457         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
14458         return (uintptr_t)ret_conv;
14459 }
14460
14461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14462         LDKTrustedCommitmentTransaction o_conv;
14463         o_conv.inner = (void*)(o & (~1));
14464         o_conv.is_owned = (o & 1) || (o == 0);
14465         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14466         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
14467         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
14468         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
14469         return (uintptr_t)ret_conv;
14470 }
14471
14472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
14473         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
14474         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
14475         return (uintptr_t)ret_conv;
14476 }
14477
14478 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14479         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
14480         jboolean ret_val = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
14481         return ret_val;
14482 }
14483
14484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14485         if ((_res & 1) != 0) return;
14486         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14487         CHECK_ACCESS(_res_ptr);
14488         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
14489         FREE((void*)_res);
14490         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
14491 }
14492
14493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
14494         LDKCVec_SignatureZ o_constr;
14495         o_constr.datalen = (*env)->GetArrayLength(env, o);
14496         if (o_constr.datalen > 0)
14497                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14498         else
14499                 o_constr.data = NULL;
14500         for (size_t i = 0; i < o_constr.datalen; i++) {
14501                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
14502                 LDKSignature o_conv_8_ref;
14503                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
14504                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
14505                 o_constr.data[i] = o_conv_8_ref;
14506         }
14507         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14508         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
14509         return (uintptr_t)ret_conv;
14510 }
14511
14512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
14513         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14514         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
14515         return (uintptr_t)ret_conv;
14516 }
14517
14518 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14519         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
14520         jboolean ret_val = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
14521         return ret_val;
14522 }
14523
14524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14525         if ((_res & 1) != 0) return;
14526         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14527         CHECK_ACCESS(_res_ptr);
14528         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
14529         FREE((void*)_res);
14530         CResult_CVec_SignatureZNoneZ_free(_res_conv);
14531 }
14532
14533 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
14534         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14535         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
14536         return (uintptr_t)ret_conv;
14537 }
14538 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14539         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
14540         intptr_t ret_val = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
14541         return ret_val;
14542 }
14543
14544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14545         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
14546         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14547         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
14548         return (uintptr_t)ret_conv;
14549 }
14550
14551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14552         LDKShutdownScript o_conv;
14553         o_conv.inner = (void*)(o & (~1));
14554         o_conv.is_owned = (o & 1) || (o == 0);
14555         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14556         o_conv = ShutdownScript_clone(&o_conv);
14557         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
14558         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
14559         return (uintptr_t)ret_conv;
14560 }
14561
14562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14563         LDKDecodeError e_conv;
14564         e_conv.inner = (void*)(e & (~1));
14565         e_conv.is_owned = (e & 1) || (e == 0);
14566         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14567         e_conv = DecodeError_clone(&e_conv);
14568         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
14569         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
14570         return (uintptr_t)ret_conv;
14571 }
14572
14573 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14574         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
14575         jboolean ret_val = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
14576         return ret_val;
14577 }
14578
14579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14580         if ((_res & 1) != 0) return;
14581         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14582         CHECK_ACCESS(_res_ptr);
14583         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
14584         FREE((void*)_res);
14585         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
14586 }
14587
14588 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
14589         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
14590         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
14591         return (uintptr_t)ret_conv;
14592 }
14593 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14594         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
14595         intptr_t ret_val = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
14596         return ret_val;
14597 }
14598
14599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14600         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
14601         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
14602         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
14603         return (uintptr_t)ret_conv;
14604 }
14605
14606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14607         LDKShutdownScript o_conv;
14608         o_conv.inner = (void*)(o & (~1));
14609         o_conv.is_owned = (o & 1) || (o == 0);
14610         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14611         o_conv = ShutdownScript_clone(&o_conv);
14612         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
14613         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
14614         return (uintptr_t)ret_conv;
14615 }
14616
14617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14618         LDKInvalidShutdownScript e_conv;
14619         e_conv.inner = (void*)(e & (~1));
14620         e_conv.is_owned = (e & 1) || (e == 0);
14621         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14622         e_conv = InvalidShutdownScript_clone(&e_conv);
14623         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
14624         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
14625         return (uintptr_t)ret_conv;
14626 }
14627
14628 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14629         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
14630         jboolean ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
14631         return ret_val;
14632 }
14633
14634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14635         if ((_res & 1) != 0) return;
14636         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14637         CHECK_ACCESS(_res_ptr);
14638         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
14639         FREE((void*)_res);
14640         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
14641 }
14642
14643 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
14644         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
14645         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
14646         return (uintptr_t)ret_conv;
14647 }
14648 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14649         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
14650         intptr_t ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
14651         return ret_val;
14652 }
14653
14654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14655         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
14656         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
14657         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
14658         return (uintptr_t)ret_conv;
14659 }
14660
14661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
14662         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
14663         *ret_conv = CResult_NoneErrorZ_ok();
14664         return (uintptr_t)ret_conv;
14665 }
14666
14667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14668         LDKIOError e_conv = LDKIOError_from_java(env, e);
14669         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
14670         *ret_conv = CResult_NoneErrorZ_err(e_conv);
14671         return (uintptr_t)ret_conv;
14672 }
14673
14674 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14675         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
14676         jboolean ret_val = CResult_NoneErrorZ_is_ok(o_conv);
14677         return ret_val;
14678 }
14679
14680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14681         if ((_res & 1) != 0) return;
14682         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14683         CHECK_ACCESS(_res_ptr);
14684         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
14685         FREE((void*)_res);
14686         CResult_NoneErrorZ_free(_res_conv);
14687 }
14688
14689 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
14690         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
14691         *ret_conv = CResult_NoneErrorZ_clone(arg);
14692         return (uintptr_t)ret_conv;
14693 }
14694 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14695         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
14696         intptr_t ret_val = CResult_NoneErrorZ_clone_ptr(arg_conv);
14697         return ret_val;
14698 }
14699
14700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14701         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
14702         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
14703         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
14704         return (uintptr_t)ret_conv;
14705 }
14706
14707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14708         LDKRouteHop o_conv;
14709         o_conv.inner = (void*)(o & (~1));
14710         o_conv.is_owned = (o & 1) || (o == 0);
14711         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14712         o_conv = RouteHop_clone(&o_conv);
14713         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
14714         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
14715         return (uintptr_t)ret_conv;
14716 }
14717
14718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14719         LDKDecodeError e_conv;
14720         e_conv.inner = (void*)(e & (~1));
14721         e_conv.is_owned = (e & 1) || (e == 0);
14722         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14723         e_conv = DecodeError_clone(&e_conv);
14724         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
14725         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
14726         return (uintptr_t)ret_conv;
14727 }
14728
14729 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14730         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
14731         jboolean ret_val = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
14732         return ret_val;
14733 }
14734
14735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14736         if ((_res & 1) != 0) return;
14737         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14738         CHECK_ACCESS(_res_ptr);
14739         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
14740         FREE((void*)_res);
14741         CResult_RouteHopDecodeErrorZ_free(_res_conv);
14742 }
14743
14744 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
14745         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
14746         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
14747         return (uintptr_t)ret_conv;
14748 }
14749 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14750         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
14751         intptr_t ret_val = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
14752         return ret_val;
14753 }
14754
14755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14756         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
14757         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
14758         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
14759         return (uintptr_t)ret_conv;
14760 }
14761
14762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14763         LDKCVec_RouteHopZ _res_constr;
14764         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14765         if (_res_constr.datalen > 0)
14766                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14767         else
14768                 _res_constr.data = NULL;
14769         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14770         for (size_t k = 0; k < _res_constr.datalen; k++) {
14771                 int64_t _res_conv_10 = _res_vals[k];
14772                 LDKRouteHop _res_conv_10_conv;
14773                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
14774                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
14775                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
14776                 _res_constr.data[k] = _res_conv_10_conv;
14777         }
14778         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14779         CVec_RouteHopZ_free(_res_constr);
14780 }
14781
14782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
14783         LDKCVec_CVec_RouteHopZZ _res_constr;
14784         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14785         if (_res_constr.datalen > 0)
14786                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
14787         else
14788                 _res_constr.data = NULL;
14789         for (size_t m = 0; m < _res_constr.datalen; m++) {
14790                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
14791                 LDKCVec_RouteHopZ _res_conv_12_constr;
14792                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
14793                 if (_res_conv_12_constr.datalen > 0)
14794                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14795                 else
14796                         _res_conv_12_constr.data = NULL;
14797                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
14798                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
14799                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
14800                         LDKRouteHop _res_conv_12_conv_10_conv;
14801                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
14802                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
14803                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
14804                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
14805                 }
14806                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
14807                 _res_constr.data[m] = _res_conv_12_constr;
14808         }
14809         CVec_CVec_RouteHopZZ_free(_res_constr);
14810 }
14811
14812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14813         LDKRoute o_conv;
14814         o_conv.inner = (void*)(o & (~1));
14815         o_conv.is_owned = (o & 1) || (o == 0);
14816         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14817         o_conv = Route_clone(&o_conv);
14818         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14819         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
14820         return (uintptr_t)ret_conv;
14821 }
14822
14823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14824         LDKDecodeError e_conv;
14825         e_conv.inner = (void*)(e & (~1));
14826         e_conv.is_owned = (e & 1) || (e == 0);
14827         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14828         e_conv = DecodeError_clone(&e_conv);
14829         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14830         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
14831         return (uintptr_t)ret_conv;
14832 }
14833
14834 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14835         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
14836         jboolean ret_val = CResult_RouteDecodeErrorZ_is_ok(o_conv);
14837         return ret_val;
14838 }
14839
14840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14841         if ((_res & 1) != 0) return;
14842         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14843         CHECK_ACCESS(_res_ptr);
14844         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
14845         FREE((void*)_res);
14846         CResult_RouteDecodeErrorZ_free(_res_conv);
14847 }
14848
14849 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
14850         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14851         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
14852         return (uintptr_t)ret_conv;
14853 }
14854 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14855         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
14856         intptr_t ret_val = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
14857         return ret_val;
14858 }
14859
14860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14861         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
14862         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14863         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
14864         return (uintptr_t)ret_conv;
14865 }
14866
14867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14868         LDKRouteParameters o_conv;
14869         o_conv.inner = (void*)(o & (~1));
14870         o_conv.is_owned = (o & 1) || (o == 0);
14871         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14872         o_conv = RouteParameters_clone(&o_conv);
14873         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
14874         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
14875         return (uintptr_t)ret_conv;
14876 }
14877
14878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14879         LDKDecodeError e_conv;
14880         e_conv.inner = (void*)(e & (~1));
14881         e_conv.is_owned = (e & 1) || (e == 0);
14882         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14883         e_conv = DecodeError_clone(&e_conv);
14884         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
14885         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
14886         return (uintptr_t)ret_conv;
14887 }
14888
14889 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14890         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
14891         jboolean ret_val = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
14892         return ret_val;
14893 }
14894
14895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14896         if ((_res & 1) != 0) return;
14897         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14898         CHECK_ACCESS(_res_ptr);
14899         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
14900         FREE((void*)_res);
14901         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
14902 }
14903
14904 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
14905         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
14906         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
14907         return (uintptr_t)ret_conv;
14908 }
14909 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14910         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
14911         intptr_t ret_val = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
14912         return ret_val;
14913 }
14914
14915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14916         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
14917         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
14918         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
14919         return (uintptr_t)ret_conv;
14920 }
14921
14922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14923         LDKCVec_RouteHintZ _res_constr;
14924         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14925         if (_res_constr.datalen > 0)
14926                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
14927         else
14928                 _res_constr.data = NULL;
14929         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14930         for (size_t l = 0; l < _res_constr.datalen; l++) {
14931                 int64_t _res_conv_11 = _res_vals[l];
14932                 LDKRouteHint _res_conv_11_conv;
14933                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
14934                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
14935                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
14936                 _res_constr.data[l] = _res_conv_11_conv;
14937         }
14938         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14939         CVec_RouteHintZ_free(_res_constr);
14940 }
14941
14942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
14943         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
14944         *ret_copy = COption_u64Z_some(o);
14945         uintptr_t ret_ref = (uintptr_t)ret_copy;
14946         return ret_ref;
14947 }
14948
14949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
14950         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
14951         *ret_copy = COption_u64Z_none();
14952         uintptr_t ret_ref = (uintptr_t)ret_copy;
14953         return ret_ref;
14954 }
14955
14956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
14957         if ((_res & 1) != 0) return;
14958         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14959         CHECK_ACCESS(_res_ptr);
14960         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
14961         FREE((void*)_res);
14962         COption_u64Z_free(_res_conv);
14963 }
14964
14965 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
14966         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
14967         *ret_copy = COption_u64Z_clone(arg);
14968 uintptr_t ret_ref = (uintptr_t)ret_copy;
14969         return ret_ref;
14970 }
14971 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14972         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
14973         intptr_t ret_val = COption_u64Z_clone_ptr(arg_conv);
14974         return ret_val;
14975 }
14976
14977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14978         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
14979         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
14980         *ret_copy = COption_u64Z_clone(orig_conv);
14981         uintptr_t ret_ref = (uintptr_t)ret_copy;
14982         return ret_ref;
14983 }
14984
14985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14986         LDKPaymentParameters o_conv;
14987         o_conv.inner = (void*)(o & (~1));
14988         o_conv.is_owned = (o & 1) || (o == 0);
14989         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14990         o_conv = PaymentParameters_clone(&o_conv);
14991         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
14992         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
14993         return (uintptr_t)ret_conv;
14994 }
14995
14996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14997         LDKDecodeError e_conv;
14998         e_conv.inner = (void*)(e & (~1));
14999         e_conv.is_owned = (e & 1) || (e == 0);
15000         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15001         e_conv = DecodeError_clone(&e_conv);
15002         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15003         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
15004         return (uintptr_t)ret_conv;
15005 }
15006
15007 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15008         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
15009         jboolean ret_val = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
15010         return ret_val;
15011 }
15012
15013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15014         if ((_res & 1) != 0) return;
15015         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15016         CHECK_ACCESS(_res_ptr);
15017         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
15018         FREE((void*)_res);
15019         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
15020 }
15021
15022 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
15023         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15024         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
15025         return (uintptr_t)ret_conv;
15026 }
15027 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15028         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
15029         intptr_t ret_val = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
15030         return ret_val;
15031 }
15032
15033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15034         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
15035         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15036         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
15037         return (uintptr_t)ret_conv;
15038 }
15039
15040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15041         LDKCVec_RouteHintHopZ _res_constr;
15042         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15043         if (_res_constr.datalen > 0)
15044                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
15045         else
15046                 _res_constr.data = NULL;
15047         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15048         for (size_t o = 0; o < _res_constr.datalen; o++) {
15049                 int64_t _res_conv_14 = _res_vals[o];
15050                 LDKRouteHintHop _res_conv_14_conv;
15051                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15052                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15053                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15054                 _res_constr.data[o] = _res_conv_14_conv;
15055         }
15056         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15057         CVec_RouteHintHopZ_free(_res_constr);
15058 }
15059
15060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15061         LDKRouteHint o_conv;
15062         o_conv.inner = (void*)(o & (~1));
15063         o_conv.is_owned = (o & 1) || (o == 0);
15064         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15065         o_conv = RouteHint_clone(&o_conv);
15066         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15067         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
15068         return (uintptr_t)ret_conv;
15069 }
15070
15071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15072         LDKDecodeError e_conv;
15073         e_conv.inner = (void*)(e & (~1));
15074         e_conv.is_owned = (e & 1) || (e == 0);
15075         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15076         e_conv = DecodeError_clone(&e_conv);
15077         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15078         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
15079         return (uintptr_t)ret_conv;
15080 }
15081
15082 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15083         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
15084         jboolean ret_val = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
15085         return ret_val;
15086 }
15087
15088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15089         if ((_res & 1) != 0) return;
15090         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15091         CHECK_ACCESS(_res_ptr);
15092         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
15093         FREE((void*)_res);
15094         CResult_RouteHintDecodeErrorZ_free(_res_conv);
15095 }
15096
15097 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
15098         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15099         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
15100         return (uintptr_t)ret_conv;
15101 }
15102 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15103         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
15104         intptr_t ret_val = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
15105         return ret_val;
15106 }
15107
15108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15109         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
15110         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15111         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
15112         return (uintptr_t)ret_conv;
15113 }
15114
15115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15116         LDKRouteHintHop o_conv;
15117         o_conv.inner = (void*)(o & (~1));
15118         o_conv.is_owned = (o & 1) || (o == 0);
15119         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15120         o_conv = RouteHintHop_clone(&o_conv);
15121         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15122         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
15123         return (uintptr_t)ret_conv;
15124 }
15125
15126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15127         LDKDecodeError e_conv;
15128         e_conv.inner = (void*)(e & (~1));
15129         e_conv.is_owned = (e & 1) || (e == 0);
15130         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15131         e_conv = DecodeError_clone(&e_conv);
15132         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15133         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
15134         return (uintptr_t)ret_conv;
15135 }
15136
15137 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15138         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
15139         jboolean ret_val = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
15140         return ret_val;
15141 }
15142
15143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15144         if ((_res & 1) != 0) return;
15145         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15146         CHECK_ACCESS(_res_ptr);
15147         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
15148         FREE((void*)_res);
15149         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
15150 }
15151
15152 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
15153         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15154         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
15155         return (uintptr_t)ret_conv;
15156 }
15157 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15158         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
15159         intptr_t ret_val = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
15160         return ret_val;
15161 }
15162
15163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15164         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
15165         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15166         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
15167         return (uintptr_t)ret_conv;
15168 }
15169
15170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15171         LDKCVec_ChannelDetailsZ _res_constr;
15172         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15173         if (_res_constr.datalen > 0)
15174                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
15175         else
15176                 _res_constr.data = NULL;
15177         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15178         for (size_t q = 0; q < _res_constr.datalen; q++) {
15179                 int64_t _res_conv_16 = _res_vals[q];
15180                 LDKChannelDetails _res_conv_16_conv;
15181                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
15182                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
15183                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
15184                 _res_constr.data[q] = _res_conv_16_conv;
15185         }
15186         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15187         CVec_ChannelDetailsZ_free(_res_constr);
15188 }
15189
15190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15191         LDKRoute o_conv;
15192         o_conv.inner = (void*)(o & (~1));
15193         o_conv.is_owned = (o & 1) || (o == 0);
15194         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15195         o_conv = Route_clone(&o_conv);
15196         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15197         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
15198         return (uintptr_t)ret_conv;
15199 }
15200
15201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15202         LDKLightningError e_conv;
15203         e_conv.inner = (void*)(e & (~1));
15204         e_conv.is_owned = (e & 1) || (e == 0);
15205         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15206         e_conv = LightningError_clone(&e_conv);
15207         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15208         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
15209         return (uintptr_t)ret_conv;
15210 }
15211
15212 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15213         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
15214         jboolean ret_val = CResult_RouteLightningErrorZ_is_ok(o_conv);
15215         return ret_val;
15216 }
15217
15218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15219         if ((_res & 1) != 0) return;
15220         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15221         CHECK_ACCESS(_res_ptr);
15222         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
15223         FREE((void*)_res);
15224         CResult_RouteLightningErrorZ_free(_res_conv);
15225 }
15226
15227 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
15228         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15229         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
15230         return (uintptr_t)ret_conv;
15231 }
15232 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15233         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
15234         intptr_t ret_val = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
15235         return ret_val;
15236 }
15237
15238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15239         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
15240         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15241         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
15242         return (uintptr_t)ret_conv;
15243 }
15244
15245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15246         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15247         CHECK_ACCESS(o_ptr);
15248         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
15249         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
15250         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15251         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
15252         return (uintptr_t)ret_conv;
15253 }
15254
15255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15256         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
15257         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15258         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
15259         return (uintptr_t)ret_conv;
15260 }
15261
15262 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15263         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
15264         jboolean ret_val = CResult_TxOutAccessErrorZ_is_ok(o_conv);
15265         return ret_val;
15266 }
15267
15268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15269         if ((_res & 1) != 0) return;
15270         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15271         CHECK_ACCESS(_res_ptr);
15272         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
15273         FREE((void*)_res);
15274         CResult_TxOutAccessErrorZ_free(_res_conv);
15275 }
15276
15277 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
15278         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15279         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
15280         return (uintptr_t)ret_conv;
15281 }
15282 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15283         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
15284         intptr_t ret_val = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
15285         return ret_val;
15286 }
15287
15288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15289         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
15290         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15291         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
15292         return (uintptr_t)ret_conv;
15293 }
15294
15295 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
15296         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15297         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
15298         return ((uintptr_t)ret_conv);
15299 }
15300 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15301         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
15302         intptr_t ret_val = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
15303         return ret_val;
15304 }
15305
15306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15307         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
15308         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15309         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
15310         return ((uintptr_t)ret_conv);
15311 }
15312
15313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, intptr_t a, int8_tArray b) {
15314         LDKTransaction b_ref;
15315         b_ref.datalen = (*env)->GetArrayLength(env, b);
15316         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
15317         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
15318         b_ref.data_is_owned = true;
15319         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15320         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
15321         return ((uintptr_t)ret_conv);
15322 }
15323
15324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15325         if ((_res & 1) != 0) return;
15326         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15327         CHECK_ACCESS(_res_ptr);
15328         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
15329         FREE((void*)_res);
15330         C2Tuple_usizeTransactionZ_free(_res_conv);
15331 }
15332
15333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15334         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
15335         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15336         if (_res_constr.datalen > 0)
15337                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
15338         else
15339                 _res_constr.data = NULL;
15340         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15341         for (size_t c = 0; c < _res_constr.datalen; c++) {
15342                 int64_t _res_conv_28 = _res_vals[c];
15343                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
15344                 CHECK_ACCESS(_res_conv_28_ptr);
15345                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
15346                 FREE((void*)_res_conv_28);
15347                 _res_constr.data[c] = _res_conv_28_conv;
15348         }
15349         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15350         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
15351 }
15352
15353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15354         LDKCVec_TxidZ _res_constr;
15355         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15356         if (_res_constr.datalen > 0)
15357                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
15358         else
15359                 _res_constr.data = NULL;
15360         for (size_t i = 0; i < _res_constr.datalen; i++) {
15361                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15362                 LDKThirtyTwoBytes _res_conv_8_ref;
15363                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
15364                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
15365                 _res_constr.data[i] = _res_conv_8_ref;
15366         }
15367         CVec_TxidZ_free(_res_constr);
15368 }
15369
15370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
15371         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15372         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
15373         return (uintptr_t)ret_conv;
15374 }
15375
15376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
15377         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
15378         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15379         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
15380         return (uintptr_t)ret_conv;
15381 }
15382
15383 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15384         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
15385         jboolean ret_val = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
15386         return ret_val;
15387 }
15388
15389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15390         if ((_res & 1) != 0) return;
15391         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15392         CHECK_ACCESS(_res_ptr);
15393         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
15394         FREE((void*)_res);
15395         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
15396 }
15397
15398 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
15399         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15400         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
15401         return (uintptr_t)ret_conv;
15402 }
15403 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15404         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
15405         intptr_t ret_val = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
15406         return ret_val;
15407 }
15408
15409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15410         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
15411         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15412         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
15413         return (uintptr_t)ret_conv;
15414 }
15415
15416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15417         LDKCVec_MonitorEventZ _res_constr;
15418         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15419         if (_res_constr.datalen > 0)
15420                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
15421         else
15422                 _res_constr.data = NULL;
15423         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15424         for (size_t o = 0; o < _res_constr.datalen; o++) {
15425                 int64_t _res_conv_14 = _res_vals[o];
15426                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
15427                 CHECK_ACCESS(_res_conv_14_ptr);
15428                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
15429                 FREE((void*)_res_conv_14);
15430                 _res_constr.data[o] = _res_conv_14_conv;
15431         }
15432         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15433         CVec_MonitorEventZ_free(_res_constr);
15434 }
15435
15436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15437         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15438         CHECK_ACCESS(o_ptr);
15439         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
15440         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
15441         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15442         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
15443         uintptr_t ret_ref = (uintptr_t)ret_copy;
15444         return ret_ref;
15445 }
15446
15447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
15448         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15449         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
15450         uintptr_t ret_ref = (uintptr_t)ret_copy;
15451         return ret_ref;
15452 }
15453
15454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15455         if ((_res & 1) != 0) return;
15456         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15457         CHECK_ACCESS(_res_ptr);
15458         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
15459         FREE((void*)_res);
15460         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
15461 }
15462
15463 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
15464         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15465         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
15466 uintptr_t ret_ref = (uintptr_t)ret_copy;
15467         return ret_ref;
15468 }
15469 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15470         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
15471         intptr_t ret_val = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
15472         return ret_val;
15473 }
15474
15475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15476         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
15477         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15478         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
15479         uintptr_t ret_ref = (uintptr_t)ret_copy;
15480         return ret_ref;
15481 }
15482
15483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15484         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15485         CHECK_ACCESS(o_ptr);
15486         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
15487         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
15488         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15489         *ret_copy = COption_ClosureReasonZ_some(o_conv);
15490         uintptr_t ret_ref = (uintptr_t)ret_copy;
15491         return ret_ref;
15492 }
15493
15494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
15495         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15496         *ret_copy = COption_ClosureReasonZ_none();
15497         uintptr_t ret_ref = (uintptr_t)ret_copy;
15498         return ret_ref;
15499 }
15500
15501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15502         if ((_res & 1) != 0) return;
15503         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15504         CHECK_ACCESS(_res_ptr);
15505         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
15506         FREE((void*)_res);
15507         COption_ClosureReasonZ_free(_res_conv);
15508 }
15509
15510 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
15511         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15512         *ret_copy = COption_ClosureReasonZ_clone(arg);
15513 uintptr_t ret_ref = (uintptr_t)ret_copy;
15514         return ret_ref;
15515 }
15516 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15517         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
15518         intptr_t ret_val = COption_ClosureReasonZ_clone_ptr(arg_conv);
15519         return ret_val;
15520 }
15521
15522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15523         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
15524         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15525         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
15526         uintptr_t ret_ref = (uintptr_t)ret_copy;
15527         return ret_ref;
15528 }
15529
15530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15531         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15532         CHECK_ACCESS(o_ptr);
15533         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
15534         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
15535         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
15536         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
15537         return (uintptr_t)ret_conv;
15538 }
15539
15540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15541         LDKDecodeError e_conv;
15542         e_conv.inner = (void*)(e & (~1));
15543         e_conv.is_owned = (e & 1) || (e == 0);
15544         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15545         e_conv = DecodeError_clone(&e_conv);
15546         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
15547         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
15548         return (uintptr_t)ret_conv;
15549 }
15550
15551 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15552         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
15553         jboolean ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
15554         return ret_val;
15555 }
15556
15557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15558         if ((_res & 1) != 0) return;
15559         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15560         CHECK_ACCESS(_res_ptr);
15561         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
15562         FREE((void*)_res);
15563         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
15564 }
15565
15566 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
15567         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
15568         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
15569         return (uintptr_t)ret_conv;
15570 }
15571 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15572         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
15573         intptr_t ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
15574         return ret_val;
15575 }
15576
15577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15578         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
15579         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
15580         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
15581         return (uintptr_t)ret_conv;
15582 }
15583
15584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15585         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15586         CHECK_ACCESS(o_ptr);
15587         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
15588         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
15589         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
15590         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
15591         uintptr_t ret_ref = (uintptr_t)ret_copy;
15592         return ret_ref;
15593 }
15594
15595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
15596         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
15597         *ret_copy = COption_NetworkUpdateZ_none();
15598         uintptr_t ret_ref = (uintptr_t)ret_copy;
15599         return ret_ref;
15600 }
15601
15602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15603         if ((_res & 1) != 0) return;
15604         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15605         CHECK_ACCESS(_res_ptr);
15606         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
15607         FREE((void*)_res);
15608         COption_NetworkUpdateZ_free(_res_conv);
15609 }
15610
15611 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
15612         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
15613         *ret_copy = COption_NetworkUpdateZ_clone(arg);
15614 uintptr_t ret_ref = (uintptr_t)ret_copy;
15615         return ret_ref;
15616 }
15617 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15618         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
15619         intptr_t ret_val = COption_NetworkUpdateZ_clone_ptr(arg_conv);
15620         return ret_val;
15621 }
15622
15623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15624         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
15625         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
15626         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
15627         uintptr_t ret_ref = (uintptr_t)ret_copy;
15628         return ret_ref;
15629 }
15630
15631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15632         LDKCVec_SpendableOutputDescriptorZ _res_constr;
15633         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15634         if (_res_constr.datalen > 0)
15635                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
15636         else
15637                 _res_constr.data = NULL;
15638         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15639         for (size_t b = 0; b < _res_constr.datalen; b++) {
15640                 int64_t _res_conv_27 = _res_vals[b];
15641                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
15642                 CHECK_ACCESS(_res_conv_27_ptr);
15643                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
15644                 FREE((void*)_res_conv_27);
15645                 _res_constr.data[b] = _res_conv_27_conv;
15646         }
15647         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15648         CVec_SpendableOutputDescriptorZ_free(_res_constr);
15649 }
15650
15651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15652         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15653         CHECK_ACCESS(o_ptr);
15654         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
15655         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
15656         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
15657         *ret_copy = COption_EventZ_some(o_conv);
15658         uintptr_t ret_ref = (uintptr_t)ret_copy;
15659         return ret_ref;
15660 }
15661
15662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
15663         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
15664         *ret_copy = COption_EventZ_none();
15665         uintptr_t ret_ref = (uintptr_t)ret_copy;
15666         return ret_ref;
15667 }
15668
15669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15670         if ((_res & 1) != 0) return;
15671         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15672         CHECK_ACCESS(_res_ptr);
15673         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
15674         FREE((void*)_res);
15675         COption_EventZ_free(_res_conv);
15676 }
15677
15678 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
15679         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
15680         *ret_copy = COption_EventZ_clone(arg);
15681 uintptr_t ret_ref = (uintptr_t)ret_copy;
15682         return ret_ref;
15683 }
15684 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15685         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
15686         intptr_t ret_val = COption_EventZ_clone_ptr(arg_conv);
15687         return ret_val;
15688 }
15689
15690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15691         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
15692         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
15693         *ret_copy = COption_EventZ_clone(orig_conv);
15694         uintptr_t ret_ref = (uintptr_t)ret_copy;
15695         return ret_ref;
15696 }
15697
15698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15699         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15700         CHECK_ACCESS(o_ptr);
15701         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
15702         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
15703         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
15704         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
15705         return (uintptr_t)ret_conv;
15706 }
15707
15708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15709         LDKDecodeError e_conv;
15710         e_conv.inner = (void*)(e & (~1));
15711         e_conv.is_owned = (e & 1) || (e == 0);
15712         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15713         e_conv = DecodeError_clone(&e_conv);
15714         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
15715         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
15716         return (uintptr_t)ret_conv;
15717 }
15718
15719 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15720         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
15721         jboolean ret_val = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
15722         return ret_val;
15723 }
15724
15725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_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_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
15730         FREE((void*)_res);
15731         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
15732 }
15733
15734 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
15735         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
15736         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
15737         return (uintptr_t)ret_conv;
15738 }
15739 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15740         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
15741         intptr_t ret_val = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
15742         return ret_val;
15743 }
15744
15745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15746         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
15747         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
15748         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
15749         return (uintptr_t)ret_conv;
15750 }
15751
15752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15753         LDKCVec_MessageSendEventZ _res_constr;
15754         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15755         if (_res_constr.datalen > 0)
15756                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
15757         else
15758                 _res_constr.data = NULL;
15759         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15760         for (size_t s = 0; s < _res_constr.datalen; s++) {
15761                 int64_t _res_conv_18 = _res_vals[s];
15762                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
15763                 CHECK_ACCESS(_res_conv_18_ptr);
15764                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
15765                 FREE((void*)_res_conv_18);
15766                 _res_constr.data[s] = _res_conv_18_conv;
15767         }
15768         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15769         CVec_MessageSendEventZ_free(_res_constr);
15770 }
15771
15772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15773         LDKFixedPenaltyScorer o_conv;
15774         o_conv.inner = (void*)(o & (~1));
15775         o_conv.is_owned = (o & 1) || (o == 0);
15776         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15777         o_conv = FixedPenaltyScorer_clone(&o_conv);
15778         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
15779         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
15780         return (uintptr_t)ret_conv;
15781 }
15782
15783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15784         LDKDecodeError e_conv;
15785         e_conv.inner = (void*)(e & (~1));
15786         e_conv.is_owned = (e & 1) || (e == 0);
15787         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15788         e_conv = DecodeError_clone(&e_conv);
15789         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
15790         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
15791         return (uintptr_t)ret_conv;
15792 }
15793
15794 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15795         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
15796         jboolean ret_val = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
15797         return ret_val;
15798 }
15799
15800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15801         if ((_res & 1) != 0) return;
15802         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15803         CHECK_ACCESS(_res_ptr);
15804         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
15805         FREE((void*)_res);
15806         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
15807 }
15808
15809 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
15810         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
15811         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
15812         return (uintptr_t)ret_conv;
15813 }
15814 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15815         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
15816         intptr_t ret_val = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
15817         return ret_val;
15818 }
15819
15820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15821         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
15822         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
15823         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
15824         return (uintptr_t)ret_conv;
15825 }
15826
15827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15828         LDKScoringParameters o_conv;
15829         o_conv.inner = (void*)(o & (~1));
15830         o_conv.is_owned = (o & 1) || (o == 0);
15831         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15832         o_conv = ScoringParameters_clone(&o_conv);
15833         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
15834         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
15835         return (uintptr_t)ret_conv;
15836 }
15837
15838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15839         LDKDecodeError e_conv;
15840         e_conv.inner = (void*)(e & (~1));
15841         e_conv.is_owned = (e & 1) || (e == 0);
15842         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15843         e_conv = DecodeError_clone(&e_conv);
15844         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
15845         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
15846         return (uintptr_t)ret_conv;
15847 }
15848
15849 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15850         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
15851         jboolean ret_val = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
15852         return ret_val;
15853 }
15854
15855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15856         if ((_res & 1) != 0) return;
15857         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15858         CHECK_ACCESS(_res_ptr);
15859         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
15860         FREE((void*)_res);
15861         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
15862 }
15863
15864 static inline uintptr_t CResult_ScoringParametersDecodeErrorZ_clone_ptr(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR arg) {
15865         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
15866         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(arg);
15867         return (uintptr_t)ret_conv;
15868 }
15869 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15870         LDKCResult_ScoringParametersDecodeErrorZ* arg_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
15871         intptr_t ret_val = CResult_ScoringParametersDecodeErrorZ_clone_ptr(arg_conv);
15872         return ret_val;
15873 }
15874
15875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15876         LDKCResult_ScoringParametersDecodeErrorZ* orig_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(orig & ~1);
15877         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
15878         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(orig_conv);
15879         return (uintptr_t)ret_conv;
15880 }
15881
15882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15883         LDKScorer o_conv;
15884         o_conv.inner = (void*)(o & (~1));
15885         o_conv.is_owned = (o & 1) || (o == 0);
15886         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15887         // WARNING: we need a move here but no clone is available for LDKScorer
15888         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
15889         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
15890         return (uintptr_t)ret_conv;
15891 }
15892
15893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15894         LDKDecodeError e_conv;
15895         e_conv.inner = (void*)(e & (~1));
15896         e_conv.is_owned = (e & 1) || (e == 0);
15897         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15898         e_conv = DecodeError_clone(&e_conv);
15899         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
15900         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
15901         return (uintptr_t)ret_conv;
15902 }
15903
15904 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15905         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
15906         jboolean ret_val = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
15907         return ret_val;
15908 }
15909
15910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15911         if ((_res & 1) != 0) return;
15912         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15913         CHECK_ACCESS(_res_ptr);
15914         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
15915         FREE((void*)_res);
15916         CResult_ScorerDecodeErrorZ_free(_res_conv);
15917 }
15918
15919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15920         LDKProbabilisticScoringParameters o_conv;
15921         o_conv.inner = (void*)(o & (~1));
15922         o_conv.is_owned = (o & 1) || (o == 0);
15923         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15924         o_conv = ProbabilisticScoringParameters_clone(&o_conv);
15925         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
15926         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_ok(o_conv);
15927         return (uintptr_t)ret_conv;
15928 }
15929
15930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15931         LDKDecodeError e_conv;
15932         e_conv.inner = (void*)(e & (~1));
15933         e_conv.is_owned = (e & 1) || (e == 0);
15934         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15935         e_conv = DecodeError_clone(&e_conv);
15936         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
15937         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_err(e_conv);
15938         return (uintptr_t)ret_conv;
15939 }
15940
15941 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15942         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(o & ~1);
15943         jboolean ret_val = CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok(o_conv);
15944         return ret_val;
15945 }
15946
15947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15948         if ((_res & 1) != 0) return;
15949         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15950         CHECK_ACCESS(_res_ptr);
15951         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(_res_ptr);
15952         FREE((void*)_res);
15953         CResult_ProbabilisticScoringParametersDecodeErrorZ_free(_res_conv);
15954 }
15955
15956 static inline uintptr_t CResult_ProbabilisticScoringParametersDecodeErrorZ_clone_ptr(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ *NONNULL_PTR arg) {
15957         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
15958         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(arg);
15959         return (uintptr_t)ret_conv;
15960 }
15961 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15962         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* arg_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(arg & ~1);
15963         intptr_t ret_val = CResult_ProbabilisticScoringParametersDecodeErrorZ_clone_ptr(arg_conv);
15964         return ret_val;
15965 }
15966
15967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScoringParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15968         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* orig_conv = (LDKCResult_ProbabilisticScoringParametersDecodeErrorZ*)(orig & ~1);
15969         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
15970         *ret_conv = CResult_ProbabilisticScoringParametersDecodeErrorZ_clone(orig_conv);
15971         return (uintptr_t)ret_conv;
15972 }
15973
15974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15975         LDKInitFeatures o_conv;
15976         o_conv.inner = (void*)(o & (~1));
15977         o_conv.is_owned = (o & 1) || (o == 0);
15978         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15979         o_conv = InitFeatures_clone(&o_conv);
15980         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
15981         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
15982         return (uintptr_t)ret_conv;
15983 }
15984
15985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15986         LDKDecodeError e_conv;
15987         e_conv.inner = (void*)(e & (~1));
15988         e_conv.is_owned = (e & 1) || (e == 0);
15989         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15990         e_conv = DecodeError_clone(&e_conv);
15991         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
15992         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
15993         return (uintptr_t)ret_conv;
15994 }
15995
15996 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15997         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
15998         jboolean ret_val = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
15999         return ret_val;
16000 }
16001
16002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16003         if ((_res & 1) != 0) return;
16004         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16005         CHECK_ACCESS(_res_ptr);
16006         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
16007         FREE((void*)_res);
16008         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
16009 }
16010
16011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16012         LDKChannelFeatures o_conv;
16013         o_conv.inner = (void*)(o & (~1));
16014         o_conv.is_owned = (o & 1) || (o == 0);
16015         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16016         o_conv = ChannelFeatures_clone(&o_conv);
16017         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16018         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
16019         return (uintptr_t)ret_conv;
16020 }
16021
16022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16023         LDKDecodeError e_conv;
16024         e_conv.inner = (void*)(e & (~1));
16025         e_conv.is_owned = (e & 1) || (e == 0);
16026         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16027         e_conv = DecodeError_clone(&e_conv);
16028         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16029         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
16030         return (uintptr_t)ret_conv;
16031 }
16032
16033 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16034         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
16035         jboolean ret_val = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
16036         return ret_val;
16037 }
16038
16039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16040         if ((_res & 1) != 0) return;
16041         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16042         CHECK_ACCESS(_res_ptr);
16043         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
16044         FREE((void*)_res);
16045         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
16046 }
16047
16048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16049         LDKNodeFeatures o_conv;
16050         o_conv.inner = (void*)(o & (~1));
16051         o_conv.is_owned = (o & 1) || (o == 0);
16052         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16053         o_conv = NodeFeatures_clone(&o_conv);
16054         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16055         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
16056         return (uintptr_t)ret_conv;
16057 }
16058
16059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16060         LDKDecodeError e_conv;
16061         e_conv.inner = (void*)(e & (~1));
16062         e_conv.is_owned = (e & 1) || (e == 0);
16063         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16064         e_conv = DecodeError_clone(&e_conv);
16065         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16066         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
16067         return (uintptr_t)ret_conv;
16068 }
16069
16070 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16071         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
16072         jboolean ret_val = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
16073         return ret_val;
16074 }
16075
16076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16077         if ((_res & 1) != 0) return;
16078         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16079         CHECK_ACCESS(_res_ptr);
16080         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
16081         FREE((void*)_res);
16082         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
16083 }
16084
16085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16086         LDKInvoiceFeatures o_conv;
16087         o_conv.inner = (void*)(o & (~1));
16088         o_conv.is_owned = (o & 1) || (o == 0);
16089         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16090         o_conv = InvoiceFeatures_clone(&o_conv);
16091         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
16092         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
16093         return (uintptr_t)ret_conv;
16094 }
16095
16096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16097         LDKDecodeError e_conv;
16098         e_conv.inner = (void*)(e & (~1));
16099         e_conv.is_owned = (e & 1) || (e == 0);
16100         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16101         e_conv = DecodeError_clone(&e_conv);
16102         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
16103         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
16104         return (uintptr_t)ret_conv;
16105 }
16106
16107 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16108         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
16109         jboolean ret_val = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
16110         return ret_val;
16111 }
16112
16113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16114         if ((_res & 1) != 0) return;
16115         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16116         CHECK_ACCESS(_res_ptr);
16117         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
16118         FREE((void*)_res);
16119         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
16120 }
16121
16122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16123         LDKChannelTypeFeatures o_conv;
16124         o_conv.inner = (void*)(o & (~1));
16125         o_conv.is_owned = (o & 1) || (o == 0);
16126         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16127         o_conv = ChannelTypeFeatures_clone(&o_conv);
16128         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
16129         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
16130         return (uintptr_t)ret_conv;
16131 }
16132
16133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16134         LDKDecodeError e_conv;
16135         e_conv.inner = (void*)(e & (~1));
16136         e_conv.is_owned = (e & 1) || (e == 0);
16137         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16138         e_conv = DecodeError_clone(&e_conv);
16139         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
16140         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
16141         return (uintptr_t)ret_conv;
16142 }
16143
16144 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16145         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
16146         jboolean ret_val = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
16147         return ret_val;
16148 }
16149
16150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16151         if ((_res & 1) != 0) return;
16152         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16153         CHECK_ACCESS(_res_ptr);
16154         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
16155         FREE((void*)_res);
16156         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
16157 }
16158
16159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16160         LDKDelayedPaymentOutputDescriptor o_conv;
16161         o_conv.inner = (void*)(o & (~1));
16162         o_conv.is_owned = (o & 1) || (o == 0);
16163         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16164         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
16165         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16166         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
16167         return (uintptr_t)ret_conv;
16168 }
16169
16170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16171         LDKDecodeError e_conv;
16172         e_conv.inner = (void*)(e & (~1));
16173         e_conv.is_owned = (e & 1) || (e == 0);
16174         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16175         e_conv = DecodeError_clone(&e_conv);
16176         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16177         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
16178         return (uintptr_t)ret_conv;
16179 }
16180
16181 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16182         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
16183         jboolean ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16184         return ret_val;
16185 }
16186
16187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16188         if ((_res & 1) != 0) return;
16189         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16190         CHECK_ACCESS(_res_ptr);
16191         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
16192         FREE((void*)_res);
16193         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
16194 }
16195
16196 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16197         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16198         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
16199         return (uintptr_t)ret_conv;
16200 }
16201 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16202         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
16203         intptr_t ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16204         return ret_val;
16205 }
16206
16207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16208         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
16209         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16210         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
16211         return (uintptr_t)ret_conv;
16212 }
16213
16214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16215         LDKStaticPaymentOutputDescriptor o_conv;
16216         o_conv.inner = (void*)(o & (~1));
16217         o_conv.is_owned = (o & 1) || (o == 0);
16218         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16219         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
16220         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16221         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
16222         return (uintptr_t)ret_conv;
16223 }
16224
16225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16226         LDKDecodeError e_conv;
16227         e_conv.inner = (void*)(e & (~1));
16228         e_conv.is_owned = (e & 1) || (e == 0);
16229         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16230         e_conv = DecodeError_clone(&e_conv);
16231         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16232         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
16233         return (uintptr_t)ret_conv;
16234 }
16235
16236 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16237         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
16238         jboolean ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16239         return ret_val;
16240 }
16241
16242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16243         if ((_res & 1) != 0) return;
16244         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16245         CHECK_ACCESS(_res_ptr);
16246         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
16247         FREE((void*)_res);
16248         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
16249 }
16250
16251 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16252         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16253         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
16254         return (uintptr_t)ret_conv;
16255 }
16256 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16257         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
16258         intptr_t ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16259         return ret_val;
16260 }
16261
16262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16263         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
16264         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16265         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
16266         return (uintptr_t)ret_conv;
16267 }
16268
16269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16270         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16271         CHECK_ACCESS(o_ptr);
16272         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
16273         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
16274         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16275         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
16276         return (uintptr_t)ret_conv;
16277 }
16278
16279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16280         LDKDecodeError e_conv;
16281         e_conv.inner = (void*)(e & (~1));
16282         e_conv.is_owned = (e & 1) || (e == 0);
16283         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16284         e_conv = DecodeError_clone(&e_conv);
16285         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16286         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
16287         return (uintptr_t)ret_conv;
16288 }
16289
16290 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16291         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
16292         jboolean ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16293         return ret_val;
16294 }
16295
16296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16297         if ((_res & 1) != 0) return;
16298         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16299         CHECK_ACCESS(_res_ptr);
16300         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
16301         FREE((void*)_res);
16302         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
16303 }
16304
16305 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16306         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16307         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
16308         return (uintptr_t)ret_conv;
16309 }
16310 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16311         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
16312         intptr_t ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16313         return ret_val;
16314 }
16315
16316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16317         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
16318         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16319         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
16320         return (uintptr_t)ret_conv;
16321 }
16322
16323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16324         LDKCVec_PaymentPreimageZ _res_constr;
16325         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16326         if (_res_constr.datalen > 0)
16327                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
16328         else
16329                 _res_constr.data = NULL;
16330         for (size_t i = 0; i < _res_constr.datalen; i++) {
16331                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16332                 LDKThirtyTwoBytes _res_conv_8_ref;
16333                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
16334                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
16335                 _res_constr.data[i] = _res_conv_8_ref;
16336         }
16337         CVec_PaymentPreimageZ_free(_res_constr);
16338 }
16339
16340 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
16341         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
16342         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
16343         return ((uintptr_t)ret_conv);
16344 }
16345 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16346         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
16347         intptr_t ret_val = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
16348         return ret_val;
16349 }
16350
16351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16352         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
16353         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
16354         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
16355         return ((uintptr_t)ret_conv);
16356 }
16357
16358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
16359         LDKSignature a_ref;
16360         CHECK((*env)->GetArrayLength(env, a) == 64);
16361         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
16362         LDKCVec_SignatureZ b_constr;
16363         b_constr.datalen = (*env)->GetArrayLength(env, b);
16364         if (b_constr.datalen > 0)
16365                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16366         else
16367                 b_constr.data = NULL;
16368         for (size_t i = 0; i < b_constr.datalen; i++) {
16369                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
16370                 LDKSignature b_conv_8_ref;
16371                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
16372                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
16373                 b_constr.data[i] = b_conv_8_ref;
16374         }
16375         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
16376         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
16377         return ((uintptr_t)ret_conv);
16378 }
16379
16380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16381         if ((_res & 1) != 0) return;
16382         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16383         CHECK_ACCESS(_res_ptr);
16384         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
16385         FREE((void*)_res);
16386         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
16387 }
16388
16389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16390         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16391         CHECK_ACCESS(o_ptr);
16392         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
16393         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
16394         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16395         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
16396         return (uintptr_t)ret_conv;
16397 }
16398
16399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
16400         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16401         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
16402         return (uintptr_t)ret_conv;
16403 }
16404
16405 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16406         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
16407         jboolean ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
16408         return ret_val;
16409 }
16410
16411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16412         if ((_res & 1) != 0) return;
16413         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16414         CHECK_ACCESS(_res_ptr);
16415         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
16416         FREE((void*)_res);
16417         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
16418 }
16419
16420 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
16421         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16422         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
16423         return (uintptr_t)ret_conv;
16424 }
16425 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16426         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
16427         intptr_t ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
16428         return ret_val;
16429 }
16430
16431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16432         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
16433         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16434         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
16435         return (uintptr_t)ret_conv;
16436 }
16437
16438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16439         LDKSignature o_ref;
16440         CHECK((*env)->GetArrayLength(env, o) == 64);
16441         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
16442         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16443         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
16444         return (uintptr_t)ret_conv;
16445 }
16446
16447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
16448         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16449         *ret_conv = CResult_SignatureNoneZ_err();
16450         return (uintptr_t)ret_conv;
16451 }
16452
16453 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16454         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
16455         jboolean ret_val = CResult_SignatureNoneZ_is_ok(o_conv);
16456         return ret_val;
16457 }
16458
16459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16460         if ((_res & 1) != 0) return;
16461         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16462         CHECK_ACCESS(_res_ptr);
16463         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
16464         FREE((void*)_res);
16465         CResult_SignatureNoneZ_free(_res_conv);
16466 }
16467
16468 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
16469         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16470         *ret_conv = CResult_SignatureNoneZ_clone(arg);
16471         return (uintptr_t)ret_conv;
16472 }
16473 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16474         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
16475         intptr_t ret_val = CResult_SignatureNoneZ_clone_ptr(arg_conv);
16476         return ret_val;
16477 }
16478
16479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16480         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
16481         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16482         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
16483         return (uintptr_t)ret_conv;
16484 }
16485
16486 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
16487         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
16488         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
16489         return ((uintptr_t)ret_conv);
16490 }
16491 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16492         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
16493         intptr_t ret_val = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
16494         return ret_val;
16495 }
16496
16497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16498         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
16499         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
16500         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
16501         return ((uintptr_t)ret_conv);
16502 }
16503
16504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
16505         LDKSignature a_ref;
16506         CHECK((*env)->GetArrayLength(env, a) == 64);
16507         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
16508         LDKSignature b_ref;
16509         CHECK((*env)->GetArrayLength(env, b) == 64);
16510         (*env)->GetByteArrayRegion(env, b, 0, 64, b_ref.compact_form);
16511         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
16512         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
16513         return ((uintptr_t)ret_conv);
16514 }
16515
16516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16517         if ((_res & 1) != 0) return;
16518         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16519         CHECK_ACCESS(_res_ptr);
16520         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
16521         FREE((void*)_res);
16522         C2Tuple_SignatureSignatureZ_free(_res_conv);
16523 }
16524
16525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16526         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16527         CHECK_ACCESS(o_ptr);
16528         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
16529         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
16530         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
16531         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
16532         return (uintptr_t)ret_conv;
16533 }
16534
16535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
16536         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
16537         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
16538         return (uintptr_t)ret_conv;
16539 }
16540
16541 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16542         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
16543         jboolean ret_val = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
16544         return ret_val;
16545 }
16546
16547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16548         if ((_res & 1) != 0) return;
16549         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16550         CHECK_ACCESS(_res_ptr);
16551         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
16552         FREE((void*)_res);
16553         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
16554 }
16555
16556 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
16557         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
16558         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
16559         return (uintptr_t)ret_conv;
16560 }
16561 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16562         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
16563         intptr_t ret_val = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
16564         return ret_val;
16565 }
16566
16567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16568         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
16569         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
16570         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
16571         return (uintptr_t)ret_conv;
16572 }
16573
16574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16575         LDKSecretKey o_ref;
16576         CHECK((*env)->GetArrayLength(env, o) == 32);
16577         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
16578         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
16579         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
16580         return (uintptr_t)ret_conv;
16581 }
16582
16583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1err(JNIEnv *env, jclass clz) {
16584         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
16585         *ret_conv = CResult_SecretKeyNoneZ_err();
16586         return (uintptr_t)ret_conv;
16587 }
16588
16589 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16590         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
16591         jboolean ret_val = CResult_SecretKeyNoneZ_is_ok(o_conv);
16592         return ret_val;
16593 }
16594
16595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16596         if ((_res & 1) != 0) return;
16597         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16598         CHECK_ACCESS(_res_ptr);
16599         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
16600         FREE((void*)_res);
16601         CResult_SecretKeyNoneZ_free(_res_conv);
16602 }
16603
16604 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
16605         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
16606         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
16607         return (uintptr_t)ret_conv;
16608 }
16609 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16610         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
16611         intptr_t ret_val = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
16612         return ret_val;
16613 }
16614
16615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16616         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
16617         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
16618         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
16619         return (uintptr_t)ret_conv;
16620 }
16621
16622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16623         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16624         CHECK_ACCESS(o_ptr);
16625         LDKSign o_conv = *(LDKSign*)(o_ptr);
16626         if (o_conv.free == LDKSign_JCalls_free) {
16627                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16628                 LDKSign_JCalls_cloned(&o_conv);
16629         }
16630         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
16631         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
16632         return (uintptr_t)ret_conv;
16633 }
16634
16635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16636         LDKDecodeError e_conv;
16637         e_conv.inner = (void*)(e & (~1));
16638         e_conv.is_owned = (e & 1) || (e == 0);
16639         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16640         e_conv = DecodeError_clone(&e_conv);
16641         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
16642         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
16643         return (uintptr_t)ret_conv;
16644 }
16645
16646 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16647         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
16648         jboolean ret_val = CResult_SignDecodeErrorZ_is_ok(o_conv);
16649         return ret_val;
16650 }
16651
16652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16653         if ((_res & 1) != 0) return;
16654         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16655         CHECK_ACCESS(_res_ptr);
16656         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
16657         FREE((void*)_res);
16658         CResult_SignDecodeErrorZ_free(_res_conv);
16659 }
16660
16661 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
16662         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
16663         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
16664         return (uintptr_t)ret_conv;
16665 }
16666 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16667         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
16668         intptr_t ret_val = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
16669         return ret_val;
16670 }
16671
16672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16673         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
16674         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
16675         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
16676         return (uintptr_t)ret_conv;
16677 }
16678
16679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16680         LDKCVec_u5Z _res_constr;
16681         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16682         if (_res_constr.datalen > 0)
16683                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
16684         else
16685                 _res_constr.data = NULL;
16686         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
16687         for (size_t h = 0; h < _res_constr.datalen; h++) {
16688                 int8_t _res_conv_7 = _res_vals[h];
16689                 
16690                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
16691         }
16692         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
16693         CVec_u5Z_free(_res_constr);
16694 }
16695
16696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16697         LDKRecoverableSignature o_ref;
16698         CHECK((*env)->GetArrayLength(env, o) == 68);
16699         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
16700         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
16701         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
16702         return (uintptr_t)ret_conv;
16703 }
16704
16705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
16706         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
16707         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
16708         return (uintptr_t)ret_conv;
16709 }
16710
16711 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16712         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
16713         jboolean ret_val = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
16714         return ret_val;
16715 }
16716
16717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16718         if ((_res & 1) != 0) return;
16719         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16720         CHECK_ACCESS(_res_ptr);
16721         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
16722         FREE((void*)_res);
16723         CResult_RecoverableSignatureNoneZ_free(_res_conv);
16724 }
16725
16726 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
16727         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
16728         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
16729         return (uintptr_t)ret_conv;
16730 }
16731 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16732         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
16733         intptr_t ret_val = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
16734         return ret_val;
16735 }
16736
16737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16738         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
16739         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
16740         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
16741         return (uintptr_t)ret_conv;
16742 }
16743
16744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
16745         LDKCVec_u8Z _res_ref;
16746         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
16747         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
16748         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
16749         CVec_u8Z_free(_res_ref);
16750 }
16751
16752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16753         LDKCVec_CVec_u8ZZ _res_constr;
16754         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16755         if (_res_constr.datalen > 0)
16756                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
16757         else
16758                 _res_constr.data = NULL;
16759         for (size_t i = 0; i < _res_constr.datalen; i++) {
16760                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16761                 LDKCVec_u8Z _res_conv_8_ref;
16762                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
16763                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
16764                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
16765                 _res_constr.data[i] = _res_conv_8_ref;
16766         }
16767         CVec_CVec_u8ZZ_free(_res_constr);
16768 }
16769
16770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
16771         LDKCVec_CVec_u8ZZ o_constr;
16772         o_constr.datalen = (*env)->GetArrayLength(env, o);
16773         if (o_constr.datalen > 0)
16774                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
16775         else
16776                 o_constr.data = NULL;
16777         for (size_t i = 0; i < o_constr.datalen; i++) {
16778                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
16779                 LDKCVec_u8Z o_conv_8_ref;
16780                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
16781                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
16782                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
16783                 o_constr.data[i] = o_conv_8_ref;
16784         }
16785         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
16786         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
16787         return (uintptr_t)ret_conv;
16788 }
16789
16790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
16791         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
16792         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
16793         return (uintptr_t)ret_conv;
16794 }
16795
16796 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16797         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
16798         jboolean ret_val = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
16799         return ret_val;
16800 }
16801
16802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16803         if ((_res & 1) != 0) return;
16804         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16805         CHECK_ACCESS(_res_ptr);
16806         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
16807         FREE((void*)_res);
16808         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
16809 }
16810
16811 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
16812         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
16813         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
16814         return (uintptr_t)ret_conv;
16815 }
16816 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16817         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
16818         intptr_t ret_val = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
16819         return ret_val;
16820 }
16821
16822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16823         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
16824         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
16825         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
16826         return (uintptr_t)ret_conv;
16827 }
16828
16829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16830         LDKInMemorySigner o_conv;
16831         o_conv.inner = (void*)(o & (~1));
16832         o_conv.is_owned = (o & 1) || (o == 0);
16833         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16834         o_conv = InMemorySigner_clone(&o_conv);
16835         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
16836         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
16837         return (uintptr_t)ret_conv;
16838 }
16839
16840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16841         LDKDecodeError e_conv;
16842         e_conv.inner = (void*)(e & (~1));
16843         e_conv.is_owned = (e & 1) || (e == 0);
16844         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16845         e_conv = DecodeError_clone(&e_conv);
16846         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
16847         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
16848         return (uintptr_t)ret_conv;
16849 }
16850
16851 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16852         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
16853         jboolean ret_val = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
16854         return ret_val;
16855 }
16856
16857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16858         if ((_res & 1) != 0) return;
16859         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16860         CHECK_ACCESS(_res_ptr);
16861         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
16862         FREE((void*)_res);
16863         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
16864 }
16865
16866 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
16867         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
16868         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
16869         return (uintptr_t)ret_conv;
16870 }
16871 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16872         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
16873         intptr_t ret_val = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
16874         return ret_val;
16875 }
16876
16877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16878         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
16879         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
16880         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
16881         return (uintptr_t)ret_conv;
16882 }
16883
16884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16885         LDKCVec_TxOutZ _res_constr;
16886         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16887         if (_res_constr.datalen > 0)
16888                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
16889         else
16890                 _res_constr.data = NULL;
16891         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16892         for (size_t h = 0; h < _res_constr.datalen; h++) {
16893                 int64_t _res_conv_7 = _res_vals[h];
16894                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
16895                 CHECK_ACCESS(_res_conv_7_ptr);
16896                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
16897                 FREE((void*)_res_conv_7);
16898                 _res_constr.data[h] = _res_conv_7_conv;
16899         }
16900         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16901         CVec_TxOutZ_free(_res_constr);
16902 }
16903
16904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16905         LDKTransaction o_ref;
16906         o_ref.datalen = (*env)->GetArrayLength(env, o);
16907         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
16908         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
16909         o_ref.data_is_owned = true;
16910         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
16911         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
16912         return (uintptr_t)ret_conv;
16913 }
16914
16915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
16916         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
16917         *ret_conv = CResult_TransactionNoneZ_err();
16918         return (uintptr_t)ret_conv;
16919 }
16920
16921 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16922         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
16923         jboolean ret_val = CResult_TransactionNoneZ_is_ok(o_conv);
16924         return ret_val;
16925 }
16926
16927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16928         if ((_res & 1) != 0) return;
16929         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16930         CHECK_ACCESS(_res_ptr);
16931         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
16932         FREE((void*)_res);
16933         CResult_TransactionNoneZ_free(_res_conv);
16934 }
16935
16936 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
16937         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
16938         *ret_conv = CResult_TransactionNoneZ_clone(arg);
16939         return (uintptr_t)ret_conv;
16940 }
16941 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16942         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
16943         intptr_t ret_val = CResult_TransactionNoneZ_clone_ptr(arg_conv);
16944         return ret_val;
16945 }
16946
16947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16948         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
16949         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
16950         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
16951         return (uintptr_t)ret_conv;
16952 }
16953
16954 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
16955         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16956         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
16957         return ((uintptr_t)ret_conv);
16958 }
16959 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16960         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
16961         intptr_t ret_val = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
16962         return ret_val;
16963 }
16964
16965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16966         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
16967         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16968         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
16969         return ((uintptr_t)ret_conv);
16970 }
16971
16972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
16973         LDKThirtyTwoBytes a_ref;
16974         CHECK((*env)->GetArrayLength(env, a) == 32);
16975         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
16976         LDKChannelMonitor b_conv;
16977         b_conv.inner = (void*)(b & (~1));
16978         b_conv.is_owned = (b & 1) || (b == 0);
16979         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16980         b_conv = ChannelMonitor_clone(&b_conv);
16981         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16982         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
16983         return ((uintptr_t)ret_conv);
16984 }
16985
16986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_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         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
16991         FREE((void*)_res);
16992         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
16993 }
16994
16995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16996         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
16997         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16998         if (_res_constr.datalen > 0)
16999                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
17000         else
17001                 _res_constr.data = NULL;
17002         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17003         for (size_t j = 0; j < _res_constr.datalen; j++) {
17004                 int64_t _res_conv_35 = _res_vals[j];
17005                 void* _res_conv_35_ptr = (void*)(((uintptr_t)_res_conv_35) & ~1);
17006                 CHECK_ACCESS(_res_conv_35_ptr);
17007                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
17008                 FREE((void*)_res_conv_35);
17009                 _res_constr.data[j] = _res_conv_35_conv;
17010         }
17011         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17012         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
17013 }
17014
17015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
17016         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
17017         o_constr.datalen = (*env)->GetArrayLength(env, o);
17018         if (o_constr.datalen > 0)
17019                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
17020         else
17021                 o_constr.data = NULL;
17022         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
17023         for (size_t j = 0; j < o_constr.datalen; j++) {
17024                 int64_t o_conv_35 = o_vals[j];
17025                 void* o_conv_35_ptr = (void*)(((uintptr_t)o_conv_35) & ~1);
17026                 CHECK_ACCESS(o_conv_35_ptr);
17027                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
17028                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o_conv_35) & ~1));
17029                 o_constr.data[j] = o_conv_35_conv;
17030         }
17031         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
17032         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17033         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
17034         return (uintptr_t)ret_conv;
17035 }
17036
17037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17038         LDKIOError e_conv = LDKIOError_from_java(env, e);
17039         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17040         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
17041         return (uintptr_t)ret_conv;
17042 }
17043
17044 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17045         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(o & ~1);
17046         jboolean ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
17047         return ret_val;
17048 }
17049
17050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17051         if ((_res & 1) != 0) return;
17052         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17053         CHECK_ACCESS(_res_ptr);
17054         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
17055         FREE((void*)_res);
17056         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
17057 }
17058
17059 static inline uintptr_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
17060         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17061         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
17062         return (uintptr_t)ret_conv;
17063 }
17064 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17065         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
17066         intptr_t ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
17067         return ret_val;
17068 }
17069
17070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17071         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
17072         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17073         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
17074         return (uintptr_t)ret_conv;
17075 }
17076
17077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
17078         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17079         *ret_copy = COption_u16Z_some(o);
17080         uintptr_t ret_ref = (uintptr_t)ret_copy;
17081         return ret_ref;
17082 }
17083
17084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
17085         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17086         *ret_copy = COption_u16Z_none();
17087         uintptr_t ret_ref = (uintptr_t)ret_copy;
17088         return ret_ref;
17089 }
17090
17091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
17092         if ((_res & 1) != 0) return;
17093         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17094         CHECK_ACCESS(_res_ptr);
17095         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
17096         FREE((void*)_res);
17097         COption_u16Z_free(_res_conv);
17098 }
17099
17100 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
17101         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17102         *ret_copy = COption_u16Z_clone(arg);
17103 uintptr_t ret_ref = (uintptr_t)ret_copy;
17104         return ret_ref;
17105 }
17106 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17107         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
17108         intptr_t ret_val = COption_u16Z_clone_ptr(arg_conv);
17109         return ret_val;
17110 }
17111
17112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17113         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
17114         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17115         *ret_copy = COption_u16Z_clone(orig_conv);
17116         uintptr_t ret_ref = (uintptr_t)ret_copy;
17117         return ret_ref;
17118 }
17119
17120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
17121         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17122         *ret_conv = CResult_NoneAPIErrorZ_ok();
17123         return (uintptr_t)ret_conv;
17124 }
17125
17126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17127         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17128         CHECK_ACCESS(e_ptr);
17129         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
17130         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
17131         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17132         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
17133         return (uintptr_t)ret_conv;
17134 }
17135
17136 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17137         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
17138         jboolean ret_val = CResult_NoneAPIErrorZ_is_ok(o_conv);
17139         return ret_val;
17140 }
17141
17142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17143         if ((_res & 1) != 0) return;
17144         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17145         CHECK_ACCESS(_res_ptr);
17146         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
17147         FREE((void*)_res);
17148         CResult_NoneAPIErrorZ_free(_res_conv);
17149 }
17150
17151 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
17152         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17153         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
17154         return (uintptr_t)ret_conv;
17155 }
17156 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17157         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
17158         intptr_t ret_val = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
17159         return ret_val;
17160 }
17161
17162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17163         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
17164         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17165         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
17166         return (uintptr_t)ret_conv;
17167 }
17168
17169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17170         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
17171         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17172         if (_res_constr.datalen > 0)
17173                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
17174         else
17175                 _res_constr.data = NULL;
17176         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17177         for (size_t w = 0; w < _res_constr.datalen; w++) {
17178                 int64_t _res_conv_22 = _res_vals[w];
17179                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
17180                 CHECK_ACCESS(_res_conv_22_ptr);
17181                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
17182                 FREE((void*)_res_conv_22);
17183                 _res_constr.data[w] = _res_conv_22_conv;
17184         }
17185         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17186         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
17187 }
17188
17189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17190         LDKCVec_APIErrorZ _res_constr;
17191         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17192         if (_res_constr.datalen > 0)
17193                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
17194         else
17195                 _res_constr.data = NULL;
17196         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17197         for (size_t k = 0; k < _res_constr.datalen; k++) {
17198                 int64_t _res_conv_10 = _res_vals[k];
17199                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
17200                 CHECK_ACCESS(_res_conv_10_ptr);
17201                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
17202                 FREE((void*)_res_conv_10);
17203                 _res_constr.data[k] = _res_conv_10_conv;
17204         }
17205         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17206         CVec_APIErrorZ_free(_res_constr);
17207 }
17208
17209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17210         LDKThirtyTwoBytes o_ref;
17211         CHECK((*env)->GetArrayLength(env, o) == 32);
17212         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
17213         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17214         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
17215         return (uintptr_t)ret_conv;
17216 }
17217
17218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17219         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17220         CHECK_ACCESS(e_ptr);
17221         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
17222         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
17223         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17224         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
17225         return (uintptr_t)ret_conv;
17226 }
17227
17228 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17229         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
17230         jboolean ret_val = CResult__u832APIErrorZ_is_ok(o_conv);
17231         return ret_val;
17232 }
17233
17234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17235         if ((_res & 1) != 0) return;
17236         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17237         CHECK_ACCESS(_res_ptr);
17238         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
17239         FREE((void*)_res);
17240         CResult__u832APIErrorZ_free(_res_conv);
17241 }
17242
17243 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
17244         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17245         *ret_conv = CResult__u832APIErrorZ_clone(arg);
17246         return (uintptr_t)ret_conv;
17247 }
17248 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17249         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
17250         intptr_t ret_val = CResult__u832APIErrorZ_clone_ptr(arg_conv);
17251         return ret_val;
17252 }
17253
17254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17255         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
17256         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17257         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
17258         return (uintptr_t)ret_conv;
17259 }
17260
17261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17262         LDKThirtyTwoBytes o_ref;
17263         CHECK((*env)->GetArrayLength(env, o) == 32);
17264         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
17265         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17266         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
17267         return (uintptr_t)ret_conv;
17268 }
17269
17270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17271         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17272         CHECK_ACCESS(e_ptr);
17273         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
17274         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
17275         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17276         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
17277         return (uintptr_t)ret_conv;
17278 }
17279
17280 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17281         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
17282         jboolean ret_val = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
17283         return ret_val;
17284 }
17285
17286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17287         if ((_res & 1) != 0) return;
17288         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17289         CHECK_ACCESS(_res_ptr);
17290         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
17291         FREE((void*)_res);
17292         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
17293 }
17294
17295 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
17296         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17297         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
17298         return (uintptr_t)ret_conv;
17299 }
17300 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17301         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
17302         intptr_t ret_val = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
17303         return ret_val;
17304 }
17305
17306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17307         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
17308         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17309         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
17310         return (uintptr_t)ret_conv;
17311 }
17312
17313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
17314         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17315         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
17316         return (uintptr_t)ret_conv;
17317 }
17318
17319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17320         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17321         CHECK_ACCESS(e_ptr);
17322         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
17323         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
17324         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17325         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
17326         return (uintptr_t)ret_conv;
17327 }
17328
17329 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17330         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
17331         jboolean ret_val = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
17332         return ret_val;
17333 }
17334
17335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17336         if ((_res & 1) != 0) return;
17337         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17338         CHECK_ACCESS(_res_ptr);
17339         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
17340         FREE((void*)_res);
17341         CResult_NonePaymentSendFailureZ_free(_res_conv);
17342 }
17343
17344 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
17345         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17346         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
17347         return (uintptr_t)ret_conv;
17348 }
17349 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17350         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
17351         intptr_t ret_val = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
17352         return ret_val;
17353 }
17354
17355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17356         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
17357         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17358         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
17359         return (uintptr_t)ret_conv;
17360 }
17361
17362 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
17363         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
17364         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
17365         return ((uintptr_t)ret_conv);
17366 }
17367 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17368         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
17369         intptr_t ret_val = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
17370         return ret_val;
17371 }
17372
17373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17374         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
17375         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
17376         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
17377         return ((uintptr_t)ret_conv);
17378 }
17379
17380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
17381         LDKThirtyTwoBytes a_ref;
17382         CHECK((*env)->GetArrayLength(env, a) == 32);
17383         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
17384         LDKThirtyTwoBytes b_ref;
17385         CHECK((*env)->GetArrayLength(env, b) == 32);
17386         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
17387         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
17388         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
17389         return ((uintptr_t)ret_conv);
17390 }
17391
17392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17393         if ((_res & 1) != 0) return;
17394         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17395         CHECK_ACCESS(_res_ptr);
17396         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
17397         FREE((void*)_res);
17398         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
17399 }
17400
17401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17402         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17403         CHECK_ACCESS(o_ptr);
17404         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
17405         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
17406         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17407         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
17408         return (uintptr_t)ret_conv;
17409 }
17410
17411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17412         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17413         CHECK_ACCESS(e_ptr);
17414         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
17415         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
17416         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17417         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
17418         return (uintptr_t)ret_conv;
17419 }
17420
17421 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17422         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
17423         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
17424         return ret_val;
17425 }
17426
17427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17428         if ((_res & 1) != 0) return;
17429         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17430         CHECK_ACCESS(_res_ptr);
17431         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
17432         FREE((void*)_res);
17433         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
17434 }
17435
17436 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
17437         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17438         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
17439         return (uintptr_t)ret_conv;
17440 }
17441 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17442         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
17443         intptr_t ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
17444         return ret_val;
17445 }
17446
17447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17448         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
17449         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17450         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
17451         return (uintptr_t)ret_conv;
17452 }
17453
17454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17455         LDKCVec_NetAddressZ _res_constr;
17456         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17457         if (_res_constr.datalen > 0)
17458                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17459         else
17460                 _res_constr.data = NULL;
17461         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17462         for (size_t m = 0; m < _res_constr.datalen; m++) {
17463                 int64_t _res_conv_12 = _res_vals[m];
17464                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
17465                 CHECK_ACCESS(_res_conv_12_ptr);
17466                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
17467                 FREE((void*)_res_conv_12);
17468                 _res_constr.data[m] = _res_conv_12_conv;
17469         }
17470         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17471         CVec_NetAddressZ_free(_res_constr);
17472 }
17473
17474 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
17475         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17476         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
17477         return ((uintptr_t)ret_conv);
17478 }
17479 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17480         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
17481         intptr_t ret_val = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
17482         return ret_val;
17483 }
17484
17485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17486         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
17487         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17488         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
17489         return ((uintptr_t)ret_conv);
17490 }
17491
17492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
17493         LDKThirtyTwoBytes a_ref;
17494         CHECK((*env)->GetArrayLength(env, a) == 32);
17495         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
17496         LDKThirtyTwoBytes b_ref;
17497         CHECK((*env)->GetArrayLength(env, b) == 32);
17498         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
17499         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17500         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
17501         return ((uintptr_t)ret_conv);
17502 }
17503
17504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17505         if ((_res & 1) != 0) return;
17506         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17507         CHECK_ACCESS(_res_ptr);
17508         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
17509         FREE((void*)_res);
17510         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
17511 }
17512
17513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17514         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17515         CHECK_ACCESS(o_ptr);
17516         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
17517         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
17518         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
17519         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
17520         return (uintptr_t)ret_conv;
17521 }
17522
17523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
17524         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
17525         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
17526         return (uintptr_t)ret_conv;
17527 }
17528
17529 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17530         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
17531         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
17532         return ret_val;
17533 }
17534
17535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17536         if ((_res & 1) != 0) return;
17537         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17538         CHECK_ACCESS(_res_ptr);
17539         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
17540         FREE((void*)_res);
17541         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
17542 }
17543
17544 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
17545         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
17546         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
17547         return (uintptr_t)ret_conv;
17548 }
17549 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17550         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
17551         intptr_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
17552         return ret_val;
17553 }
17554
17555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17556         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
17557         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
17558         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
17559         return (uintptr_t)ret_conv;
17560 }
17561
17562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17563         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17564         CHECK_ACCESS(o_ptr);
17565         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
17566         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
17567         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
17568         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
17569         return (uintptr_t)ret_conv;
17570 }
17571
17572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17573         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17574         CHECK_ACCESS(e_ptr);
17575         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
17576         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
17577         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
17578         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
17579         return (uintptr_t)ret_conv;
17580 }
17581
17582 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17583         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
17584         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
17585         return ret_val;
17586 }
17587
17588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17589         if ((_res & 1) != 0) return;
17590         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17591         CHECK_ACCESS(_res_ptr);
17592         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
17593         FREE((void*)_res);
17594         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
17595 }
17596
17597 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
17598         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
17599         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
17600         return (uintptr_t)ret_conv;
17601 }
17602 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17603         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
17604         intptr_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
17605         return ret_val;
17606 }
17607
17608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17609         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
17610         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
17611         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
17612         return (uintptr_t)ret_conv;
17613 }
17614
17615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17616         LDKThirtyTwoBytes o_ref;
17617         CHECK((*env)->GetArrayLength(env, o) == 32);
17618         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
17619         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
17620         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
17621         return (uintptr_t)ret_conv;
17622 }
17623
17624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
17625         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
17626         *ret_conv = CResult_PaymentSecretNoneZ_err();
17627         return (uintptr_t)ret_conv;
17628 }
17629
17630 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17631         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
17632         jboolean ret_val = CResult_PaymentSecretNoneZ_is_ok(o_conv);
17633         return ret_val;
17634 }
17635
17636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17637         if ((_res & 1) != 0) return;
17638         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17639         CHECK_ACCESS(_res_ptr);
17640         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
17641         FREE((void*)_res);
17642         CResult_PaymentSecretNoneZ_free(_res_conv);
17643 }
17644
17645 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
17646         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
17647         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
17648         return (uintptr_t)ret_conv;
17649 }
17650 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17651         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
17652         intptr_t ret_val = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
17653         return ret_val;
17654 }
17655
17656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17657         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
17658         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
17659         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
17660         return (uintptr_t)ret_conv;
17661 }
17662
17663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17664         LDKThirtyTwoBytes o_ref;
17665         CHECK((*env)->GetArrayLength(env, o) == 32);
17666         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
17667         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
17668         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
17669         return (uintptr_t)ret_conv;
17670 }
17671
17672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17673         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17674         CHECK_ACCESS(e_ptr);
17675         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
17676         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
17677         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
17678         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
17679         return (uintptr_t)ret_conv;
17680 }
17681
17682 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17683         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
17684         jboolean ret_val = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
17685         return ret_val;
17686 }
17687
17688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17689         if ((_res & 1) != 0) return;
17690         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17691         CHECK_ACCESS(_res_ptr);
17692         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
17693         FREE((void*)_res);
17694         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
17695 }
17696
17697 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
17698         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
17699         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
17700         return (uintptr_t)ret_conv;
17701 }
17702 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17703         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
17704         intptr_t ret_val = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
17705         return ret_val;
17706 }
17707
17708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17709         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
17710         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
17711         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
17712         return (uintptr_t)ret_conv;
17713 }
17714
17715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17716         LDKThirtyTwoBytes o_ref;
17717         CHECK((*env)->GetArrayLength(env, o) == 32);
17718         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
17719         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
17720         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
17721         return (uintptr_t)ret_conv;
17722 }
17723
17724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17725         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17726         CHECK_ACCESS(e_ptr);
17727         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
17728         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
17729         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
17730         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
17731         return (uintptr_t)ret_conv;
17732 }
17733
17734 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17735         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
17736         jboolean ret_val = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
17737         return ret_val;
17738 }
17739
17740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17741         if ((_res & 1) != 0) return;
17742         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17743         CHECK_ACCESS(_res_ptr);
17744         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
17745         FREE((void*)_res);
17746         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
17747 }
17748
17749 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
17750         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
17751         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
17752         return (uintptr_t)ret_conv;
17753 }
17754 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17755         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
17756         intptr_t ret_val = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
17757         return ret_val;
17758 }
17759
17760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17761         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
17762         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
17763         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
17764         return (uintptr_t)ret_conv;
17765 }
17766
17767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17768         LDKCounterpartyForwardingInfo o_conv;
17769         o_conv.inner = (void*)(o & (~1));
17770         o_conv.is_owned = (o & 1) || (o == 0);
17771         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17772         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
17773         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
17774         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
17775         return (uintptr_t)ret_conv;
17776 }
17777
17778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17779         LDKDecodeError e_conv;
17780         e_conv.inner = (void*)(e & (~1));
17781         e_conv.is_owned = (e & 1) || (e == 0);
17782         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17783         e_conv = DecodeError_clone(&e_conv);
17784         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
17785         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
17786         return (uintptr_t)ret_conv;
17787 }
17788
17789 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17790         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
17791         jboolean ret_val = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
17792         return ret_val;
17793 }
17794
17795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17796         if ((_res & 1) != 0) return;
17797         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17798         CHECK_ACCESS(_res_ptr);
17799         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
17800         FREE((void*)_res);
17801         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
17802 }
17803
17804 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
17805         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
17806         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
17807         return (uintptr_t)ret_conv;
17808 }
17809 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17810         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
17811         intptr_t ret_val = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
17812         return ret_val;
17813 }
17814
17815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17816         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
17817         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
17818         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
17819         return (uintptr_t)ret_conv;
17820 }
17821
17822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17823         LDKChannelCounterparty o_conv;
17824         o_conv.inner = (void*)(o & (~1));
17825         o_conv.is_owned = (o & 1) || (o == 0);
17826         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17827         o_conv = ChannelCounterparty_clone(&o_conv);
17828         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
17829         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
17830         return (uintptr_t)ret_conv;
17831 }
17832
17833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17834         LDKDecodeError e_conv;
17835         e_conv.inner = (void*)(e & (~1));
17836         e_conv.is_owned = (e & 1) || (e == 0);
17837         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17838         e_conv = DecodeError_clone(&e_conv);
17839         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
17840         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
17841         return (uintptr_t)ret_conv;
17842 }
17843
17844 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17845         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
17846         jboolean ret_val = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
17847         return ret_val;
17848 }
17849
17850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17851         if ((_res & 1) != 0) return;
17852         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17853         CHECK_ACCESS(_res_ptr);
17854         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
17855         FREE((void*)_res);
17856         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
17857 }
17858
17859 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
17860         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
17861         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
17862         return (uintptr_t)ret_conv;
17863 }
17864 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17865         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
17866         intptr_t ret_val = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
17867         return ret_val;
17868 }
17869
17870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17871         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
17872         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
17873         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
17874         return (uintptr_t)ret_conv;
17875 }
17876
17877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17878         LDKChannelDetails o_conv;
17879         o_conv.inner = (void*)(o & (~1));
17880         o_conv.is_owned = (o & 1) || (o == 0);
17881         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17882         o_conv = ChannelDetails_clone(&o_conv);
17883         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
17884         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
17885         return (uintptr_t)ret_conv;
17886 }
17887
17888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17889         LDKDecodeError e_conv;
17890         e_conv.inner = (void*)(e & (~1));
17891         e_conv.is_owned = (e & 1) || (e == 0);
17892         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17893         e_conv = DecodeError_clone(&e_conv);
17894         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
17895         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
17896         return (uintptr_t)ret_conv;
17897 }
17898
17899 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17900         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
17901         jboolean ret_val = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
17902         return ret_val;
17903 }
17904
17905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17906         if ((_res & 1) != 0) return;
17907         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17908         CHECK_ACCESS(_res_ptr);
17909         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
17910         FREE((void*)_res);
17911         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
17912 }
17913
17914 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
17915         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
17916         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
17917         return (uintptr_t)ret_conv;
17918 }
17919 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17920         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
17921         intptr_t ret_val = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
17922         return ret_val;
17923 }
17924
17925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17926         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
17927         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
17928         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
17929         return (uintptr_t)ret_conv;
17930 }
17931
17932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17933         LDKPhantomRouteHints o_conv;
17934         o_conv.inner = (void*)(o & (~1));
17935         o_conv.is_owned = (o & 1) || (o == 0);
17936         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17937         o_conv = PhantomRouteHints_clone(&o_conv);
17938         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
17939         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
17940         return (uintptr_t)ret_conv;
17941 }
17942
17943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17944         LDKDecodeError e_conv;
17945         e_conv.inner = (void*)(e & (~1));
17946         e_conv.is_owned = (e & 1) || (e == 0);
17947         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17948         e_conv = DecodeError_clone(&e_conv);
17949         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
17950         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
17951         return (uintptr_t)ret_conv;
17952 }
17953
17954 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17955         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
17956         jboolean ret_val = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
17957         return ret_val;
17958 }
17959
17960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17961         if ((_res & 1) != 0) return;
17962         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17963         CHECK_ACCESS(_res_ptr);
17964         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
17965         FREE((void*)_res);
17966         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
17967 }
17968
17969 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
17970         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
17971         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
17972         return (uintptr_t)ret_conv;
17973 }
17974 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17975         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
17976         intptr_t ret_val = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
17977         return ret_val;
17978 }
17979
17980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17981         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
17982         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
17983         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
17984         return (uintptr_t)ret_conv;
17985 }
17986
17987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17988         LDKCVec_ChannelMonitorZ _res_constr;
17989         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17990         if (_res_constr.datalen > 0)
17991                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
17992         else
17993                 _res_constr.data = NULL;
17994         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17995         for (size_t q = 0; q < _res_constr.datalen; q++) {
17996                 int64_t _res_conv_16 = _res_vals[q];
17997                 LDKChannelMonitor _res_conv_16_conv;
17998                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
17999                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
18000                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
18001                 _res_constr.data[q] = _res_conv_16_conv;
18002         }
18003         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18004         CVec_ChannelMonitorZ_free(_res_constr);
18005 }
18006
18007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
18008         LDKThirtyTwoBytes a_ref;
18009         CHECK((*env)->GetArrayLength(env, a) == 32);
18010         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18011         LDKChannelManager b_conv;
18012         b_conv.inner = (void*)(b & (~1));
18013         b_conv.is_owned = (b & 1) || (b == 0);
18014         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18015         // WARNING: we need a move here but no clone is available for LDKChannelManager
18016         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
18017         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
18018         return ((uintptr_t)ret_conv);
18019 }
18020
18021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18022         if ((_res & 1) != 0) return;
18023         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18024         CHECK_ACCESS(_res_ptr);
18025         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
18026         FREE((void*)_res);
18027         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
18028 }
18029
18030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18031         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18032         CHECK_ACCESS(o_ptr);
18033         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
18034         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
18035         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
18036         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
18037         return (uintptr_t)ret_conv;
18038 }
18039
18040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18041         LDKDecodeError e_conv;
18042         e_conv.inner = (void*)(e & (~1));
18043         e_conv.is_owned = (e & 1) || (e == 0);
18044         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18045         e_conv = DecodeError_clone(&e_conv);
18046         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
18047         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
18048         return (uintptr_t)ret_conv;
18049 }
18050
18051 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18052         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
18053         jboolean ret_val = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
18054         return ret_val;
18055 }
18056
18057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18058         if ((_res & 1) != 0) return;
18059         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18060         CHECK_ACCESS(_res_ptr);
18061         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
18062         FREE((void*)_res);
18063         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
18064 }
18065
18066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18067         LDKChannelConfig o_conv;
18068         o_conv.inner = (void*)(o & (~1));
18069         o_conv.is_owned = (o & 1) || (o == 0);
18070         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18071         o_conv = ChannelConfig_clone(&o_conv);
18072         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18073         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
18074         return (uintptr_t)ret_conv;
18075 }
18076
18077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18078         LDKDecodeError e_conv;
18079         e_conv.inner = (void*)(e & (~1));
18080         e_conv.is_owned = (e & 1) || (e == 0);
18081         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18082         e_conv = DecodeError_clone(&e_conv);
18083         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18084         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
18085         return (uintptr_t)ret_conv;
18086 }
18087
18088 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18089         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
18090         jboolean ret_val = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
18091         return ret_val;
18092 }
18093
18094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18095         if ((_res & 1) != 0) return;
18096         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18097         CHECK_ACCESS(_res_ptr);
18098         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
18099         FREE((void*)_res);
18100         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
18101 }
18102
18103 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
18104         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18105         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
18106         return (uintptr_t)ret_conv;
18107 }
18108 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18109         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
18110         intptr_t ret_val = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
18111         return ret_val;
18112 }
18113
18114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18115         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
18116         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18117         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
18118         return (uintptr_t)ret_conv;
18119 }
18120
18121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18122         LDKOutPoint o_conv;
18123         o_conv.inner = (void*)(o & (~1));
18124         o_conv.is_owned = (o & 1) || (o == 0);
18125         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18126         o_conv = OutPoint_clone(&o_conv);
18127         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18128         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
18129         return (uintptr_t)ret_conv;
18130 }
18131
18132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18133         LDKDecodeError e_conv;
18134         e_conv.inner = (void*)(e & (~1));
18135         e_conv.is_owned = (e & 1) || (e == 0);
18136         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18137         e_conv = DecodeError_clone(&e_conv);
18138         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18139         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
18140         return (uintptr_t)ret_conv;
18141 }
18142
18143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18144         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
18145         jboolean ret_val = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
18146         return ret_val;
18147 }
18148
18149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18150         if ((_res & 1) != 0) return;
18151         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18152         CHECK_ACCESS(_res_ptr);
18153         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
18154         FREE((void*)_res);
18155         CResult_OutPointDecodeErrorZ_free(_res_conv);
18156 }
18157
18158 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
18159         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18160         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
18161         return (uintptr_t)ret_conv;
18162 }
18163 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18164         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
18165         intptr_t ret_val = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
18166         return ret_val;
18167 }
18168
18169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18170         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
18171         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18172         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
18173         return (uintptr_t)ret_conv;
18174 }
18175
18176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18177         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18178         CHECK_ACCESS(o_ptr);
18179         LDKType o_conv = *(LDKType*)(o_ptr);
18180         if (o_conv.free == LDKType_JCalls_free) {
18181                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18182                 LDKType_JCalls_cloned(&o_conv);
18183         }
18184         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18185         *ret_copy = COption_TypeZ_some(o_conv);
18186         uintptr_t ret_ref = (uintptr_t)ret_copy;
18187         return ret_ref;
18188 }
18189
18190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
18191         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18192         *ret_copy = COption_TypeZ_none();
18193         uintptr_t ret_ref = (uintptr_t)ret_copy;
18194         return ret_ref;
18195 }
18196
18197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18198         if ((_res & 1) != 0) return;
18199         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18200         CHECK_ACCESS(_res_ptr);
18201         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
18202         FREE((void*)_res);
18203         COption_TypeZ_free(_res_conv);
18204 }
18205
18206 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
18207         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18208         *ret_copy = COption_TypeZ_clone(arg);
18209 uintptr_t ret_ref = (uintptr_t)ret_copy;
18210         return ret_ref;
18211 }
18212 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18213         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
18214         intptr_t ret_val = COption_TypeZ_clone_ptr(arg_conv);
18215         return ret_val;
18216 }
18217
18218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18219         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
18220         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18221         *ret_copy = COption_TypeZ_clone(orig_conv);
18222         uintptr_t ret_ref = (uintptr_t)ret_copy;
18223         return ret_ref;
18224 }
18225
18226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18227         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18228         CHECK_ACCESS(o_ptr);
18229         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
18230         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
18231         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18232         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
18233         return (uintptr_t)ret_conv;
18234 }
18235
18236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18237         LDKDecodeError e_conv;
18238         e_conv.inner = (void*)(e & (~1));
18239         e_conv.is_owned = (e & 1) || (e == 0);
18240         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18241         e_conv = DecodeError_clone(&e_conv);
18242         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18243         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
18244         return (uintptr_t)ret_conv;
18245 }
18246
18247 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18248         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
18249         jboolean ret_val = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
18250         return ret_val;
18251 }
18252
18253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18254         if ((_res & 1) != 0) return;
18255         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18256         CHECK_ACCESS(_res_ptr);
18257         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
18258         FREE((void*)_res);
18259         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
18260 }
18261
18262 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
18263         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18264         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
18265         return (uintptr_t)ret_conv;
18266 }
18267 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18268         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
18269         intptr_t ret_val = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
18270         return ret_val;
18271 }
18272
18273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18274         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
18275         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18276         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
18277         return (uintptr_t)ret_conv;
18278 }
18279
18280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18281         LDKThirtyTwoBytes o_ref;
18282         CHECK((*env)->GetArrayLength(env, o) == 32);
18283         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18284         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18285         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
18286         return (uintptr_t)ret_conv;
18287 }
18288
18289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18290         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18291         CHECK_ACCESS(e_ptr);
18292         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
18293         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
18294         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18295         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
18296         return (uintptr_t)ret_conv;
18297 }
18298
18299 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18300         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
18301         jboolean ret_val = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
18302         return ret_val;
18303 }
18304
18305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18306         if ((_res & 1) != 0) return;
18307         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18308         CHECK_ACCESS(_res_ptr);
18309         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
18310         FREE((void*)_res);
18311         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
18312 }
18313
18314 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
18315         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18316         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
18317         return (uintptr_t)ret_conv;
18318 }
18319 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18320         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
18321         intptr_t ret_val = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
18322         return ret_val;
18323 }
18324
18325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18326         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
18327         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18328         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
18329         return (uintptr_t)ret_conv;
18330 }
18331
18332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
18333         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
18334         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
18335         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
18336         return (uintptr_t)ret_conv;
18337 }
18338
18339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
18340         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
18341         *ret_conv = CResult_SiPrefixNoneZ_err();
18342         return (uintptr_t)ret_conv;
18343 }
18344
18345 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18346         LDKCResult_SiPrefixNoneZ* o_conv = (LDKCResult_SiPrefixNoneZ*)(o & ~1);
18347         jboolean ret_val = CResult_SiPrefixNoneZ_is_ok(o_conv);
18348         return ret_val;
18349 }
18350
18351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18352         if ((_res & 1) != 0) return;
18353         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18354         CHECK_ACCESS(_res_ptr);
18355         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
18356         FREE((void*)_res);
18357         CResult_SiPrefixNoneZ_free(_res_conv);
18358 }
18359
18360 static inline uintptr_t CResult_SiPrefixNoneZ_clone_ptr(LDKCResult_SiPrefixNoneZ *NONNULL_PTR arg) {
18361         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
18362         *ret_conv = CResult_SiPrefixNoneZ_clone(arg);
18363         return (uintptr_t)ret_conv;
18364 }
18365 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18366         LDKCResult_SiPrefixNoneZ* arg_conv = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
18367         intptr_t ret_val = CResult_SiPrefixNoneZ_clone_ptr(arg_conv);
18368         return ret_val;
18369 }
18370
18371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18372         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
18373         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
18374         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
18375         return (uintptr_t)ret_conv;
18376 }
18377
18378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18379         LDKInvoice o_conv;
18380         o_conv.inner = (void*)(o & (~1));
18381         o_conv.is_owned = (o & 1) || (o == 0);
18382         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18383         o_conv = Invoice_clone(&o_conv);
18384         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
18385         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
18386         return (uintptr_t)ret_conv;
18387 }
18388
18389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
18390         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
18391         *ret_conv = CResult_InvoiceNoneZ_err();
18392         return (uintptr_t)ret_conv;
18393 }
18394
18395 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18396         LDKCResult_InvoiceNoneZ* o_conv = (LDKCResult_InvoiceNoneZ*)(o & ~1);
18397         jboolean ret_val = CResult_InvoiceNoneZ_is_ok(o_conv);
18398         return ret_val;
18399 }
18400
18401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18402         if ((_res & 1) != 0) return;
18403         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18404         CHECK_ACCESS(_res_ptr);
18405         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
18406         FREE((void*)_res);
18407         CResult_InvoiceNoneZ_free(_res_conv);
18408 }
18409
18410 static inline uintptr_t CResult_InvoiceNoneZ_clone_ptr(LDKCResult_InvoiceNoneZ *NONNULL_PTR arg) {
18411         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
18412         *ret_conv = CResult_InvoiceNoneZ_clone(arg);
18413         return (uintptr_t)ret_conv;
18414 }
18415 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18416         LDKCResult_InvoiceNoneZ* arg_conv = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
18417         intptr_t ret_val = CResult_InvoiceNoneZ_clone_ptr(arg_conv);
18418         return ret_val;
18419 }
18420
18421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18422         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
18423         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
18424         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
18425         return (uintptr_t)ret_conv;
18426 }
18427
18428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18429         LDKSignedRawInvoice o_conv;
18430         o_conv.inner = (void*)(o & (~1));
18431         o_conv.is_owned = (o & 1) || (o == 0);
18432         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18433         o_conv = SignedRawInvoice_clone(&o_conv);
18434         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
18435         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
18436         return (uintptr_t)ret_conv;
18437 }
18438
18439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
18440         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
18441         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
18442         return (uintptr_t)ret_conv;
18443 }
18444
18445 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18446         LDKCResult_SignedRawInvoiceNoneZ* o_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(o & ~1);
18447         jboolean ret_val = CResult_SignedRawInvoiceNoneZ_is_ok(o_conv);
18448         return ret_val;
18449 }
18450
18451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18452         if ((_res & 1) != 0) return;
18453         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18454         CHECK_ACCESS(_res_ptr);
18455         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
18456         FREE((void*)_res);
18457         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
18458 }
18459
18460 static inline uintptr_t CResult_SignedRawInvoiceNoneZ_clone_ptr(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR arg) {
18461         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
18462         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(arg);
18463         return (uintptr_t)ret_conv;
18464 }
18465 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18466         LDKCResult_SignedRawInvoiceNoneZ* arg_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
18467         intptr_t ret_val = CResult_SignedRawInvoiceNoneZ_clone_ptr(arg_conv);
18468         return ret_val;
18469 }
18470
18471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18472         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
18473         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
18474         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
18475         return (uintptr_t)ret_conv;
18476 }
18477
18478 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
18479         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
18480         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
18481         return ((uintptr_t)ret_conv);
18482 }
18483 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18484         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
18485         intptr_t ret_val = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
18486         return ret_val;
18487 }
18488
18489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18490         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
18491         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
18492         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
18493         return ((uintptr_t)ret_conv);
18494 }
18495
18496 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) {
18497         LDKRawInvoice a_conv;
18498         a_conv.inner = (void*)(a & (~1));
18499         a_conv.is_owned = (a & 1) || (a == 0);
18500         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18501         a_conv = RawInvoice_clone(&a_conv);
18502         LDKThirtyTwoBytes b_ref;
18503         CHECK((*env)->GetArrayLength(env, b) == 32);
18504         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
18505         LDKInvoiceSignature c_conv;
18506         c_conv.inner = (void*)(c & (~1));
18507         c_conv.is_owned = (c & 1) || (c == 0);
18508         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
18509         c_conv = InvoiceSignature_clone(&c_conv);
18510         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
18511         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
18512         return ((uintptr_t)ret_conv);
18513 }
18514
18515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18516         if ((_res & 1) != 0) return;
18517         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18518         CHECK_ACCESS(_res_ptr);
18519         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
18520         FREE((void*)_res);
18521         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
18522 }
18523
18524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18525         LDKPayeePubKey o_conv;
18526         o_conv.inner = (void*)(o & (~1));
18527         o_conv.is_owned = (o & 1) || (o == 0);
18528         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18529         o_conv = PayeePubKey_clone(&o_conv);
18530         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
18531         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
18532         return (uintptr_t)ret_conv;
18533 }
18534
18535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18536         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
18537         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
18538         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
18539         return (uintptr_t)ret_conv;
18540 }
18541
18542 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18543         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
18544         jboolean ret_val = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
18545         return ret_val;
18546 }
18547
18548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18549         if ((_res & 1) != 0) return;
18550         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18551         CHECK_ACCESS(_res_ptr);
18552         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
18553         FREE((void*)_res);
18554         CResult_PayeePubKeyErrorZ_free(_res_conv);
18555 }
18556
18557 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
18558         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
18559         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
18560         return (uintptr_t)ret_conv;
18561 }
18562 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18563         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
18564         intptr_t ret_val = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
18565         return ret_val;
18566 }
18567
18568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18569         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
18570         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
18571         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
18572         return (uintptr_t)ret_conv;
18573 }
18574
18575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18576         LDKCVec_PrivateRouteZ _res_constr;
18577         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18578         if (_res_constr.datalen > 0)
18579                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
18580         else
18581                 _res_constr.data = NULL;
18582         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18583         for (size_t o = 0; o < _res_constr.datalen; o++) {
18584                 int64_t _res_conv_14 = _res_vals[o];
18585                 LDKPrivateRoute _res_conv_14_conv;
18586                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
18587                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
18588                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
18589                 _res_constr.data[o] = _res_conv_14_conv;
18590         }
18591         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18592         CVec_PrivateRouteZ_free(_res_constr);
18593 }
18594
18595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18596         LDKPositiveTimestamp o_conv;
18597         o_conv.inner = (void*)(o & (~1));
18598         o_conv.is_owned = (o & 1) || (o == 0);
18599         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18600         o_conv = PositiveTimestamp_clone(&o_conv);
18601         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
18602         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
18603         return (uintptr_t)ret_conv;
18604 }
18605
18606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18607         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
18608         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
18609         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
18610         return (uintptr_t)ret_conv;
18611 }
18612
18613 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18614         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
18615         jboolean ret_val = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
18616         return ret_val;
18617 }
18618
18619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18620         if ((_res & 1) != 0) return;
18621         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18622         CHECK_ACCESS(_res_ptr);
18623         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
18624         FREE((void*)_res);
18625         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
18626 }
18627
18628 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
18629         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
18630         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
18631         return (uintptr_t)ret_conv;
18632 }
18633 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18634         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
18635         intptr_t ret_val = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
18636         return ret_val;
18637 }
18638
18639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18640         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
18641         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
18642         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
18643         return (uintptr_t)ret_conv;
18644 }
18645
18646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
18647         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
18648         *ret_conv = CResult_NoneSemanticErrorZ_ok();
18649         return (uintptr_t)ret_conv;
18650 }
18651
18652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18653         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
18654         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
18655         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
18656         return (uintptr_t)ret_conv;
18657 }
18658
18659 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18660         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
18661         jboolean ret_val = CResult_NoneSemanticErrorZ_is_ok(o_conv);
18662         return ret_val;
18663 }
18664
18665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18666         if ((_res & 1) != 0) return;
18667         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18668         CHECK_ACCESS(_res_ptr);
18669         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
18670         FREE((void*)_res);
18671         CResult_NoneSemanticErrorZ_free(_res_conv);
18672 }
18673
18674 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
18675         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
18676         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
18677         return (uintptr_t)ret_conv;
18678 }
18679 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18680         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
18681         intptr_t ret_val = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
18682         return ret_val;
18683 }
18684
18685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18686         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
18687         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
18688         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
18689         return (uintptr_t)ret_conv;
18690 }
18691
18692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18693         LDKInvoice o_conv;
18694         o_conv.inner = (void*)(o & (~1));
18695         o_conv.is_owned = (o & 1) || (o == 0);
18696         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18697         o_conv = Invoice_clone(&o_conv);
18698         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
18699         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
18700         return (uintptr_t)ret_conv;
18701 }
18702
18703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18704         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
18705         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
18706         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
18707         return (uintptr_t)ret_conv;
18708 }
18709
18710 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18711         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
18712         jboolean ret_val = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
18713         return ret_val;
18714 }
18715
18716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18717         if ((_res & 1) != 0) return;
18718         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18719         CHECK_ACCESS(_res_ptr);
18720         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
18721         FREE((void*)_res);
18722         CResult_InvoiceSemanticErrorZ_free(_res_conv);
18723 }
18724
18725 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
18726         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
18727         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
18728         return (uintptr_t)ret_conv;
18729 }
18730 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18731         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
18732         intptr_t ret_val = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
18733         return ret_val;
18734 }
18735
18736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18737         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
18738         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
18739         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
18740         return (uintptr_t)ret_conv;
18741 }
18742
18743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18744         LDKDescription o_conv;
18745         o_conv.inner = (void*)(o & (~1));
18746         o_conv.is_owned = (o & 1) || (o == 0);
18747         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18748         o_conv = Description_clone(&o_conv);
18749         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
18750         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
18751         return (uintptr_t)ret_conv;
18752 }
18753
18754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18755         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
18756         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
18757         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
18758         return (uintptr_t)ret_conv;
18759 }
18760
18761 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18762         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
18763         jboolean ret_val = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
18764         return ret_val;
18765 }
18766
18767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18768         if ((_res & 1) != 0) return;
18769         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18770         CHECK_ACCESS(_res_ptr);
18771         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
18772         FREE((void*)_res);
18773         CResult_DescriptionCreationErrorZ_free(_res_conv);
18774 }
18775
18776 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
18777         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
18778         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
18779         return (uintptr_t)ret_conv;
18780 }
18781 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18782         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
18783         intptr_t ret_val = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
18784         return ret_val;
18785 }
18786
18787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18788         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
18789         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
18790         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
18791         return (uintptr_t)ret_conv;
18792 }
18793
18794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18795         LDKPrivateRoute o_conv;
18796         o_conv.inner = (void*)(o & (~1));
18797         o_conv.is_owned = (o & 1) || (o == 0);
18798         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18799         o_conv = PrivateRoute_clone(&o_conv);
18800         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
18801         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
18802         return (uintptr_t)ret_conv;
18803 }
18804
18805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18806         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
18807         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
18808         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
18809         return (uintptr_t)ret_conv;
18810 }
18811
18812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18813         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
18814         jboolean ret_val = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
18815         return ret_val;
18816 }
18817
18818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_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_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
18823         FREE((void*)_res);
18824         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
18825 }
18826
18827 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
18828         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
18829         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
18830         return (uintptr_t)ret_conv;
18831 }
18832 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18833         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
18834         intptr_t ret_val = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
18835         return ret_val;
18836 }
18837
18838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18839         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
18840         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
18841         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
18842         return (uintptr_t)ret_conv;
18843 }
18844
18845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
18846         LDKStr o_conv = java_to_owned_str(env, o);
18847         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
18848         *ret_conv = CResult_StringErrorZ_ok(o_conv);
18849         return (uintptr_t)ret_conv;
18850 }
18851
18852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18853         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
18854         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
18855         *ret_conv = CResult_StringErrorZ_err(e_conv);
18856         return (uintptr_t)ret_conv;
18857 }
18858
18859 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18860         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
18861         jboolean ret_val = CResult_StringErrorZ_is_ok(o_conv);
18862         return ret_val;
18863 }
18864
18865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18866         if ((_res & 1) != 0) return;
18867         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18868         CHECK_ACCESS(_res_ptr);
18869         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
18870         FREE((void*)_res);
18871         CResult_StringErrorZ_free(_res_conv);
18872 }
18873
18874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18875         LDKChannelMonitorUpdate o_conv;
18876         o_conv.inner = (void*)(o & (~1));
18877         o_conv.is_owned = (o & 1) || (o == 0);
18878         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18879         o_conv = ChannelMonitorUpdate_clone(&o_conv);
18880         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
18881         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
18882         return (uintptr_t)ret_conv;
18883 }
18884
18885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18886         LDKDecodeError e_conv;
18887         e_conv.inner = (void*)(e & (~1));
18888         e_conv.is_owned = (e & 1) || (e == 0);
18889         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18890         e_conv = DecodeError_clone(&e_conv);
18891         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
18892         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
18893         return (uintptr_t)ret_conv;
18894 }
18895
18896 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18897         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
18898         jboolean ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
18899         return ret_val;
18900 }
18901
18902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18903         if ((_res & 1) != 0) return;
18904         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18905         CHECK_ACCESS(_res_ptr);
18906         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
18907         FREE((void*)_res);
18908         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
18909 }
18910
18911 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
18912         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
18913         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
18914         return (uintptr_t)ret_conv;
18915 }
18916 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18917         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
18918         intptr_t ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
18919         return ret_val;
18920 }
18921
18922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18923         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
18924         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
18925         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
18926         return (uintptr_t)ret_conv;
18927 }
18928
18929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18930         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18931         CHECK_ACCESS(o_ptr);
18932         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
18933         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
18934         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
18935         *ret_copy = COption_MonitorEventZ_some(o_conv);
18936         uintptr_t ret_ref = (uintptr_t)ret_copy;
18937         return ret_ref;
18938 }
18939
18940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
18941         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
18942         *ret_copy = COption_MonitorEventZ_none();
18943         uintptr_t ret_ref = (uintptr_t)ret_copy;
18944         return ret_ref;
18945 }
18946
18947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18948         if ((_res & 1) != 0) return;
18949         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18950         CHECK_ACCESS(_res_ptr);
18951         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
18952         FREE((void*)_res);
18953         COption_MonitorEventZ_free(_res_conv);
18954 }
18955
18956 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
18957         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
18958         *ret_copy = COption_MonitorEventZ_clone(arg);
18959 uintptr_t ret_ref = (uintptr_t)ret_copy;
18960         return ret_ref;
18961 }
18962 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18963         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
18964         intptr_t ret_val = COption_MonitorEventZ_clone_ptr(arg_conv);
18965         return ret_val;
18966 }
18967
18968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18969         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
18970         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
18971         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
18972         uintptr_t ret_ref = (uintptr_t)ret_copy;
18973         return ret_ref;
18974 }
18975
18976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18977         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18978         CHECK_ACCESS(o_ptr);
18979         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
18980         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
18981         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
18982         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
18983         return (uintptr_t)ret_conv;
18984 }
18985
18986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18987         LDKDecodeError e_conv;
18988         e_conv.inner = (void*)(e & (~1));
18989         e_conv.is_owned = (e & 1) || (e == 0);
18990         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18991         e_conv = DecodeError_clone(&e_conv);
18992         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
18993         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
18994         return (uintptr_t)ret_conv;
18995 }
18996
18997 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18998         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
18999         jboolean ret_val = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
19000         return ret_val;
19001 }
19002
19003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19004         if ((_res & 1) != 0) return;
19005         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19006         CHECK_ACCESS(_res_ptr);
19007         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
19008         FREE((void*)_res);
19009         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
19010 }
19011
19012 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
19013         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19014         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
19015         return (uintptr_t)ret_conv;
19016 }
19017 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19018         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
19019         intptr_t ret_val = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
19020         return ret_val;
19021 }
19022
19023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19024         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
19025         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19026         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
19027         return (uintptr_t)ret_conv;
19028 }
19029
19030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19031         LDKHTLCUpdate o_conv;
19032         o_conv.inner = (void*)(o & (~1));
19033         o_conv.is_owned = (o & 1) || (o == 0);
19034         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19035         o_conv = HTLCUpdate_clone(&o_conv);
19036         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19037         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
19038         return (uintptr_t)ret_conv;
19039 }
19040
19041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19042         LDKDecodeError e_conv;
19043         e_conv.inner = (void*)(e & (~1));
19044         e_conv.is_owned = (e & 1) || (e == 0);
19045         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19046         e_conv = DecodeError_clone(&e_conv);
19047         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19048         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
19049         return (uintptr_t)ret_conv;
19050 }
19051
19052 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19053         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
19054         jboolean ret_val = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
19055         return ret_val;
19056 }
19057
19058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19059         if ((_res & 1) != 0) return;
19060         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19061         CHECK_ACCESS(_res_ptr);
19062         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
19063         FREE((void*)_res);
19064         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
19065 }
19066
19067 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
19068         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19069         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
19070         return (uintptr_t)ret_conv;
19071 }
19072 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19073         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
19074         intptr_t ret_val = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
19075         return ret_val;
19076 }
19077
19078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19079         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
19080         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19081         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
19082         return (uintptr_t)ret_conv;
19083 }
19084
19085 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
19086         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19087         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
19088         return ((uintptr_t)ret_conv);
19089 }
19090 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19091         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
19092         intptr_t ret_val = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
19093         return ret_val;
19094 }
19095
19096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19097         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
19098         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19099         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
19100         return ((uintptr_t)ret_conv);
19101 }
19102
19103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
19104         LDKOutPoint a_conv;
19105         a_conv.inner = (void*)(a & (~1));
19106         a_conv.is_owned = (a & 1) || (a == 0);
19107         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19108         a_conv = OutPoint_clone(&a_conv);
19109         LDKCVec_u8Z b_ref;
19110         b_ref.datalen = (*env)->GetArrayLength(env, b);
19111         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
19112         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
19113         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19114         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
19115         return ((uintptr_t)ret_conv);
19116 }
19117
19118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19119         if ((_res & 1) != 0) return;
19120         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19121         CHECK_ACCESS(_res_ptr);
19122         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
19123         FREE((void*)_res);
19124         C2Tuple_OutPointScriptZ_free(_res_conv);
19125 }
19126
19127 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
19128         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
19129         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
19130         return ((uintptr_t)ret_conv);
19131 }
19132 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19133         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
19134         intptr_t ret_val = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
19135         return ret_val;
19136 }
19137
19138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19139         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
19140         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
19141         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
19142         return ((uintptr_t)ret_conv);
19143 }
19144
19145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
19146         LDKCVec_u8Z b_ref;
19147         b_ref.datalen = (*env)->GetArrayLength(env, b);
19148         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
19149         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
19150         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
19151         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
19152         return ((uintptr_t)ret_conv);
19153 }
19154
19155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19156         if ((_res & 1) != 0) return;
19157         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19158         CHECK_ACCESS(_res_ptr);
19159         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
19160         FREE((void*)_res);
19161         C2Tuple_u32ScriptZ_free(_res_conv);
19162 }
19163
19164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19165         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
19166         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19167         if (_res_constr.datalen > 0)
19168                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
19169         else
19170                 _res_constr.data = NULL;
19171         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19172         for (size_t v = 0; v < _res_constr.datalen; v++) {
19173                 int64_t _res_conv_21 = _res_vals[v];
19174                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
19175                 CHECK_ACCESS(_res_conv_21_ptr);
19176                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
19177                 FREE((void*)_res_conv_21);
19178                 _res_constr.data[v] = _res_conv_21_conv;
19179         }
19180         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19181         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
19182 }
19183
19184 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
19185         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19186         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
19187         return ((uintptr_t)ret_conv);
19188 }
19189 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19190         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
19191         intptr_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
19192         return ret_val;
19193 }
19194
19195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19196         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
19197         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19198         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
19199         return ((uintptr_t)ret_conv);
19200 }
19201
19202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
19203         LDKThirtyTwoBytes a_ref;
19204         CHECK((*env)->GetArrayLength(env, a) == 32);
19205         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19206         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
19207         b_constr.datalen = (*env)->GetArrayLength(env, b);
19208         if (b_constr.datalen > 0)
19209                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
19210         else
19211                 b_constr.data = NULL;
19212         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
19213         for (size_t v = 0; v < b_constr.datalen; v++) {
19214                 int64_t b_conv_21 = b_vals[v];
19215                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
19216                 CHECK_ACCESS(b_conv_21_ptr);
19217                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
19218                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
19219                 b_constr.data[v] = b_conv_21_conv;
19220         }
19221         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
19222         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19223         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
19224         return ((uintptr_t)ret_conv);
19225 }
19226
19227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19228         if ((_res & 1) != 0) return;
19229         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19230         CHECK_ACCESS(_res_ptr);
19231         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
19232         FREE((void*)_res);
19233         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
19234 }
19235
19236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19237         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
19238         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19239         if (_res_constr.datalen > 0)
19240                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
19241         else
19242                 _res_constr.data = NULL;
19243         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19244         for (size_t o = 0; o < _res_constr.datalen; o++) {
19245                 int64_t _res_conv_40 = _res_vals[o];
19246                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
19247                 CHECK_ACCESS(_res_conv_40_ptr);
19248                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
19249                 FREE((void*)_res_conv_40);
19250                 _res_constr.data[o] = _res_conv_40_conv;
19251         }
19252         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19253         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
19254 }
19255
19256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19257         LDKCVec_EventZ _res_constr;
19258         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19259         if (_res_constr.datalen > 0)
19260                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
19261         else
19262                 _res_constr.data = NULL;
19263         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19264         for (size_t h = 0; h < _res_constr.datalen; h++) {
19265                 int64_t _res_conv_7 = _res_vals[h];
19266                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
19267                 CHECK_ACCESS(_res_conv_7_ptr);
19268                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
19269                 FREE((void*)_res_conv_7);
19270                 _res_constr.data[h] = _res_conv_7_conv;
19271         }
19272         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19273         CVec_EventZ_free(_res_constr);
19274 }
19275
19276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19277         LDKCVec_TransactionZ _res_constr;
19278         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19279         if (_res_constr.datalen > 0)
19280                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
19281         else
19282                 _res_constr.data = NULL;
19283         for (size_t i = 0; i < _res_constr.datalen; i++) {
19284                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19285                 LDKTransaction _res_conv_8_ref;
19286                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
19287                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
19288                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
19289                 _res_conv_8_ref.data_is_owned = true;
19290                 _res_constr.data[i] = _res_conv_8_ref;
19291         }
19292         CVec_TransactionZ_free(_res_constr);
19293 }
19294
19295 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
19296         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
19297         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
19298         return ((uintptr_t)ret_conv);
19299 }
19300 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19301         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
19302         intptr_t ret_val = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
19303         return ret_val;
19304 }
19305
19306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19307         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
19308         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
19309         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
19310         return ((uintptr_t)ret_conv);
19311 }
19312
19313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
19314         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
19315         CHECK_ACCESS(b_ptr);
19316         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
19317         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
19318         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
19319         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
19320         return ((uintptr_t)ret_conv);
19321 }
19322
19323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19324         if ((_res & 1) != 0) return;
19325         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19326         CHECK_ACCESS(_res_ptr);
19327         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
19328         FREE((void*)_res);
19329         C2Tuple_u32TxOutZ_free(_res_conv);
19330 }
19331
19332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19333         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
19334         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19335         if (_res_constr.datalen > 0)
19336                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
19337         else
19338                 _res_constr.data = NULL;
19339         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19340         for (size_t u = 0; u < _res_constr.datalen; u++) {
19341                 int64_t _res_conv_20 = _res_vals[u];
19342                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
19343                 CHECK_ACCESS(_res_conv_20_ptr);
19344                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
19345                 FREE((void*)_res_conv_20);
19346                 _res_constr.data[u] = _res_conv_20_conv;
19347         }
19348         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19349         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
19350 }
19351
19352 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
19353         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19354         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
19355         return ((uintptr_t)ret_conv);
19356 }
19357 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19358         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
19359         intptr_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
19360         return ret_val;
19361 }
19362
19363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19364         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
19365         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19366         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
19367         return ((uintptr_t)ret_conv);
19368 }
19369
19370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
19371         LDKThirtyTwoBytes a_ref;
19372         CHECK((*env)->GetArrayLength(env, a) == 32);
19373         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19374         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
19375         b_constr.datalen = (*env)->GetArrayLength(env, b);
19376         if (b_constr.datalen > 0)
19377                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
19378         else
19379                 b_constr.data = NULL;
19380         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
19381         for (size_t u = 0; u < b_constr.datalen; u++) {
19382                 int64_t b_conv_20 = b_vals[u];
19383                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
19384                 CHECK_ACCESS(b_conv_20_ptr);
19385                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
19386                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
19387                 b_constr.data[u] = b_conv_20_conv;
19388         }
19389         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
19390         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19391         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
19392         return ((uintptr_t)ret_conv);
19393 }
19394
19395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19396         if ((_res & 1) != 0) return;
19397         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19398         CHECK_ACCESS(_res_ptr);
19399         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
19400         FREE((void*)_res);
19401         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
19402 }
19403
19404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19405         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
19406         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19407         if (_res_constr.datalen > 0)
19408                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
19409         else
19410                 _res_constr.data = NULL;
19411         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19412         for (size_t n = 0; n < _res_constr.datalen; n++) {
19413                 int64_t _res_conv_39 = _res_vals[n];
19414                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
19415                 CHECK_ACCESS(_res_conv_39_ptr);
19416                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
19417                 FREE((void*)_res_conv_39);
19418                 _res_constr.data[n] = _res_conv_39_conv;
19419         }
19420         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19421         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
19422 }
19423
19424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19425         LDKCVec_BalanceZ _res_constr;
19426         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19427         if (_res_constr.datalen > 0)
19428                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
19429         else
19430                 _res_constr.data = NULL;
19431         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19432         for (size_t j = 0; j < _res_constr.datalen; j++) {
19433                 int64_t _res_conv_9 = _res_vals[j];
19434                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
19435                 CHECK_ACCESS(_res_conv_9_ptr);
19436                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
19437                 FREE((void*)_res_conv_9);
19438                 _res_constr.data[j] = _res_conv_9_conv;
19439         }
19440         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19441         CVec_BalanceZ_free(_res_constr);
19442 }
19443
19444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19445         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19446         CHECK_ACCESS(o_ptr);
19447         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
19448         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
19449         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19450         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
19451         return (uintptr_t)ret_conv;
19452 }
19453
19454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19455         LDKDecodeError e_conv;
19456         e_conv.inner = (void*)(e & (~1));
19457         e_conv.is_owned = (e & 1) || (e == 0);
19458         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19459         e_conv = DecodeError_clone(&e_conv);
19460         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19461         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
19462         return (uintptr_t)ret_conv;
19463 }
19464
19465 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19466         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
19467         jboolean ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
19468         return ret_val;
19469 }
19470
19471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19472         if ((_res & 1) != 0) return;
19473         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19474         CHECK_ACCESS(_res_ptr);
19475         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
19476         FREE((void*)_res);
19477         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
19478 }
19479
19480 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
19481         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19482         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
19483         return (uintptr_t)ret_conv;
19484 }
19485 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19486         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
19487         intptr_t ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
19488         return ret_val;
19489 }
19490
19491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19492         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
19493         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19494         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
19495         return (uintptr_t)ret_conv;
19496 }
19497
19498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
19499         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19500         *ret_conv = CResult_NoneLightningErrorZ_ok();
19501         return (uintptr_t)ret_conv;
19502 }
19503
19504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19505         LDKLightningError e_conv;
19506         e_conv.inner = (void*)(e & (~1));
19507         e_conv.is_owned = (e & 1) || (e == 0);
19508         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19509         e_conv = LightningError_clone(&e_conv);
19510         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19511         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
19512         return (uintptr_t)ret_conv;
19513 }
19514
19515 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19516         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
19517         jboolean ret_val = CResult_NoneLightningErrorZ_is_ok(o_conv);
19518         return ret_val;
19519 }
19520
19521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19522         if ((_res & 1) != 0) return;
19523         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19524         CHECK_ACCESS(_res_ptr);
19525         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
19526         FREE((void*)_res);
19527         CResult_NoneLightningErrorZ_free(_res_conv);
19528 }
19529
19530 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
19531         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19532         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
19533         return (uintptr_t)ret_conv;
19534 }
19535 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19536         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
19537         intptr_t ret_val = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
19538         return ret_val;
19539 }
19540
19541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19542         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
19543         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19544         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
19545         return (uintptr_t)ret_conv;
19546 }
19547
19548 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
19549         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
19550         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
19551         return ((uintptr_t)ret_conv);
19552 }
19553 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19554         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
19555         intptr_t ret_val = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
19556         return ret_val;
19557 }
19558
19559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19560         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
19561         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
19562         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
19563         return ((uintptr_t)ret_conv);
19564 }
19565
19566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
19567         LDKPublicKey a_ref;
19568         CHECK((*env)->GetArrayLength(env, a) == 33);
19569         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
19570         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
19571         CHECK_ACCESS(b_ptr);
19572         LDKType b_conv = *(LDKType*)(b_ptr);
19573         if (b_conv.free == LDKType_JCalls_free) {
19574                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19575                 LDKType_JCalls_cloned(&b_conv);
19576         }
19577         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
19578         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
19579         return ((uintptr_t)ret_conv);
19580 }
19581
19582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19583         if ((_res & 1) != 0) return;
19584         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19585         CHECK_ACCESS(_res_ptr);
19586         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
19587         FREE((void*)_res);
19588         C2Tuple_PublicKeyTypeZ_free(_res_conv);
19589 }
19590
19591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19592         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
19593         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19594         if (_res_constr.datalen > 0)
19595                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
19596         else
19597                 _res_constr.data = NULL;
19598         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19599         for (size_t z = 0; z < _res_constr.datalen; z++) {
19600                 int64_t _res_conv_25 = _res_vals[z];
19601                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
19602                 CHECK_ACCESS(_res_conv_25_ptr);
19603                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
19604                 FREE((void*)_res_conv_25);
19605                 _res_constr.data[z] = _res_conv_25_conv;
19606         }
19607         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19608         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
19609 }
19610
19611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
19612         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19613         *ret_conv = CResult_boolLightningErrorZ_ok(o);
19614         return (uintptr_t)ret_conv;
19615 }
19616
19617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19618         LDKLightningError e_conv;
19619         e_conv.inner = (void*)(e & (~1));
19620         e_conv.is_owned = (e & 1) || (e == 0);
19621         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19622         e_conv = LightningError_clone(&e_conv);
19623         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19624         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
19625         return (uintptr_t)ret_conv;
19626 }
19627
19628 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19629         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
19630         jboolean ret_val = CResult_boolLightningErrorZ_is_ok(o_conv);
19631         return ret_val;
19632 }
19633
19634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19635         if ((_res & 1) != 0) return;
19636         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19637         CHECK_ACCESS(_res_ptr);
19638         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
19639         FREE((void*)_res);
19640         CResult_boolLightningErrorZ_free(_res_conv);
19641 }
19642
19643 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
19644         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19645         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
19646         return (uintptr_t)ret_conv;
19647 }
19648 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19649         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
19650         intptr_t ret_val = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
19651         return ret_val;
19652 }
19653
19654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19655         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
19656         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19657         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
19658         return (uintptr_t)ret_conv;
19659 }
19660
19661 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
19662         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19663         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
19664         return ((uintptr_t)ret_conv);
19665 }
19666 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19667         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
19668         intptr_t ret_val = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
19669         return ret_val;
19670 }
19671
19672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19673         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
19674         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19675         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
19676         return ((uintptr_t)ret_conv);
19677 }
19678
19679 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) {
19680         LDKChannelAnnouncement a_conv;
19681         a_conv.inner = (void*)(a & (~1));
19682         a_conv.is_owned = (a & 1) || (a == 0);
19683         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19684         a_conv = ChannelAnnouncement_clone(&a_conv);
19685         LDKChannelUpdate b_conv;
19686         b_conv.inner = (void*)(b & (~1));
19687         b_conv.is_owned = (b & 1) || (b == 0);
19688         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19689         b_conv = ChannelUpdate_clone(&b_conv);
19690         LDKChannelUpdate c_conv;
19691         c_conv.inner = (void*)(c & (~1));
19692         c_conv.is_owned = (c & 1) || (c == 0);
19693         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
19694         c_conv = ChannelUpdate_clone(&c_conv);
19695         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19696         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
19697         return ((uintptr_t)ret_conv);
19698 }
19699
19700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19701         if ((_res & 1) != 0) return;
19702         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19703         CHECK_ACCESS(_res_ptr);
19704         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
19705         FREE((void*)_res);
19706         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
19707 }
19708
19709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19710         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
19711         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19712         if (_res_constr.datalen > 0)
19713                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
19714         else
19715                 _res_constr.data = NULL;
19716         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19717         for (size_t h = 0; h < _res_constr.datalen; h++) {
19718                 int64_t _res_conv_59 = _res_vals[h];
19719                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
19720                 CHECK_ACCESS(_res_conv_59_ptr);
19721                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
19722                 FREE((void*)_res_conv_59);
19723                 _res_constr.data[h] = _res_conv_59_conv;
19724         }
19725         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19726         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
19727 }
19728
19729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19730         LDKCVec_NodeAnnouncementZ _res_constr;
19731         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19732         if (_res_constr.datalen > 0)
19733                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
19734         else
19735                 _res_constr.data = NULL;
19736         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19737         for (size_t s = 0; s < _res_constr.datalen; s++) {
19738                 int64_t _res_conv_18 = _res_vals[s];
19739                 LDKNodeAnnouncement _res_conv_18_conv;
19740                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
19741                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
19742                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
19743                 _res_constr.data[s] = _res_conv_18_conv;
19744         }
19745         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19746         CVec_NodeAnnouncementZ_free(_res_constr);
19747 }
19748
19749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19750         LDKCVec_PublicKeyZ _res_constr;
19751         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19752         if (_res_constr.datalen > 0)
19753                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
19754         else
19755                 _res_constr.data = NULL;
19756         for (size_t i = 0; i < _res_constr.datalen; i++) {
19757                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19758                 LDKPublicKey _res_conv_8_ref;
19759                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
19760                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
19761                 _res_constr.data[i] = _res_conv_8_ref;
19762         }
19763         CVec_PublicKeyZ_free(_res_constr);
19764 }
19765
19766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19767         LDKCVec_u8Z o_ref;
19768         o_ref.datalen = (*env)->GetArrayLength(env, o);
19769         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
19770         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
19771         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
19772         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
19773         return (uintptr_t)ret_conv;
19774 }
19775
19776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19777         LDKPeerHandleError e_conv;
19778         e_conv.inner = (void*)(e & (~1));
19779         e_conv.is_owned = (e & 1) || (e == 0);
19780         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19781         e_conv = PeerHandleError_clone(&e_conv);
19782         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
19783         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
19784         return (uintptr_t)ret_conv;
19785 }
19786
19787 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19788         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
19789         jboolean ret_val = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
19790         return ret_val;
19791 }
19792
19793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19794         if ((_res & 1) != 0) return;
19795         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19796         CHECK_ACCESS(_res_ptr);
19797         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
19798         FREE((void*)_res);
19799         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
19800 }
19801
19802 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
19803         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
19804         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
19805         return (uintptr_t)ret_conv;
19806 }
19807 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19808         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
19809         intptr_t ret_val = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
19810         return ret_val;
19811 }
19812
19813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19814         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
19815         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
19816         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
19817         return (uintptr_t)ret_conv;
19818 }
19819
19820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
19821         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
19822         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
19823         return (uintptr_t)ret_conv;
19824 }
19825
19826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19827         LDKPeerHandleError e_conv;
19828         e_conv.inner = (void*)(e & (~1));
19829         e_conv.is_owned = (e & 1) || (e == 0);
19830         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19831         e_conv = PeerHandleError_clone(&e_conv);
19832         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
19833         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
19834         return (uintptr_t)ret_conv;
19835 }
19836
19837 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19838         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
19839         jboolean ret_val = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
19840         return ret_val;
19841 }
19842
19843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19844         if ((_res & 1) != 0) return;
19845         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19846         CHECK_ACCESS(_res_ptr);
19847         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
19848         FREE((void*)_res);
19849         CResult_NonePeerHandleErrorZ_free(_res_conv);
19850 }
19851
19852 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
19853         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
19854         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
19855         return (uintptr_t)ret_conv;
19856 }
19857 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19858         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
19859         intptr_t ret_val = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
19860         return ret_val;
19861 }
19862
19863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19864         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
19865         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
19866         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
19867         return (uintptr_t)ret_conv;
19868 }
19869
19870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
19871         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
19872         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
19873         return (uintptr_t)ret_conv;
19874 }
19875
19876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19877         LDKPeerHandleError e_conv;
19878         e_conv.inner = (void*)(e & (~1));
19879         e_conv.is_owned = (e & 1) || (e == 0);
19880         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19881         e_conv = PeerHandleError_clone(&e_conv);
19882         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
19883         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
19884         return (uintptr_t)ret_conv;
19885 }
19886
19887 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19888         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
19889         jboolean ret_val = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
19890         return ret_val;
19891 }
19892
19893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19894         if ((_res & 1) != 0) return;
19895         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19896         CHECK_ACCESS(_res_ptr);
19897         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
19898         FREE((void*)_res);
19899         CResult_boolPeerHandleErrorZ_free(_res_conv);
19900 }
19901
19902 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
19903         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
19904         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
19905         return (uintptr_t)ret_conv;
19906 }
19907 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19908         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
19909         intptr_t ret_val = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
19910         return ret_val;
19911 }
19912
19913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19914         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
19915         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
19916         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
19917         return (uintptr_t)ret_conv;
19918 }
19919
19920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19921         LDKNodeId o_conv;
19922         o_conv.inner = (void*)(o & (~1));
19923         o_conv.is_owned = (o & 1) || (o == 0);
19924         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19925         o_conv = NodeId_clone(&o_conv);
19926         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19927         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
19928         return (uintptr_t)ret_conv;
19929 }
19930
19931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19932         LDKDecodeError e_conv;
19933         e_conv.inner = (void*)(e & (~1));
19934         e_conv.is_owned = (e & 1) || (e == 0);
19935         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19936         e_conv = DecodeError_clone(&e_conv);
19937         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19938         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
19939         return (uintptr_t)ret_conv;
19940 }
19941
19942 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19943         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
19944         jboolean ret_val = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
19945         return ret_val;
19946 }
19947
19948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19949         if ((_res & 1) != 0) return;
19950         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19951         CHECK_ACCESS(_res_ptr);
19952         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
19953         FREE((void*)_res);
19954         CResult_NodeIdDecodeErrorZ_free(_res_conv);
19955 }
19956
19957 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
19958         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19959         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
19960         return (uintptr_t)ret_conv;
19961 }
19962 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19963         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
19964         intptr_t ret_val = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
19965         return ret_val;
19966 }
19967
19968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19969         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
19970         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19971         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
19972         return (uintptr_t)ret_conv;
19973 }
19974
19975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19976         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19977         CHECK_ACCESS(o_ptr);
19978         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
19979         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
19980         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19981         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
19982         return (uintptr_t)ret_conv;
19983 }
19984
19985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19986         LDKDecodeError e_conv;
19987         e_conv.inner = (void*)(e & (~1));
19988         e_conv.is_owned = (e & 1) || (e == 0);
19989         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19990         e_conv = DecodeError_clone(&e_conv);
19991         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19992         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
19993         return (uintptr_t)ret_conv;
19994 }
19995
19996 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19997         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
19998         jboolean ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
19999         return ret_val;
20000 }
20001
20002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20003         if ((_res & 1) != 0) return;
20004         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20005         CHECK_ACCESS(_res_ptr);
20006         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
20007         FREE((void*)_res);
20008         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
20009 }
20010
20011 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
20012         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20013         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
20014         return (uintptr_t)ret_conv;
20015 }
20016 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20017         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
20018         intptr_t ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
20019         return ret_val;
20020 }
20021
20022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20023         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
20024         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20025         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
20026         return (uintptr_t)ret_conv;
20027 }
20028
20029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20030         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20031         CHECK_ACCESS(o_ptr);
20032         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
20033         if (o_conv.free == LDKAccess_JCalls_free) {
20034                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20035                 LDKAccess_JCalls_cloned(&o_conv);
20036         }
20037         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
20038         *ret_copy = COption_AccessZ_some(o_conv);
20039         uintptr_t ret_ref = (uintptr_t)ret_copy;
20040         return ret_ref;
20041 }
20042
20043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
20044         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
20045         *ret_copy = COption_AccessZ_none();
20046         uintptr_t ret_ref = (uintptr_t)ret_copy;
20047         return ret_ref;
20048 }
20049
20050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20051         if ((_res & 1) != 0) return;
20052         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20053         CHECK_ACCESS(_res_ptr);
20054         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
20055         FREE((void*)_res);
20056         COption_AccessZ_free(_res_conv);
20057 }
20058
20059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20060         LDKChannelUpdateInfo o_conv;
20061         o_conv.inner = (void*)(o & (~1));
20062         o_conv.is_owned = (o & 1) || (o == 0);
20063         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20064         o_conv = ChannelUpdateInfo_clone(&o_conv);
20065         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20066         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
20067         return (uintptr_t)ret_conv;
20068 }
20069
20070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20071         LDKDecodeError e_conv;
20072         e_conv.inner = (void*)(e & (~1));
20073         e_conv.is_owned = (e & 1) || (e == 0);
20074         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20075         e_conv = DecodeError_clone(&e_conv);
20076         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20077         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
20078         return (uintptr_t)ret_conv;
20079 }
20080
20081 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20082         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
20083         jboolean ret_val = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
20084         return ret_val;
20085 }
20086
20087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20088         if ((_res & 1) != 0) return;
20089         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20090         CHECK_ACCESS(_res_ptr);
20091         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
20092         FREE((void*)_res);
20093         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
20094 }
20095
20096 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
20097         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20098         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
20099         return (uintptr_t)ret_conv;
20100 }
20101 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20102         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
20103         intptr_t ret_val = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
20104         return ret_val;
20105 }
20106
20107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20108         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
20109         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20110         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
20111         return (uintptr_t)ret_conv;
20112 }
20113
20114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20115         LDKChannelInfo o_conv;
20116         o_conv.inner = (void*)(o & (~1));
20117         o_conv.is_owned = (o & 1) || (o == 0);
20118         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20119         o_conv = ChannelInfo_clone(&o_conv);
20120         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20121         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
20122         return (uintptr_t)ret_conv;
20123 }
20124
20125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20126         LDKDecodeError e_conv;
20127         e_conv.inner = (void*)(e & (~1));
20128         e_conv.is_owned = (e & 1) || (e == 0);
20129         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20130         e_conv = DecodeError_clone(&e_conv);
20131         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20132         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
20133         return (uintptr_t)ret_conv;
20134 }
20135
20136 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20137         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
20138         jboolean ret_val = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
20139         return ret_val;
20140 }
20141
20142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20143         if ((_res & 1) != 0) return;
20144         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20145         CHECK_ACCESS(_res_ptr);
20146         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
20147         FREE((void*)_res);
20148         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
20149 }
20150
20151 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
20152         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20153         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
20154         return (uintptr_t)ret_conv;
20155 }
20156 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20157         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
20158         intptr_t ret_val = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
20159         return ret_val;
20160 }
20161
20162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20163         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
20164         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20165         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
20166         return (uintptr_t)ret_conv;
20167 }
20168
20169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20170         LDKRoutingFees o_conv;
20171         o_conv.inner = (void*)(o & (~1));
20172         o_conv.is_owned = (o & 1) || (o == 0);
20173         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20174         o_conv = RoutingFees_clone(&o_conv);
20175         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20176         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
20177         return (uintptr_t)ret_conv;
20178 }
20179
20180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20181         LDKDecodeError e_conv;
20182         e_conv.inner = (void*)(e & (~1));
20183         e_conv.is_owned = (e & 1) || (e == 0);
20184         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20185         e_conv = DecodeError_clone(&e_conv);
20186         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20187         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
20188         return (uintptr_t)ret_conv;
20189 }
20190
20191 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20192         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
20193         jboolean ret_val = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
20194         return ret_val;
20195 }
20196
20197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20198         if ((_res & 1) != 0) return;
20199         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20200         CHECK_ACCESS(_res_ptr);
20201         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
20202         FREE((void*)_res);
20203         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
20204 }
20205
20206 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
20207         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20208         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
20209         return (uintptr_t)ret_conv;
20210 }
20211 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20212         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
20213         intptr_t ret_val = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
20214         return ret_val;
20215 }
20216
20217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20218         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
20219         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20220         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
20221         return (uintptr_t)ret_conv;
20222 }
20223
20224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20225         LDKNodeAnnouncementInfo o_conv;
20226         o_conv.inner = (void*)(o & (~1));
20227         o_conv.is_owned = (o & 1) || (o == 0);
20228         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20229         o_conv = NodeAnnouncementInfo_clone(&o_conv);
20230         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20231         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
20232         return (uintptr_t)ret_conv;
20233 }
20234
20235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20236         LDKDecodeError e_conv;
20237         e_conv.inner = (void*)(e & (~1));
20238         e_conv.is_owned = (e & 1) || (e == 0);
20239         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20240         e_conv = DecodeError_clone(&e_conv);
20241         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20242         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
20243         return (uintptr_t)ret_conv;
20244 }
20245
20246 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20247         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
20248         jboolean ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
20249         return ret_val;
20250 }
20251
20252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20253         if ((_res & 1) != 0) return;
20254         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20255         CHECK_ACCESS(_res_ptr);
20256         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
20257         FREE((void*)_res);
20258         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
20259 }
20260
20261 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
20262         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20263         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
20264         return (uintptr_t)ret_conv;
20265 }
20266 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20267         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
20268         intptr_t ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
20269         return ret_val;
20270 }
20271
20272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20273         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
20274         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20275         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
20276         return (uintptr_t)ret_conv;
20277 }
20278
20279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20280         LDKCVec_u64Z _res_constr;
20281         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20282         if (_res_constr.datalen > 0)
20283                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20284         else
20285                 _res_constr.data = NULL;
20286         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20287         for (size_t g = 0; g < _res_constr.datalen; g++) {
20288                 int64_t _res_conv_6 = _res_vals[g];
20289                 _res_constr.data[g] = _res_conv_6;
20290         }
20291         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20292         CVec_u64Z_free(_res_constr);
20293 }
20294
20295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20296         LDKNodeInfo o_conv;
20297         o_conv.inner = (void*)(o & (~1));
20298         o_conv.is_owned = (o & 1) || (o == 0);
20299         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20300         o_conv = NodeInfo_clone(&o_conv);
20301         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20302         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
20303         return (uintptr_t)ret_conv;
20304 }
20305
20306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20307         LDKDecodeError e_conv;
20308         e_conv.inner = (void*)(e & (~1));
20309         e_conv.is_owned = (e & 1) || (e == 0);
20310         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20311         e_conv = DecodeError_clone(&e_conv);
20312         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20313         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
20314         return (uintptr_t)ret_conv;
20315 }
20316
20317 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20318         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
20319         jboolean ret_val = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
20320         return ret_val;
20321 }
20322
20323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20324         if ((_res & 1) != 0) return;
20325         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20326         CHECK_ACCESS(_res_ptr);
20327         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
20328         FREE((void*)_res);
20329         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
20330 }
20331
20332 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
20333         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20334         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
20335         return (uintptr_t)ret_conv;
20336 }
20337 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20338         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
20339         intptr_t ret_val = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
20340         return ret_val;
20341 }
20342
20343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20344         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
20345         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20346         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
20347         return (uintptr_t)ret_conv;
20348 }
20349
20350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20351         LDKNetworkGraph o_conv;
20352         o_conv.inner = (void*)(o & (~1));
20353         o_conv.is_owned = (o & 1) || (o == 0);
20354         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20355         o_conv = NetworkGraph_clone(&o_conv);
20356         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20357         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
20358         return (uintptr_t)ret_conv;
20359 }
20360
20361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20362         LDKDecodeError e_conv;
20363         e_conv.inner = (void*)(e & (~1));
20364         e_conv.is_owned = (e & 1) || (e == 0);
20365         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20366         e_conv = DecodeError_clone(&e_conv);
20367         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20368         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
20369         return (uintptr_t)ret_conv;
20370 }
20371
20372 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20373         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
20374         jboolean ret_val = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
20375         return ret_val;
20376 }
20377
20378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20379         if ((_res & 1) != 0) return;
20380         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20381         CHECK_ACCESS(_res_ptr);
20382         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
20383         FREE((void*)_res);
20384         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
20385 }
20386
20387 static inline uintptr_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
20388         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20389         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
20390         return (uintptr_t)ret_conv;
20391 }
20392 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20393         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
20394         intptr_t ret_val = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
20395         return ret_val;
20396 }
20397
20398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20399         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
20400         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20401         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
20402         return (uintptr_t)ret_conv;
20403 }
20404
20405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
20406         LDKCVec_NetAddressZ o_constr;
20407         o_constr.datalen = (*env)->GetArrayLength(env, o);
20408         if (o_constr.datalen > 0)
20409                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
20410         else
20411                 o_constr.data = NULL;
20412         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
20413         for (size_t m = 0; m < o_constr.datalen; m++) {
20414                 int64_t o_conv_12 = o_vals[m];
20415                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
20416                 CHECK_ACCESS(o_conv_12_ptr);
20417                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
20418                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
20419                 o_constr.data[m] = o_conv_12_conv;
20420         }
20421         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
20422         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20423         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
20424         uintptr_t ret_ref = (uintptr_t)ret_copy;
20425         return ret_ref;
20426 }
20427
20428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
20429         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20430         *ret_copy = COption_CVec_NetAddressZZ_none();
20431         uintptr_t ret_ref = (uintptr_t)ret_copy;
20432         return ret_ref;
20433 }
20434
20435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20436         if ((_res & 1) != 0) return;
20437         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20438         CHECK_ACCESS(_res_ptr);
20439         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
20440         FREE((void*)_res);
20441         COption_CVec_NetAddressZZ_free(_res_conv);
20442 }
20443
20444 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
20445         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20446         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
20447 uintptr_t ret_ref = (uintptr_t)ret_copy;
20448         return ret_ref;
20449 }
20450 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20451         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
20452         intptr_t ret_val = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
20453         return ret_val;
20454 }
20455
20456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20457         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
20458         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20459         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
20460         uintptr_t ret_ref = (uintptr_t)ret_copy;
20461         return ret_ref;
20462 }
20463
20464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20465         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20466         CHECK_ACCESS(o_ptr);
20467         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
20468         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
20469         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20470         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
20471         return (uintptr_t)ret_conv;
20472 }
20473
20474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20475         LDKDecodeError e_conv;
20476         e_conv.inner = (void*)(e & (~1));
20477         e_conv.is_owned = (e & 1) || (e == 0);
20478         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20479         e_conv = DecodeError_clone(&e_conv);
20480         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20481         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
20482         return (uintptr_t)ret_conv;
20483 }
20484
20485 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20486         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
20487         jboolean ret_val = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
20488         return ret_val;
20489 }
20490
20491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20492         if ((_res & 1) != 0) return;
20493         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20494         CHECK_ACCESS(_res_ptr);
20495         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
20496         FREE((void*)_res);
20497         CResult_NetAddressDecodeErrorZ_free(_res_conv);
20498 }
20499
20500 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
20501         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20502         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
20503         return (uintptr_t)ret_conv;
20504 }
20505 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20506         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
20507         intptr_t ret_val = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
20508         return ret_val;
20509 }
20510
20511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20512         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
20513         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
20514         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
20515         return (uintptr_t)ret_conv;
20516 }
20517
20518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20519         LDKCVec_UpdateAddHTLCZ _res_constr;
20520         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20521         if (_res_constr.datalen > 0)
20522                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
20523         else
20524                 _res_constr.data = NULL;
20525         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20526         for (size_t p = 0; p < _res_constr.datalen; p++) {
20527                 int64_t _res_conv_15 = _res_vals[p];
20528                 LDKUpdateAddHTLC _res_conv_15_conv;
20529                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
20530                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
20531                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
20532                 _res_constr.data[p] = _res_conv_15_conv;
20533         }
20534         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20535         CVec_UpdateAddHTLCZ_free(_res_constr);
20536 }
20537
20538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20539         LDKCVec_UpdateFulfillHTLCZ _res_constr;
20540         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20541         if (_res_constr.datalen > 0)
20542                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
20543         else
20544                 _res_constr.data = NULL;
20545         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20546         for (size_t t = 0; t < _res_constr.datalen; t++) {
20547                 int64_t _res_conv_19 = _res_vals[t];
20548                 LDKUpdateFulfillHTLC _res_conv_19_conv;
20549                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
20550                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
20551                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
20552                 _res_constr.data[t] = _res_conv_19_conv;
20553         }
20554         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20555         CVec_UpdateFulfillHTLCZ_free(_res_constr);
20556 }
20557
20558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20559         LDKCVec_UpdateFailHTLCZ _res_constr;
20560         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20561         if (_res_constr.datalen > 0)
20562                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
20563         else
20564                 _res_constr.data = NULL;
20565         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20566         for (size_t q = 0; q < _res_constr.datalen; q++) {
20567                 int64_t _res_conv_16 = _res_vals[q];
20568                 LDKUpdateFailHTLC _res_conv_16_conv;
20569                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
20570                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
20571                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
20572                 _res_constr.data[q] = _res_conv_16_conv;
20573         }
20574         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20575         CVec_UpdateFailHTLCZ_free(_res_constr);
20576 }
20577
20578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20579         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
20580         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20581         if (_res_constr.datalen > 0)
20582                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
20583         else
20584                 _res_constr.data = NULL;
20585         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20586         for (size_t z = 0; z < _res_constr.datalen; z++) {
20587                 int64_t _res_conv_25 = _res_vals[z];
20588                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
20589                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
20590                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
20591                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
20592                 _res_constr.data[z] = _res_conv_25_conv;
20593         }
20594         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20595         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
20596 }
20597
20598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20599         LDKAcceptChannel o_conv;
20600         o_conv.inner = (void*)(o & (~1));
20601         o_conv.is_owned = (o & 1) || (o == 0);
20602         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20603         o_conv = AcceptChannel_clone(&o_conv);
20604         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
20605         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
20606         return (uintptr_t)ret_conv;
20607 }
20608
20609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20610         LDKDecodeError e_conv;
20611         e_conv.inner = (void*)(e & (~1));
20612         e_conv.is_owned = (e & 1) || (e == 0);
20613         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20614         e_conv = DecodeError_clone(&e_conv);
20615         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
20616         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
20617         return (uintptr_t)ret_conv;
20618 }
20619
20620 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20621         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
20622         jboolean ret_val = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
20623         return ret_val;
20624 }
20625
20626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20627         if ((_res & 1) != 0) return;
20628         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20629         CHECK_ACCESS(_res_ptr);
20630         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
20631         FREE((void*)_res);
20632         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
20633 }
20634
20635 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
20636         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
20637         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
20638         return (uintptr_t)ret_conv;
20639 }
20640 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20641         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
20642         intptr_t ret_val = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
20643         return ret_val;
20644 }
20645
20646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20647         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
20648         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
20649         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
20650         return (uintptr_t)ret_conv;
20651 }
20652
20653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20654         LDKAnnouncementSignatures o_conv;
20655         o_conv.inner = (void*)(o & (~1));
20656         o_conv.is_owned = (o & 1) || (o == 0);
20657         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20658         o_conv = AnnouncementSignatures_clone(&o_conv);
20659         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
20660         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
20661         return (uintptr_t)ret_conv;
20662 }
20663
20664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20665         LDKDecodeError e_conv;
20666         e_conv.inner = (void*)(e & (~1));
20667         e_conv.is_owned = (e & 1) || (e == 0);
20668         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20669         e_conv = DecodeError_clone(&e_conv);
20670         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
20671         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
20672         return (uintptr_t)ret_conv;
20673 }
20674
20675 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20676         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
20677         jboolean ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
20678         return ret_val;
20679 }
20680
20681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20682         if ((_res & 1) != 0) return;
20683         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20684         CHECK_ACCESS(_res_ptr);
20685         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
20686         FREE((void*)_res);
20687         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
20688 }
20689
20690 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
20691         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
20692         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
20693         return (uintptr_t)ret_conv;
20694 }
20695 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20696         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
20697         intptr_t ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
20698         return ret_val;
20699 }
20700
20701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20702         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
20703         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
20704         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
20705         return (uintptr_t)ret_conv;
20706 }
20707
20708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20709         LDKChannelReestablish o_conv;
20710         o_conv.inner = (void*)(o & (~1));
20711         o_conv.is_owned = (o & 1) || (o == 0);
20712         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20713         o_conv = ChannelReestablish_clone(&o_conv);
20714         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
20715         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
20716         return (uintptr_t)ret_conv;
20717 }
20718
20719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20720         LDKDecodeError e_conv;
20721         e_conv.inner = (void*)(e & (~1));
20722         e_conv.is_owned = (e & 1) || (e == 0);
20723         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20724         e_conv = DecodeError_clone(&e_conv);
20725         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
20726         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
20727         return (uintptr_t)ret_conv;
20728 }
20729
20730 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20731         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
20732         jboolean ret_val = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
20733         return ret_val;
20734 }
20735
20736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20737         if ((_res & 1) != 0) return;
20738         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20739         CHECK_ACCESS(_res_ptr);
20740         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
20741         FREE((void*)_res);
20742         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
20743 }
20744
20745 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
20746         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
20747         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
20748         return (uintptr_t)ret_conv;
20749 }
20750 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20751         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
20752         intptr_t ret_val = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
20753         return ret_val;
20754 }
20755
20756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20757         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
20758         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
20759         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
20760         return (uintptr_t)ret_conv;
20761 }
20762
20763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20764         LDKClosingSigned o_conv;
20765         o_conv.inner = (void*)(o & (~1));
20766         o_conv.is_owned = (o & 1) || (o == 0);
20767         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20768         o_conv = ClosingSigned_clone(&o_conv);
20769         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
20770         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
20771         return (uintptr_t)ret_conv;
20772 }
20773
20774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20775         LDKDecodeError e_conv;
20776         e_conv.inner = (void*)(e & (~1));
20777         e_conv.is_owned = (e & 1) || (e == 0);
20778         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20779         e_conv = DecodeError_clone(&e_conv);
20780         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
20781         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
20782         return (uintptr_t)ret_conv;
20783 }
20784
20785 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20786         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
20787         jboolean ret_val = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
20788         return ret_val;
20789 }
20790
20791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20792         if ((_res & 1) != 0) return;
20793         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20794         CHECK_ACCESS(_res_ptr);
20795         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
20796         FREE((void*)_res);
20797         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
20798 }
20799
20800 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
20801         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
20802         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
20803         return (uintptr_t)ret_conv;
20804 }
20805 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20806         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
20807         intptr_t ret_val = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
20808         return ret_val;
20809 }
20810
20811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20812         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
20813         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
20814         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
20815         return (uintptr_t)ret_conv;
20816 }
20817
20818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20819         LDKClosingSignedFeeRange o_conv;
20820         o_conv.inner = (void*)(o & (~1));
20821         o_conv.is_owned = (o & 1) || (o == 0);
20822         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20823         o_conv = ClosingSignedFeeRange_clone(&o_conv);
20824         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
20825         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
20826         return (uintptr_t)ret_conv;
20827 }
20828
20829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20830         LDKDecodeError e_conv;
20831         e_conv.inner = (void*)(e & (~1));
20832         e_conv.is_owned = (e & 1) || (e == 0);
20833         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20834         e_conv = DecodeError_clone(&e_conv);
20835         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
20836         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
20837         return (uintptr_t)ret_conv;
20838 }
20839
20840 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20841         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
20842         jboolean ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
20843         return ret_val;
20844 }
20845
20846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20847         if ((_res & 1) != 0) return;
20848         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20849         CHECK_ACCESS(_res_ptr);
20850         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
20851         FREE((void*)_res);
20852         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
20853 }
20854
20855 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
20856         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
20857         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
20858         return (uintptr_t)ret_conv;
20859 }
20860 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20861         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
20862         intptr_t ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
20863         return ret_val;
20864 }
20865
20866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20867         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
20868         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
20869         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
20870         return (uintptr_t)ret_conv;
20871 }
20872
20873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20874         LDKCommitmentSigned o_conv;
20875         o_conv.inner = (void*)(o & (~1));
20876         o_conv.is_owned = (o & 1) || (o == 0);
20877         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20878         o_conv = CommitmentSigned_clone(&o_conv);
20879         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
20880         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
20881         return (uintptr_t)ret_conv;
20882 }
20883
20884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20885         LDKDecodeError e_conv;
20886         e_conv.inner = (void*)(e & (~1));
20887         e_conv.is_owned = (e & 1) || (e == 0);
20888         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20889         e_conv = DecodeError_clone(&e_conv);
20890         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
20891         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
20892         return (uintptr_t)ret_conv;
20893 }
20894
20895 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20896         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
20897         jboolean ret_val = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
20898         return ret_val;
20899 }
20900
20901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20902         if ((_res & 1) != 0) return;
20903         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20904         CHECK_ACCESS(_res_ptr);
20905         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
20906         FREE((void*)_res);
20907         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
20908 }
20909
20910 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
20911         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
20912         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
20913         return (uintptr_t)ret_conv;
20914 }
20915 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20916         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
20917         intptr_t ret_val = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
20918         return ret_val;
20919 }
20920
20921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20922         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
20923         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
20924         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
20925         return (uintptr_t)ret_conv;
20926 }
20927
20928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20929         LDKFundingCreated o_conv;
20930         o_conv.inner = (void*)(o & (~1));
20931         o_conv.is_owned = (o & 1) || (o == 0);
20932         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20933         o_conv = FundingCreated_clone(&o_conv);
20934         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
20935         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
20936         return (uintptr_t)ret_conv;
20937 }
20938
20939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20940         LDKDecodeError e_conv;
20941         e_conv.inner = (void*)(e & (~1));
20942         e_conv.is_owned = (e & 1) || (e == 0);
20943         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20944         e_conv = DecodeError_clone(&e_conv);
20945         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
20946         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
20947         return (uintptr_t)ret_conv;
20948 }
20949
20950 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20951         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
20952         jboolean ret_val = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
20953         return ret_val;
20954 }
20955
20956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20957         if ((_res & 1) != 0) return;
20958         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20959         CHECK_ACCESS(_res_ptr);
20960         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
20961         FREE((void*)_res);
20962         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
20963 }
20964
20965 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
20966         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
20967         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
20968         return (uintptr_t)ret_conv;
20969 }
20970 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20971         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
20972         intptr_t ret_val = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
20973         return ret_val;
20974 }
20975
20976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20977         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
20978         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
20979         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
20980         return (uintptr_t)ret_conv;
20981 }
20982
20983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20984         LDKFundingSigned o_conv;
20985         o_conv.inner = (void*)(o & (~1));
20986         o_conv.is_owned = (o & 1) || (o == 0);
20987         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20988         o_conv = FundingSigned_clone(&o_conv);
20989         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
20990         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
20991         return (uintptr_t)ret_conv;
20992 }
20993
20994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20995         LDKDecodeError e_conv;
20996         e_conv.inner = (void*)(e & (~1));
20997         e_conv.is_owned = (e & 1) || (e == 0);
20998         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20999         e_conv = DecodeError_clone(&e_conv);
21000         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21001         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
21002         return (uintptr_t)ret_conv;
21003 }
21004
21005 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21006         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
21007         jboolean ret_val = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
21008         return ret_val;
21009 }
21010
21011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21012         if ((_res & 1) != 0) return;
21013         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21014         CHECK_ACCESS(_res_ptr);
21015         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
21016         FREE((void*)_res);
21017         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
21018 }
21019
21020 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
21021         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21022         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
21023         return (uintptr_t)ret_conv;
21024 }
21025 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21026         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
21027         intptr_t ret_val = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
21028         return ret_val;
21029 }
21030
21031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21032         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
21033         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21034         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
21035         return (uintptr_t)ret_conv;
21036 }
21037
21038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21039         LDKFundingLocked o_conv;
21040         o_conv.inner = (void*)(o & (~1));
21041         o_conv.is_owned = (o & 1) || (o == 0);
21042         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21043         o_conv = FundingLocked_clone(&o_conv);
21044         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21045         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
21046         return (uintptr_t)ret_conv;
21047 }
21048
21049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21050         LDKDecodeError e_conv;
21051         e_conv.inner = (void*)(e & (~1));
21052         e_conv.is_owned = (e & 1) || (e == 0);
21053         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21054         e_conv = DecodeError_clone(&e_conv);
21055         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21056         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
21057         return (uintptr_t)ret_conv;
21058 }
21059
21060 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21061         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
21062         jboolean ret_val = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
21063         return ret_val;
21064 }
21065
21066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21067         if ((_res & 1) != 0) return;
21068         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21069         CHECK_ACCESS(_res_ptr);
21070         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
21071         FREE((void*)_res);
21072         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
21073 }
21074
21075 static inline uintptr_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
21076         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21077         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
21078         return (uintptr_t)ret_conv;
21079 }
21080 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21081         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
21082         intptr_t ret_val = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
21083         return ret_val;
21084 }
21085
21086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21087         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
21088         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21089         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
21090         return (uintptr_t)ret_conv;
21091 }
21092
21093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21094         LDKInit o_conv;
21095         o_conv.inner = (void*)(o & (~1));
21096         o_conv.is_owned = (o & 1) || (o == 0);
21097         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21098         o_conv = Init_clone(&o_conv);
21099         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21100         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
21101         return (uintptr_t)ret_conv;
21102 }
21103
21104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21105         LDKDecodeError e_conv;
21106         e_conv.inner = (void*)(e & (~1));
21107         e_conv.is_owned = (e & 1) || (e == 0);
21108         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21109         e_conv = DecodeError_clone(&e_conv);
21110         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21111         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
21112         return (uintptr_t)ret_conv;
21113 }
21114
21115 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21116         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
21117         jboolean ret_val = CResult_InitDecodeErrorZ_is_ok(o_conv);
21118         return ret_val;
21119 }
21120
21121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21122         if ((_res & 1) != 0) return;
21123         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21124         CHECK_ACCESS(_res_ptr);
21125         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
21126         FREE((void*)_res);
21127         CResult_InitDecodeErrorZ_free(_res_conv);
21128 }
21129
21130 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
21131         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21132         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
21133         return (uintptr_t)ret_conv;
21134 }
21135 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21136         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
21137         intptr_t ret_val = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
21138         return ret_val;
21139 }
21140
21141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21142         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
21143         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21144         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
21145         return (uintptr_t)ret_conv;
21146 }
21147
21148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21149         LDKOpenChannel o_conv;
21150         o_conv.inner = (void*)(o & (~1));
21151         o_conv.is_owned = (o & 1) || (o == 0);
21152         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21153         o_conv = OpenChannel_clone(&o_conv);
21154         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21155         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
21156         return (uintptr_t)ret_conv;
21157 }
21158
21159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21160         LDKDecodeError e_conv;
21161         e_conv.inner = (void*)(e & (~1));
21162         e_conv.is_owned = (e & 1) || (e == 0);
21163         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21164         e_conv = DecodeError_clone(&e_conv);
21165         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21166         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
21167         return (uintptr_t)ret_conv;
21168 }
21169
21170 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21171         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
21172         jboolean ret_val = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
21173         return ret_val;
21174 }
21175
21176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21177         if ((_res & 1) != 0) return;
21178         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21179         CHECK_ACCESS(_res_ptr);
21180         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
21181         FREE((void*)_res);
21182         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
21183 }
21184
21185 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
21186         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21187         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
21188         return (uintptr_t)ret_conv;
21189 }
21190 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21191         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
21192         intptr_t ret_val = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
21193         return ret_val;
21194 }
21195
21196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21197         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
21198         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21199         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
21200         return (uintptr_t)ret_conv;
21201 }
21202
21203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21204         LDKRevokeAndACK o_conv;
21205         o_conv.inner = (void*)(o & (~1));
21206         o_conv.is_owned = (o & 1) || (o == 0);
21207         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21208         o_conv = RevokeAndACK_clone(&o_conv);
21209         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21210         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
21211         return (uintptr_t)ret_conv;
21212 }
21213
21214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21215         LDKDecodeError e_conv;
21216         e_conv.inner = (void*)(e & (~1));
21217         e_conv.is_owned = (e & 1) || (e == 0);
21218         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21219         e_conv = DecodeError_clone(&e_conv);
21220         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21221         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
21222         return (uintptr_t)ret_conv;
21223 }
21224
21225 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21226         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
21227         jboolean ret_val = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
21228         return ret_val;
21229 }
21230
21231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21232         if ((_res & 1) != 0) return;
21233         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21234         CHECK_ACCESS(_res_ptr);
21235         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
21236         FREE((void*)_res);
21237         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
21238 }
21239
21240 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
21241         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21242         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
21243         return (uintptr_t)ret_conv;
21244 }
21245 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21246         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
21247         intptr_t ret_val = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
21248         return ret_val;
21249 }
21250
21251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21252         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
21253         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21254         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
21255         return (uintptr_t)ret_conv;
21256 }
21257
21258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21259         LDKShutdown o_conv;
21260         o_conv.inner = (void*)(o & (~1));
21261         o_conv.is_owned = (o & 1) || (o == 0);
21262         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21263         o_conv = Shutdown_clone(&o_conv);
21264         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21265         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
21266         return (uintptr_t)ret_conv;
21267 }
21268
21269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21270         LDKDecodeError e_conv;
21271         e_conv.inner = (void*)(e & (~1));
21272         e_conv.is_owned = (e & 1) || (e == 0);
21273         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21274         e_conv = DecodeError_clone(&e_conv);
21275         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21276         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
21277         return (uintptr_t)ret_conv;
21278 }
21279
21280 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21281         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
21282         jboolean ret_val = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
21283         return ret_val;
21284 }
21285
21286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21287         if ((_res & 1) != 0) return;
21288         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21289         CHECK_ACCESS(_res_ptr);
21290         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
21291         FREE((void*)_res);
21292         CResult_ShutdownDecodeErrorZ_free(_res_conv);
21293 }
21294
21295 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
21296         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21297         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
21298         return (uintptr_t)ret_conv;
21299 }
21300 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21301         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
21302         intptr_t ret_val = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
21303         return ret_val;
21304 }
21305
21306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21307         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
21308         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21309         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
21310         return (uintptr_t)ret_conv;
21311 }
21312
21313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21314         LDKUpdateFailHTLC o_conv;
21315         o_conv.inner = (void*)(o & (~1));
21316         o_conv.is_owned = (o & 1) || (o == 0);
21317         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21318         o_conv = UpdateFailHTLC_clone(&o_conv);
21319         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21320         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
21321         return (uintptr_t)ret_conv;
21322 }
21323
21324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21325         LDKDecodeError e_conv;
21326         e_conv.inner = (void*)(e & (~1));
21327         e_conv.is_owned = (e & 1) || (e == 0);
21328         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21329         e_conv = DecodeError_clone(&e_conv);
21330         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21331         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
21332         return (uintptr_t)ret_conv;
21333 }
21334
21335 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21336         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
21337         jboolean ret_val = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
21338         return ret_val;
21339 }
21340
21341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21342         if ((_res & 1) != 0) return;
21343         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21344         CHECK_ACCESS(_res_ptr);
21345         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
21346         FREE((void*)_res);
21347         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
21348 }
21349
21350 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
21351         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21352         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
21353         return (uintptr_t)ret_conv;
21354 }
21355 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21356         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
21357         intptr_t ret_val = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
21358         return ret_val;
21359 }
21360
21361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21362         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
21363         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21364         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
21365         return (uintptr_t)ret_conv;
21366 }
21367
21368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21369         LDKUpdateFailMalformedHTLC o_conv;
21370         o_conv.inner = (void*)(o & (~1));
21371         o_conv.is_owned = (o & 1) || (o == 0);
21372         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21373         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
21374         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21375         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
21376         return (uintptr_t)ret_conv;
21377 }
21378
21379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21380         LDKDecodeError e_conv;
21381         e_conv.inner = (void*)(e & (~1));
21382         e_conv.is_owned = (e & 1) || (e == 0);
21383         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21384         e_conv = DecodeError_clone(&e_conv);
21385         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21386         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
21387         return (uintptr_t)ret_conv;
21388 }
21389
21390 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21391         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
21392         jboolean ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
21393         return ret_val;
21394 }
21395
21396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21397         if ((_res & 1) != 0) return;
21398         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21399         CHECK_ACCESS(_res_ptr);
21400         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
21401         FREE((void*)_res);
21402         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
21403 }
21404
21405 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
21406         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21407         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
21408         return (uintptr_t)ret_conv;
21409 }
21410 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21411         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
21412         intptr_t ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
21413         return ret_val;
21414 }
21415
21416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21417         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
21418         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21419         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
21420         return (uintptr_t)ret_conv;
21421 }
21422
21423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21424         LDKUpdateFee o_conv;
21425         o_conv.inner = (void*)(o & (~1));
21426         o_conv.is_owned = (o & 1) || (o == 0);
21427         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21428         o_conv = UpdateFee_clone(&o_conv);
21429         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21430         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
21431         return (uintptr_t)ret_conv;
21432 }
21433
21434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21435         LDKDecodeError e_conv;
21436         e_conv.inner = (void*)(e & (~1));
21437         e_conv.is_owned = (e & 1) || (e == 0);
21438         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21439         e_conv = DecodeError_clone(&e_conv);
21440         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21441         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
21442         return (uintptr_t)ret_conv;
21443 }
21444
21445 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21446         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
21447         jboolean ret_val = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
21448         return ret_val;
21449 }
21450
21451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21452         if ((_res & 1) != 0) return;
21453         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21454         CHECK_ACCESS(_res_ptr);
21455         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
21456         FREE((void*)_res);
21457         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
21458 }
21459
21460 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
21461         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21462         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
21463         return (uintptr_t)ret_conv;
21464 }
21465 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21466         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
21467         intptr_t ret_val = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
21468         return ret_val;
21469 }
21470
21471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21472         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
21473         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21474         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
21475         return (uintptr_t)ret_conv;
21476 }
21477
21478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21479         LDKUpdateFulfillHTLC o_conv;
21480         o_conv.inner = (void*)(o & (~1));
21481         o_conv.is_owned = (o & 1) || (o == 0);
21482         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21483         o_conv = UpdateFulfillHTLC_clone(&o_conv);
21484         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21485         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
21486         return (uintptr_t)ret_conv;
21487 }
21488
21489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21490         LDKDecodeError e_conv;
21491         e_conv.inner = (void*)(e & (~1));
21492         e_conv.is_owned = (e & 1) || (e == 0);
21493         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21494         e_conv = DecodeError_clone(&e_conv);
21495         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21496         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
21497         return (uintptr_t)ret_conv;
21498 }
21499
21500 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21501         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
21502         jboolean ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
21503         return ret_val;
21504 }
21505
21506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21507         if ((_res & 1) != 0) return;
21508         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21509         CHECK_ACCESS(_res_ptr);
21510         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
21511         FREE((void*)_res);
21512         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
21513 }
21514
21515 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
21516         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21517         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
21518         return (uintptr_t)ret_conv;
21519 }
21520 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21521         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
21522         intptr_t ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
21523         return ret_val;
21524 }
21525
21526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21527         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
21528         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21529         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
21530         return (uintptr_t)ret_conv;
21531 }
21532
21533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21534         LDKUpdateAddHTLC o_conv;
21535         o_conv.inner = (void*)(o & (~1));
21536         o_conv.is_owned = (o & 1) || (o == 0);
21537         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21538         o_conv = UpdateAddHTLC_clone(&o_conv);
21539         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
21540         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
21541         return (uintptr_t)ret_conv;
21542 }
21543
21544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21545         LDKDecodeError e_conv;
21546         e_conv.inner = (void*)(e & (~1));
21547         e_conv.is_owned = (e & 1) || (e == 0);
21548         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21549         e_conv = DecodeError_clone(&e_conv);
21550         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
21551         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
21552         return (uintptr_t)ret_conv;
21553 }
21554
21555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21556         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
21557         jboolean ret_val = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
21558         return ret_val;
21559 }
21560
21561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21562         if ((_res & 1) != 0) return;
21563         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21564         CHECK_ACCESS(_res_ptr);
21565         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
21566         FREE((void*)_res);
21567         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
21568 }
21569
21570 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
21571         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
21572         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
21573         return (uintptr_t)ret_conv;
21574 }
21575 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21576         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
21577         intptr_t ret_val = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
21578         return ret_val;
21579 }
21580
21581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21582         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
21583         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
21584         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
21585         return (uintptr_t)ret_conv;
21586 }
21587
21588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21589         LDKPing o_conv;
21590         o_conv.inner = (void*)(o & (~1));
21591         o_conv.is_owned = (o & 1) || (o == 0);
21592         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21593         o_conv = Ping_clone(&o_conv);
21594         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
21595         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
21596         return (uintptr_t)ret_conv;
21597 }
21598
21599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21600         LDKDecodeError e_conv;
21601         e_conv.inner = (void*)(e & (~1));
21602         e_conv.is_owned = (e & 1) || (e == 0);
21603         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21604         e_conv = DecodeError_clone(&e_conv);
21605         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
21606         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
21607         return (uintptr_t)ret_conv;
21608 }
21609
21610 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21611         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
21612         jboolean ret_val = CResult_PingDecodeErrorZ_is_ok(o_conv);
21613         return ret_val;
21614 }
21615
21616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21617         if ((_res & 1) != 0) return;
21618         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21619         CHECK_ACCESS(_res_ptr);
21620         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
21621         FREE((void*)_res);
21622         CResult_PingDecodeErrorZ_free(_res_conv);
21623 }
21624
21625 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
21626         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
21627         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
21628         return (uintptr_t)ret_conv;
21629 }
21630 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21631         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
21632         intptr_t ret_val = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
21633         return ret_val;
21634 }
21635
21636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21637         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
21638         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
21639         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
21640         return (uintptr_t)ret_conv;
21641 }
21642
21643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21644         LDKPong o_conv;
21645         o_conv.inner = (void*)(o & (~1));
21646         o_conv.is_owned = (o & 1) || (o == 0);
21647         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21648         o_conv = Pong_clone(&o_conv);
21649         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
21650         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
21651         return (uintptr_t)ret_conv;
21652 }
21653
21654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21655         LDKDecodeError e_conv;
21656         e_conv.inner = (void*)(e & (~1));
21657         e_conv.is_owned = (e & 1) || (e == 0);
21658         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21659         e_conv = DecodeError_clone(&e_conv);
21660         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
21661         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
21662         return (uintptr_t)ret_conv;
21663 }
21664
21665 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21666         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
21667         jboolean ret_val = CResult_PongDecodeErrorZ_is_ok(o_conv);
21668         return ret_val;
21669 }
21670
21671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21672         if ((_res & 1) != 0) return;
21673         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21674         CHECK_ACCESS(_res_ptr);
21675         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
21676         FREE((void*)_res);
21677         CResult_PongDecodeErrorZ_free(_res_conv);
21678 }
21679
21680 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
21681         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
21682         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
21683         return (uintptr_t)ret_conv;
21684 }
21685 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21686         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
21687         intptr_t ret_val = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
21688         return ret_val;
21689 }
21690
21691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21692         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
21693         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
21694         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
21695         return (uintptr_t)ret_conv;
21696 }
21697
21698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21699         LDKUnsignedChannelAnnouncement o_conv;
21700         o_conv.inner = (void*)(o & (~1));
21701         o_conv.is_owned = (o & 1) || (o == 0);
21702         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21703         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
21704         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
21705         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
21706         return (uintptr_t)ret_conv;
21707 }
21708
21709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21710         LDKDecodeError e_conv;
21711         e_conv.inner = (void*)(e & (~1));
21712         e_conv.is_owned = (e & 1) || (e == 0);
21713         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21714         e_conv = DecodeError_clone(&e_conv);
21715         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
21716         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
21717         return (uintptr_t)ret_conv;
21718 }
21719
21720 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21721         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
21722         jboolean ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
21723         return ret_val;
21724 }
21725
21726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21727         if ((_res & 1) != 0) return;
21728         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21729         CHECK_ACCESS(_res_ptr);
21730         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
21731         FREE((void*)_res);
21732         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
21733 }
21734
21735 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
21736         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
21737         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
21738         return (uintptr_t)ret_conv;
21739 }
21740 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21741         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
21742         intptr_t ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
21743         return ret_val;
21744 }
21745
21746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21747         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
21748         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
21749         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
21750         return (uintptr_t)ret_conv;
21751 }
21752
21753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21754         LDKChannelAnnouncement o_conv;
21755         o_conv.inner = (void*)(o & (~1));
21756         o_conv.is_owned = (o & 1) || (o == 0);
21757         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21758         o_conv = ChannelAnnouncement_clone(&o_conv);
21759         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
21760         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
21761         return (uintptr_t)ret_conv;
21762 }
21763
21764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21765         LDKDecodeError e_conv;
21766         e_conv.inner = (void*)(e & (~1));
21767         e_conv.is_owned = (e & 1) || (e == 0);
21768         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21769         e_conv = DecodeError_clone(&e_conv);
21770         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
21771         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
21772         return (uintptr_t)ret_conv;
21773 }
21774
21775 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21776         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
21777         jboolean ret_val = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
21778         return ret_val;
21779 }
21780
21781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_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         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
21786         FREE((void*)_res);
21787         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
21788 }
21789
21790 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
21791         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
21792         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
21793         return (uintptr_t)ret_conv;
21794 }
21795 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21796         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
21797         intptr_t ret_val = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
21798         return ret_val;
21799 }
21800
21801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21802         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
21803         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
21804         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
21805         return (uintptr_t)ret_conv;
21806 }
21807
21808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21809         LDKUnsignedChannelUpdate o_conv;
21810         o_conv.inner = (void*)(o & (~1));
21811         o_conv.is_owned = (o & 1) || (o == 0);
21812         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21813         o_conv = UnsignedChannelUpdate_clone(&o_conv);
21814         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
21815         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
21816         return (uintptr_t)ret_conv;
21817 }
21818
21819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21820         LDKDecodeError e_conv;
21821         e_conv.inner = (void*)(e & (~1));
21822         e_conv.is_owned = (e & 1) || (e == 0);
21823         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21824         e_conv = DecodeError_clone(&e_conv);
21825         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
21826         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
21827         return (uintptr_t)ret_conv;
21828 }
21829
21830 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21831         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
21832         jboolean ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
21833         return ret_val;
21834 }
21835
21836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21837         if ((_res & 1) != 0) return;
21838         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21839         CHECK_ACCESS(_res_ptr);
21840         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
21841         FREE((void*)_res);
21842         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
21843 }
21844
21845 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
21846         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
21847         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
21848         return (uintptr_t)ret_conv;
21849 }
21850 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21851         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
21852         intptr_t ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
21853         return ret_val;
21854 }
21855
21856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21857         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
21858         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
21859         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
21860         return (uintptr_t)ret_conv;
21861 }
21862
21863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21864         LDKChannelUpdate o_conv;
21865         o_conv.inner = (void*)(o & (~1));
21866         o_conv.is_owned = (o & 1) || (o == 0);
21867         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21868         o_conv = ChannelUpdate_clone(&o_conv);
21869         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
21870         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
21871         return (uintptr_t)ret_conv;
21872 }
21873
21874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21875         LDKDecodeError e_conv;
21876         e_conv.inner = (void*)(e & (~1));
21877         e_conv.is_owned = (e & 1) || (e == 0);
21878         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21879         e_conv = DecodeError_clone(&e_conv);
21880         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
21881         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
21882         return (uintptr_t)ret_conv;
21883 }
21884
21885 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21886         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
21887         jboolean ret_val = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
21888         return ret_val;
21889 }
21890
21891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21892         if ((_res & 1) != 0) return;
21893         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21894         CHECK_ACCESS(_res_ptr);
21895         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
21896         FREE((void*)_res);
21897         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
21898 }
21899
21900 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
21901         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
21902         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
21903         return (uintptr_t)ret_conv;
21904 }
21905 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21906         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
21907         intptr_t ret_val = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
21908         return ret_val;
21909 }
21910
21911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21912         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
21913         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
21914         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
21915         return (uintptr_t)ret_conv;
21916 }
21917
21918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21919         LDKErrorMessage o_conv;
21920         o_conv.inner = (void*)(o & (~1));
21921         o_conv.is_owned = (o & 1) || (o == 0);
21922         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21923         o_conv = ErrorMessage_clone(&o_conv);
21924         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
21925         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
21926         return (uintptr_t)ret_conv;
21927 }
21928
21929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21930         LDKDecodeError e_conv;
21931         e_conv.inner = (void*)(e & (~1));
21932         e_conv.is_owned = (e & 1) || (e == 0);
21933         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21934         e_conv = DecodeError_clone(&e_conv);
21935         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
21936         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
21937         return (uintptr_t)ret_conv;
21938 }
21939
21940 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21941         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
21942         jboolean ret_val = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
21943         return ret_val;
21944 }
21945
21946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21947         if ((_res & 1) != 0) return;
21948         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21949         CHECK_ACCESS(_res_ptr);
21950         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
21951         FREE((void*)_res);
21952         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
21953 }
21954
21955 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
21956         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
21957         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
21958         return (uintptr_t)ret_conv;
21959 }
21960 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21961         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
21962         intptr_t ret_val = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
21963         return ret_val;
21964 }
21965
21966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21967         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
21968         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
21969         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
21970         return (uintptr_t)ret_conv;
21971 }
21972
21973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21974         LDKWarningMessage o_conv;
21975         o_conv.inner = (void*)(o & (~1));
21976         o_conv.is_owned = (o & 1) || (o == 0);
21977         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21978         o_conv = WarningMessage_clone(&o_conv);
21979         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
21980         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
21981         return (uintptr_t)ret_conv;
21982 }
21983
21984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21985         LDKDecodeError e_conv;
21986         e_conv.inner = (void*)(e & (~1));
21987         e_conv.is_owned = (e & 1) || (e == 0);
21988         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21989         e_conv = DecodeError_clone(&e_conv);
21990         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
21991         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
21992         return (uintptr_t)ret_conv;
21993 }
21994
21995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21996         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
21997         jboolean ret_val = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
21998         return ret_val;
21999 }
22000
22001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22002         if ((_res & 1) != 0) return;
22003         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22004         CHECK_ACCESS(_res_ptr);
22005         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
22006         FREE((void*)_res);
22007         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
22008 }
22009
22010 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
22011         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22012         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
22013         return (uintptr_t)ret_conv;
22014 }
22015 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22016         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
22017         intptr_t ret_val = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
22018         return ret_val;
22019 }
22020
22021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22022         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
22023         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22024         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
22025         return (uintptr_t)ret_conv;
22026 }
22027
22028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22029         LDKUnsignedNodeAnnouncement o_conv;
22030         o_conv.inner = (void*)(o & (~1));
22031         o_conv.is_owned = (o & 1) || (o == 0);
22032         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22033         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
22034         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22035         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
22036         return (uintptr_t)ret_conv;
22037 }
22038
22039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22040         LDKDecodeError e_conv;
22041         e_conv.inner = (void*)(e & (~1));
22042         e_conv.is_owned = (e & 1) || (e == 0);
22043         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22044         e_conv = DecodeError_clone(&e_conv);
22045         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22046         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
22047         return (uintptr_t)ret_conv;
22048 }
22049
22050 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22051         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
22052         jboolean ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
22053         return ret_val;
22054 }
22055
22056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22057         if ((_res & 1) != 0) return;
22058         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22059         CHECK_ACCESS(_res_ptr);
22060         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
22061         FREE((void*)_res);
22062         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
22063 }
22064
22065 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22066         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22067         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
22068         return (uintptr_t)ret_conv;
22069 }
22070 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22071         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
22072         intptr_t ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22073         return ret_val;
22074 }
22075
22076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22077         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
22078         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22079         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
22080         return (uintptr_t)ret_conv;
22081 }
22082
22083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22084         LDKNodeAnnouncement o_conv;
22085         o_conv.inner = (void*)(o & (~1));
22086         o_conv.is_owned = (o & 1) || (o == 0);
22087         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22088         o_conv = NodeAnnouncement_clone(&o_conv);
22089         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22090         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
22091         return (uintptr_t)ret_conv;
22092 }
22093
22094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22095         LDKDecodeError e_conv;
22096         e_conv.inner = (void*)(e & (~1));
22097         e_conv.is_owned = (e & 1) || (e == 0);
22098         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22099         e_conv = DecodeError_clone(&e_conv);
22100         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22101         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
22102         return (uintptr_t)ret_conv;
22103 }
22104
22105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22106         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
22107         jboolean ret_val = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
22108         return ret_val;
22109 }
22110
22111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22112         if ((_res & 1) != 0) return;
22113         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22114         CHECK_ACCESS(_res_ptr);
22115         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
22116         FREE((void*)_res);
22117         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
22118 }
22119
22120 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22121         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22122         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
22123         return (uintptr_t)ret_conv;
22124 }
22125 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22126         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
22127         intptr_t ret_val = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22128         return ret_val;
22129 }
22130
22131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22132         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
22133         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22134         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
22135         return (uintptr_t)ret_conv;
22136 }
22137
22138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22139         LDKQueryShortChannelIds o_conv;
22140         o_conv.inner = (void*)(o & (~1));
22141         o_conv.is_owned = (o & 1) || (o == 0);
22142         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22143         o_conv = QueryShortChannelIds_clone(&o_conv);
22144         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22145         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
22146         return (uintptr_t)ret_conv;
22147 }
22148
22149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22150         LDKDecodeError e_conv;
22151         e_conv.inner = (void*)(e & (~1));
22152         e_conv.is_owned = (e & 1) || (e == 0);
22153         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22154         e_conv = DecodeError_clone(&e_conv);
22155         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22156         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
22157         return (uintptr_t)ret_conv;
22158 }
22159
22160 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22161         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
22162         jboolean ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
22163         return ret_val;
22164 }
22165
22166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22167         if ((_res & 1) != 0) return;
22168         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22169         CHECK_ACCESS(_res_ptr);
22170         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
22171         FREE((void*)_res);
22172         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
22173 }
22174
22175 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
22176         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22177         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
22178         return (uintptr_t)ret_conv;
22179 }
22180 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22181         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
22182         intptr_t ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
22183         return ret_val;
22184 }
22185
22186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22187         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
22188         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22189         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
22190         return (uintptr_t)ret_conv;
22191 }
22192
22193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22194         LDKReplyShortChannelIdsEnd o_conv;
22195         o_conv.inner = (void*)(o & (~1));
22196         o_conv.is_owned = (o & 1) || (o == 0);
22197         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22198         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
22199         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22200         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
22201         return (uintptr_t)ret_conv;
22202 }
22203
22204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22205         LDKDecodeError e_conv;
22206         e_conv.inner = (void*)(e & (~1));
22207         e_conv.is_owned = (e & 1) || (e == 0);
22208         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22209         e_conv = DecodeError_clone(&e_conv);
22210         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22211         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
22212         return (uintptr_t)ret_conv;
22213 }
22214
22215 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22216         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
22217         jboolean ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
22218         return ret_val;
22219 }
22220
22221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22222         if ((_res & 1) != 0) return;
22223         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22224         CHECK_ACCESS(_res_ptr);
22225         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
22226         FREE((void*)_res);
22227         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
22228 }
22229
22230 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
22231         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22232         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
22233         return (uintptr_t)ret_conv;
22234 }
22235 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22236         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
22237         intptr_t ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
22238         return ret_val;
22239 }
22240
22241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22242         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
22243         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22244         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
22245         return (uintptr_t)ret_conv;
22246 }
22247
22248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22249         LDKQueryChannelRange o_conv;
22250         o_conv.inner = (void*)(o & (~1));
22251         o_conv.is_owned = (o & 1) || (o == 0);
22252         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22253         o_conv = QueryChannelRange_clone(&o_conv);
22254         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22255         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
22256         return (uintptr_t)ret_conv;
22257 }
22258
22259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22260         LDKDecodeError e_conv;
22261         e_conv.inner = (void*)(e & (~1));
22262         e_conv.is_owned = (e & 1) || (e == 0);
22263         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22264         e_conv = DecodeError_clone(&e_conv);
22265         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22266         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
22267         return (uintptr_t)ret_conv;
22268 }
22269
22270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22271         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
22272         jboolean ret_val = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
22273         return ret_val;
22274 }
22275
22276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22277         if ((_res & 1) != 0) return;
22278         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22279         CHECK_ACCESS(_res_ptr);
22280         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
22281         FREE((void*)_res);
22282         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
22283 }
22284
22285 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
22286         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22287         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
22288         return (uintptr_t)ret_conv;
22289 }
22290 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22291         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
22292         intptr_t ret_val = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
22293         return ret_val;
22294 }
22295
22296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22297         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
22298         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22299         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
22300         return (uintptr_t)ret_conv;
22301 }
22302
22303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22304         LDKReplyChannelRange o_conv;
22305         o_conv.inner = (void*)(o & (~1));
22306         o_conv.is_owned = (o & 1) || (o == 0);
22307         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22308         o_conv = ReplyChannelRange_clone(&o_conv);
22309         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22310         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
22311         return (uintptr_t)ret_conv;
22312 }
22313
22314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22315         LDKDecodeError e_conv;
22316         e_conv.inner = (void*)(e & (~1));
22317         e_conv.is_owned = (e & 1) || (e == 0);
22318         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22319         e_conv = DecodeError_clone(&e_conv);
22320         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22321         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
22322         return (uintptr_t)ret_conv;
22323 }
22324
22325 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22326         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
22327         jboolean ret_val = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
22328         return ret_val;
22329 }
22330
22331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22332         if ((_res & 1) != 0) return;
22333         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22334         CHECK_ACCESS(_res_ptr);
22335         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
22336         FREE((void*)_res);
22337         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
22338 }
22339
22340 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
22341         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22342         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
22343         return (uintptr_t)ret_conv;
22344 }
22345 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22346         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
22347         intptr_t ret_val = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
22348         return ret_val;
22349 }
22350
22351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22352         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
22353         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22354         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
22355         return (uintptr_t)ret_conv;
22356 }
22357
22358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22359         LDKGossipTimestampFilter o_conv;
22360         o_conv.inner = (void*)(o & (~1));
22361         o_conv.is_owned = (o & 1) || (o == 0);
22362         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22363         o_conv = GossipTimestampFilter_clone(&o_conv);
22364         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22365         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
22366         return (uintptr_t)ret_conv;
22367 }
22368
22369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22370         LDKDecodeError e_conv;
22371         e_conv.inner = (void*)(e & (~1));
22372         e_conv.is_owned = (e & 1) || (e == 0);
22373         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22374         e_conv = DecodeError_clone(&e_conv);
22375         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22376         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
22377         return (uintptr_t)ret_conv;
22378 }
22379
22380 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22381         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
22382         jboolean ret_val = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
22383         return ret_val;
22384 }
22385
22386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22387         if ((_res & 1) != 0) return;
22388         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22389         CHECK_ACCESS(_res_ptr);
22390         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
22391         FREE((void*)_res);
22392         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
22393 }
22394
22395 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
22396         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22397         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
22398         return (uintptr_t)ret_conv;
22399 }
22400 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22401         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
22402         intptr_t ret_val = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
22403         return ret_val;
22404 }
22405
22406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22407         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
22408         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22409         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
22410         return (uintptr_t)ret_conv;
22411 }
22412
22413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22414         LDKCVec_PhantomRouteHintsZ _res_constr;
22415         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22416         if (_res_constr.datalen > 0)
22417                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
22418         else
22419                 _res_constr.data = NULL;
22420         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22421         for (size_t t = 0; t < _res_constr.datalen; t++) {
22422                 int64_t _res_conv_19 = _res_vals[t];
22423                 LDKPhantomRouteHints _res_conv_19_conv;
22424                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
22425                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
22426                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
22427                 _res_constr.data[t] = _res_conv_19_conv;
22428         }
22429         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22430         CVec_PhantomRouteHintsZ_free(_res_constr);
22431 }
22432
22433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22434         LDKInvoice o_conv;
22435         o_conv.inner = (void*)(o & (~1));
22436         o_conv.is_owned = (o & 1) || (o == 0);
22437         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22438         o_conv = Invoice_clone(&o_conv);
22439         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22440         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
22441         return (uintptr_t)ret_conv;
22442 }
22443
22444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22445         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
22446         CHECK_ACCESS(e_ptr);
22447         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
22448         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
22449         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22450         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
22451         return (uintptr_t)ret_conv;
22452 }
22453
22454 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22455         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
22456         jboolean ret_val = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
22457         return ret_val;
22458 }
22459
22460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22461         if ((_res & 1) != 0) return;
22462         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22463         CHECK_ACCESS(_res_ptr);
22464         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
22465         FREE((void*)_res);
22466         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
22467 }
22468
22469 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
22470         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22471         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
22472         return (uintptr_t)ret_conv;
22473 }
22474 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22475         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
22476         intptr_t ret_val = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
22477         return ret_val;
22478 }
22479
22480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22481         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
22482         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22483         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
22484         return (uintptr_t)ret_conv;
22485 }
22486
22487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22488         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
22489         CHECK_ACCESS(o_ptr);
22490         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
22491         if (o_conv.free == LDKFilter_JCalls_free) {
22492                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22493                 LDKFilter_JCalls_cloned(&o_conv);
22494         }
22495         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
22496         *ret_copy = COption_FilterZ_some(o_conv);
22497         uintptr_t ret_ref = (uintptr_t)ret_copy;
22498         return ret_ref;
22499 }
22500
22501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
22502         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
22503         *ret_copy = COption_FilterZ_none();
22504         uintptr_t ret_ref = (uintptr_t)ret_copy;
22505         return ret_ref;
22506 }
22507
22508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22509         if ((_res & 1) != 0) return;
22510         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22511         CHECK_ACCESS(_res_ptr);
22512         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
22513         FREE((void*)_res);
22514         COption_FilterZ_free(_res_conv);
22515 }
22516
22517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22518         LDKLockedChannelMonitor o_conv;
22519         o_conv.inner = (void*)(o & (~1));
22520         o_conv.is_owned = (o & 1) || (o == 0);
22521         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22522         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
22523         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
22524         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
22525         return (uintptr_t)ret_conv;
22526 }
22527
22528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
22529         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
22530         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
22531         return (uintptr_t)ret_conv;
22532 }
22533
22534 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22535         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
22536         jboolean ret_val = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
22537         return ret_val;
22538 }
22539
22540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22541         if ((_res & 1) != 0) return;
22542         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22543         CHECK_ACCESS(_res_ptr);
22544         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
22545         FREE((void*)_res);
22546         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
22547 }
22548
22549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22550         LDKCVec_OutPointZ _res_constr;
22551         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22552         if (_res_constr.datalen > 0)
22553                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
22554         else
22555                 _res_constr.data = NULL;
22556         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22557         for (size_t k = 0; k < _res_constr.datalen; k++) {
22558                 int64_t _res_conv_10 = _res_vals[k];
22559                 LDKOutPoint _res_conv_10_conv;
22560                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
22561                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
22562                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
22563                 _res_constr.data[k] = _res_conv_10_conv;
22564         }
22565         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22566         CVec_OutPointZ_free(_res_constr);
22567 }
22568
22569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22570         if ((this_ptr & 1) != 0) return;
22571         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22572         CHECK_ACCESS(this_ptr_ptr);
22573         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
22574         FREE((void*)this_ptr);
22575         PaymentPurpose_free(this_ptr_conv);
22576 }
22577
22578 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
22579         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
22580         *ret_copy = PaymentPurpose_clone(arg);
22581 uintptr_t ret_ref = (uintptr_t)ret_copy;
22582         return ret_ref;
22583 }
22584 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22585         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
22586         intptr_t ret_val = PaymentPurpose_clone_ptr(arg_conv);
22587         return ret_val;
22588 }
22589
22590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22591         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
22592         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
22593         *ret_copy = PaymentPurpose_clone(orig_conv);
22594         uintptr_t ret_ref = (uintptr_t)ret_copy;
22595         return ret_ref;
22596 }
22597
22598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
22599         LDKThirtyTwoBytes payment_preimage_ref;
22600         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
22601         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
22602         LDKThirtyTwoBytes payment_secret_ref;
22603         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
22604         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
22605         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
22606         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
22607         uintptr_t ret_ref = (uintptr_t)ret_copy;
22608         return ret_ref;
22609 }
22610
22611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
22612         LDKThirtyTwoBytes a_ref;
22613         CHECK((*env)->GetArrayLength(env, a) == 32);
22614         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22615         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
22616         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
22617         uintptr_t ret_ref = (uintptr_t)ret_copy;
22618         return ret_ref;
22619 }
22620
22621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22622         if ((this_ptr & 1) != 0) return;
22623         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22624         CHECK_ACCESS(this_ptr_ptr);
22625         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
22626         FREE((void*)this_ptr);
22627         ClosureReason_free(this_ptr_conv);
22628 }
22629
22630 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
22631         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22632         *ret_copy = ClosureReason_clone(arg);
22633 uintptr_t ret_ref = (uintptr_t)ret_copy;
22634         return ret_ref;
22635 }
22636 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22637         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
22638         intptr_t ret_val = ClosureReason_clone_ptr(arg_conv);
22639         return ret_val;
22640 }
22641
22642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22643         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
22644         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22645         *ret_copy = ClosureReason_clone(orig_conv);
22646         uintptr_t ret_ref = (uintptr_t)ret_copy;
22647         return ret_ref;
22648 }
22649
22650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
22651         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
22652         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22653         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
22654         uintptr_t ret_ref = (uintptr_t)ret_copy;
22655         return ret_ref;
22656 }
22657
22658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
22659         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22660         *ret_copy = ClosureReason_holder_force_closed();
22661         uintptr_t ret_ref = (uintptr_t)ret_copy;
22662         return ret_ref;
22663 }
22664
22665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
22666         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22667         *ret_copy = ClosureReason_cooperative_closure();
22668         uintptr_t ret_ref = (uintptr_t)ret_copy;
22669         return ret_ref;
22670 }
22671
22672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
22673         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22674         *ret_copy = ClosureReason_commitment_tx_confirmed();
22675         uintptr_t ret_ref = (uintptr_t)ret_copy;
22676         return ret_ref;
22677 }
22678
22679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
22680         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22681         *ret_copy = ClosureReason_funding_timed_out();
22682         uintptr_t ret_ref = (uintptr_t)ret_copy;
22683         return ret_ref;
22684 }
22685
22686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
22687         LDKStr err_conv = java_to_owned_str(env, err);
22688         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22689         *ret_copy = ClosureReason_processing_error(err_conv);
22690         uintptr_t ret_ref = (uintptr_t)ret_copy;
22691         return ret_ref;
22692 }
22693
22694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
22695         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22696         *ret_copy = ClosureReason_disconnected_peer();
22697         uintptr_t ret_ref = (uintptr_t)ret_copy;
22698         return ret_ref;
22699 }
22700
22701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
22702         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
22703         *ret_copy = ClosureReason_outdated_channel_manager();
22704         uintptr_t ret_ref = (uintptr_t)ret_copy;
22705         return ret_ref;
22706 }
22707
22708 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
22709         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
22710         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
22711         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22712         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22713         CVec_u8Z_free(ret_var);
22714         return ret_arr;
22715 }
22716
22717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22718         LDKu8slice ser_ref;
22719         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22720         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22721         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
22722         *ret_conv = ClosureReason_read(ser_ref);
22723         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22724         return (uintptr_t)ret_conv;
22725 }
22726
22727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22728         if ((this_ptr & 1) != 0) return;
22729         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22730         CHECK_ACCESS(this_ptr_ptr);
22731         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
22732         FREE((void*)this_ptr);
22733         Event_free(this_ptr_conv);
22734 }
22735
22736 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
22737         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22738         *ret_copy = Event_clone(arg);
22739 uintptr_t ret_ref = (uintptr_t)ret_copy;
22740         return ret_ref;
22741 }
22742 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22743         LDKEvent* arg_conv = (LDKEvent*)arg;
22744         intptr_t ret_val = Event_clone_ptr(arg_conv);
22745         return ret_val;
22746 }
22747
22748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22749         LDKEvent* orig_conv = (LDKEvent*)orig;
22750         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22751         *ret_copy = Event_clone(orig_conv);
22752         uintptr_t ret_ref = (uintptr_t)ret_copy;
22753         return ret_ref;
22754 }
22755
22756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1funding_1generation_1ready(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
22757         LDKThirtyTwoBytes temporary_channel_id_ref;
22758         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
22759         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
22760         LDKCVec_u8Z output_script_ref;
22761         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
22762         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
22763         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
22764         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22765         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
22766         uintptr_t ret_ref = (uintptr_t)ret_copy;
22767         return ret_ref;
22768 }
22769
22770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amt, int64_t purpose) {
22771         LDKThirtyTwoBytes payment_hash_ref;
22772         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
22773         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
22774         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
22775         CHECK_ACCESS(purpose_ptr);
22776         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
22777         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
22778         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22779         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
22780         uintptr_t ret_ref = (uintptr_t)ret_copy;
22781         return ret_ref;
22782 }
22783
22784 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) {
22785         LDKThirtyTwoBytes payment_id_ref;
22786         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
22787         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
22788         LDKThirtyTwoBytes payment_preimage_ref;
22789         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
22790         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
22791         LDKThirtyTwoBytes payment_hash_ref;
22792         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
22793         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
22794         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
22795         CHECK_ACCESS(fee_paid_msat_ptr);
22796         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
22797         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
22798         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22799         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
22800         uintptr_t ret_ref = (uintptr_t)ret_copy;
22801         return ret_ref;
22802 }
22803
22804 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) {
22805         LDKThirtyTwoBytes payment_id_ref;
22806         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
22807         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
22808         LDKThirtyTwoBytes payment_hash_ref;
22809         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
22810         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
22811         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
22812         CHECK_ACCESS(network_update_ptr);
22813         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
22814         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
22815         LDKCVec_RouteHopZ path_constr;
22816         path_constr.datalen = (*env)->GetArrayLength(env, path);
22817         if (path_constr.datalen > 0)
22818                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
22819         else
22820                 path_constr.data = NULL;
22821         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
22822         for (size_t k = 0; k < path_constr.datalen; k++) {
22823                 int64_t path_conv_10 = path_vals[k];
22824                 LDKRouteHop path_conv_10_conv;
22825                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
22826                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
22827                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
22828                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
22829                 path_constr.data[k] = path_conv_10_conv;
22830         }
22831         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
22832         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
22833         CHECK_ACCESS(short_channel_id_ptr);
22834         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
22835         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
22836         LDKRouteParameters retry_conv;
22837         retry_conv.inner = (void*)(retry & (~1));
22838         retry_conv.is_owned = (retry & 1) || (retry == 0);
22839         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
22840         retry_conv = RouteParameters_clone(&retry_conv);
22841         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22842         *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);
22843         uintptr_t ret_ref = (uintptr_t)ret_copy;
22844         return ret_ref;
22845 }
22846
22847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
22848         LDKThirtyTwoBytes payment_id_ref;
22849         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
22850         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
22851         LDKThirtyTwoBytes payment_hash_ref;
22852         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
22853         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
22854         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22855         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
22856         uintptr_t ret_ref = (uintptr_t)ret_copy;
22857         return ret_ref;
22858 }
22859
22860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
22861         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22862         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
22863         uintptr_t ret_ref = (uintptr_t)ret_copy;
22864         return ret_ref;
22865 }
22866
22867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
22868         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
22869         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
22870         if (outputs_constr.datalen > 0)
22871                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
22872         else
22873                 outputs_constr.data = NULL;
22874         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
22875         for (size_t b = 0; b < outputs_constr.datalen; b++) {
22876                 int64_t outputs_conv_27 = outputs_vals[b];
22877                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
22878                 CHECK_ACCESS(outputs_conv_27_ptr);
22879                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
22880                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
22881                 outputs_constr.data[b] = outputs_conv_27_conv;
22882         }
22883         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
22884         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22885         *ret_copy = Event_spendable_outputs(outputs_constr);
22886         uintptr_t ret_ref = (uintptr_t)ret_copy;
22887         return ret_ref;
22888 }
22889
22890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) {
22891         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
22892         CHECK_ACCESS(fee_earned_msat_ptr);
22893         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
22894         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
22895         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22896         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
22897         uintptr_t ret_ref = (uintptr_t)ret_copy;
22898         return ret_ref;
22899 }
22900
22901 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) {
22902         LDKThirtyTwoBytes channel_id_ref;
22903         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
22904         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
22905         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
22906         CHECK_ACCESS(reason_ptr);
22907         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
22908         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
22909         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22910         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
22911         uintptr_t ret_ref = (uintptr_t)ret_copy;
22912         return ret_ref;
22913 }
22914
22915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
22916         LDKThirtyTwoBytes channel_id_ref;
22917         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
22918         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
22919         LDKTransaction transaction_ref;
22920         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
22921         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
22922         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
22923         transaction_ref.data_is_owned = true;
22924         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22925         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
22926         uintptr_t ret_ref = (uintptr_t)ret_copy;
22927         return ret_ref;
22928 }
22929
22930 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) {
22931         LDKThirtyTwoBytes payment_id_ref;
22932         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
22933         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
22934         LDKThirtyTwoBytes payment_hash_ref;
22935         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
22936         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
22937         LDKCVec_RouteHopZ path_constr;
22938         path_constr.datalen = (*env)->GetArrayLength(env, path);
22939         if (path_constr.datalen > 0)
22940                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
22941         else
22942                 path_constr.data = NULL;
22943         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
22944         for (size_t k = 0; k < path_constr.datalen; k++) {
22945                 int64_t path_conv_10 = path_vals[k];
22946                 LDKRouteHop path_conv_10_conv;
22947                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
22948                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
22949                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
22950                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
22951                 path_constr.data[k] = path_conv_10_conv;
22952         }
22953         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
22954         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22955         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
22956         uintptr_t ret_ref = (uintptr_t)ret_copy;
22957         return ret_ref;
22958 }
22959
22960 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) {
22961         LDKThirtyTwoBytes temporary_channel_id_ref;
22962         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
22963         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
22964         LDKPublicKey counterparty_node_id_ref;
22965         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
22966         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
22967         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22968         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat);
22969         uintptr_t ret_ref = (uintptr_t)ret_copy;
22970         return ret_ref;
22971 }
22972
22973 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
22974         LDKEvent* obj_conv = (LDKEvent*)obj;
22975         LDKCVec_u8Z ret_var = Event_write(obj_conv);
22976         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22977         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22978         CVec_u8Z_free(ret_var);
22979         return ret_arr;
22980 }
22981
22982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22983         LDKu8slice ser_ref;
22984         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22985         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22986         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
22987         *ret_conv = Event_read(ser_ref);
22988         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22989         return (uintptr_t)ret_conv;
22990 }
22991
22992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22993         if ((this_ptr & 1) != 0) return;
22994         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22995         CHECK_ACCESS(this_ptr_ptr);
22996         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
22997         FREE((void*)this_ptr);
22998         MessageSendEvent_free(this_ptr_conv);
22999 }
23000
23001 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
23002         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23003         *ret_copy = MessageSendEvent_clone(arg);
23004 uintptr_t ret_ref = (uintptr_t)ret_copy;
23005         return ret_ref;
23006 }
23007 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23008         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
23009         intptr_t ret_val = MessageSendEvent_clone_ptr(arg_conv);
23010         return ret_val;
23011 }
23012
23013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23014         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
23015         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23016         *ret_copy = MessageSendEvent_clone(orig_conv);
23017         uintptr_t ret_ref = (uintptr_t)ret_copy;
23018         return ret_ref;
23019 }
23020
23021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23022         LDKPublicKey node_id_ref;
23023         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23024         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23025         LDKAcceptChannel msg_conv;
23026         msg_conv.inner = (void*)(msg & (~1));
23027         msg_conv.is_owned = (msg & 1) || (msg == 0);
23028         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23029         msg_conv = AcceptChannel_clone(&msg_conv);
23030         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23031         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
23032         uintptr_t ret_ref = (uintptr_t)ret_copy;
23033         return ret_ref;
23034 }
23035
23036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23037         LDKPublicKey node_id_ref;
23038         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23039         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23040         LDKOpenChannel msg_conv;
23041         msg_conv.inner = (void*)(msg & (~1));
23042         msg_conv.is_owned = (msg & 1) || (msg == 0);
23043         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23044         msg_conv = OpenChannel_clone(&msg_conv);
23045         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23046         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
23047         uintptr_t ret_ref = (uintptr_t)ret_copy;
23048         return ret_ref;
23049 }
23050
23051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23052         LDKPublicKey node_id_ref;
23053         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23054         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23055         LDKFundingCreated msg_conv;
23056         msg_conv.inner = (void*)(msg & (~1));
23057         msg_conv.is_owned = (msg & 1) || (msg == 0);
23058         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23059         msg_conv = FundingCreated_clone(&msg_conv);
23060         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23061         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
23062         uintptr_t ret_ref = (uintptr_t)ret_copy;
23063         return ret_ref;
23064 }
23065
23066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23067         LDKPublicKey node_id_ref;
23068         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23069         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23070         LDKFundingSigned msg_conv;
23071         msg_conv.inner = (void*)(msg & (~1));
23072         msg_conv.is_owned = (msg & 1) || (msg == 0);
23073         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23074         msg_conv = FundingSigned_clone(&msg_conv);
23075         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23076         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
23077         uintptr_t ret_ref = (uintptr_t)ret_copy;
23078         return ret_ref;
23079 }
23080
23081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1locked(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23082         LDKPublicKey node_id_ref;
23083         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23084         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23085         LDKFundingLocked msg_conv;
23086         msg_conv.inner = (void*)(msg & (~1));
23087         msg_conv.is_owned = (msg & 1) || (msg == 0);
23088         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23089         msg_conv = FundingLocked_clone(&msg_conv);
23090         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23091         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
23092         uintptr_t ret_ref = (uintptr_t)ret_copy;
23093         return ret_ref;
23094 }
23095
23096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23097         LDKPublicKey node_id_ref;
23098         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23099         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23100         LDKAnnouncementSignatures msg_conv;
23101         msg_conv.inner = (void*)(msg & (~1));
23102         msg_conv.is_owned = (msg & 1) || (msg == 0);
23103         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23104         msg_conv = AnnouncementSignatures_clone(&msg_conv);
23105         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23106         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
23107         uintptr_t ret_ref = (uintptr_t)ret_copy;
23108         return ret_ref;
23109 }
23110
23111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
23112         LDKPublicKey node_id_ref;
23113         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23114         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23115         LDKCommitmentUpdate updates_conv;
23116         updates_conv.inner = (void*)(updates & (~1));
23117         updates_conv.is_owned = (updates & 1) || (updates == 0);
23118         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
23119         updates_conv = CommitmentUpdate_clone(&updates_conv);
23120         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23121         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
23122         uintptr_t ret_ref = (uintptr_t)ret_copy;
23123         return ret_ref;
23124 }
23125
23126 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) {
23127         LDKPublicKey node_id_ref;
23128         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23129         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23130         LDKRevokeAndACK msg_conv;
23131         msg_conv.inner = (void*)(msg & (~1));
23132         msg_conv.is_owned = (msg & 1) || (msg == 0);
23133         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23134         msg_conv = RevokeAndACK_clone(&msg_conv);
23135         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23136         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
23137         uintptr_t ret_ref = (uintptr_t)ret_copy;
23138         return ret_ref;
23139 }
23140
23141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23142         LDKPublicKey node_id_ref;
23143         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23144         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23145         LDKClosingSigned msg_conv;
23146         msg_conv.inner = (void*)(msg & (~1));
23147         msg_conv.is_owned = (msg & 1) || (msg == 0);
23148         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23149         msg_conv = ClosingSigned_clone(&msg_conv);
23150         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23151         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
23152         uintptr_t ret_ref = (uintptr_t)ret_copy;
23153         return ret_ref;
23154 }
23155
23156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23157         LDKPublicKey node_id_ref;
23158         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23159         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23160         LDKShutdown msg_conv;
23161         msg_conv.inner = (void*)(msg & (~1));
23162         msg_conv.is_owned = (msg & 1) || (msg == 0);
23163         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23164         msg_conv = Shutdown_clone(&msg_conv);
23165         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23166         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
23167         uintptr_t ret_ref = (uintptr_t)ret_copy;
23168         return ret_ref;
23169 }
23170
23171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23172         LDKPublicKey node_id_ref;
23173         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23174         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23175         LDKChannelReestablish msg_conv;
23176         msg_conv.inner = (void*)(msg & (~1));
23177         msg_conv.is_owned = (msg & 1) || (msg == 0);
23178         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23179         msg_conv = ChannelReestablish_clone(&msg_conv);
23180         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23181         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
23182         uintptr_t ret_ref = (uintptr_t)ret_copy;
23183         return ret_ref;
23184 }
23185
23186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
23187         LDKChannelAnnouncement msg_conv;
23188         msg_conv.inner = (void*)(msg & (~1));
23189         msg_conv.is_owned = (msg & 1) || (msg == 0);
23190         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23191         msg_conv = ChannelAnnouncement_clone(&msg_conv);
23192         LDKChannelUpdate update_msg_conv;
23193         update_msg_conv.inner = (void*)(update_msg & (~1));
23194         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
23195         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
23196         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
23197         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23198         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
23199         uintptr_t ret_ref = (uintptr_t)ret_copy;
23200         return ret_ref;
23201 }
23202
23203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
23204         LDKNodeAnnouncement msg_conv;
23205         msg_conv.inner = (void*)(msg & (~1));
23206         msg_conv.is_owned = (msg & 1) || (msg == 0);
23207         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23208         msg_conv = NodeAnnouncement_clone(&msg_conv);
23209         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23210         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
23211         uintptr_t ret_ref = (uintptr_t)ret_copy;
23212         return ret_ref;
23213 }
23214
23215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
23216         LDKChannelUpdate msg_conv;
23217         msg_conv.inner = (void*)(msg & (~1));
23218         msg_conv.is_owned = (msg & 1) || (msg == 0);
23219         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23220         msg_conv = ChannelUpdate_clone(&msg_conv);
23221         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23222         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
23223         uintptr_t ret_ref = (uintptr_t)ret_copy;
23224         return ret_ref;
23225 }
23226
23227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23228         LDKPublicKey node_id_ref;
23229         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23230         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23231         LDKChannelUpdate msg_conv;
23232         msg_conv.inner = (void*)(msg & (~1));
23233         msg_conv.is_owned = (msg & 1) || (msg == 0);
23234         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23235         msg_conv = ChannelUpdate_clone(&msg_conv);
23236         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23237         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
23238         uintptr_t ret_ref = (uintptr_t)ret_copy;
23239         return ret_ref;
23240 }
23241
23242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
23243         LDKPublicKey node_id_ref;
23244         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23245         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23246         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
23247         CHECK_ACCESS(action_ptr);
23248         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
23249         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
23250         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23251         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
23252         uintptr_t ret_ref = (uintptr_t)ret_copy;
23253         return ret_ref;
23254 }
23255
23256 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) {
23257         LDKPublicKey node_id_ref;
23258         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23259         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23260         LDKQueryChannelRange msg_conv;
23261         msg_conv.inner = (void*)(msg & (~1));
23262         msg_conv.is_owned = (msg & 1) || (msg == 0);
23263         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23264         msg_conv = QueryChannelRange_clone(&msg_conv);
23265         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23266         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
23267         uintptr_t ret_ref = (uintptr_t)ret_copy;
23268         return ret_ref;
23269 }
23270
23271 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) {
23272         LDKPublicKey node_id_ref;
23273         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23274         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23275         LDKQueryShortChannelIds msg_conv;
23276         msg_conv.inner = (void*)(msg & (~1));
23277         msg_conv.is_owned = (msg & 1) || (msg == 0);
23278         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23279         msg_conv = QueryShortChannelIds_clone(&msg_conv);
23280         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23281         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
23282         uintptr_t ret_ref = (uintptr_t)ret_copy;
23283         return ret_ref;
23284 }
23285
23286 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) {
23287         LDKPublicKey node_id_ref;
23288         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23289         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23290         LDKReplyChannelRange msg_conv;
23291         msg_conv.inner = (void*)(msg & (~1));
23292         msg_conv.is_owned = (msg & 1) || (msg == 0);
23293         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23294         msg_conv = ReplyChannelRange_clone(&msg_conv);
23295         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23296         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
23297         uintptr_t ret_ref = (uintptr_t)ret_copy;
23298         return ret_ref;
23299 }
23300
23301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23302         if ((this_ptr & 1) != 0) return;
23303         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23304         CHECK_ACCESS(this_ptr_ptr);
23305         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
23306         FREE((void*)this_ptr);
23307         MessageSendEventsProvider_free(this_ptr_conv);
23308 }
23309
23310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23311         if ((this_ptr & 1) != 0) return;
23312         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23313         CHECK_ACCESS(this_ptr_ptr);
23314         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
23315         FREE((void*)this_ptr);
23316         EventsProvider_free(this_ptr_conv);
23317 }
23318
23319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23320         if ((this_ptr & 1) != 0) return;
23321         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23322         CHECK_ACCESS(this_ptr_ptr);
23323         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
23324         FREE((void*)this_ptr);
23325         EventHandler_free(this_ptr_conv);
23326 }
23327
23328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23329         if ((this_ptr & 1) != 0) return;
23330         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23331         CHECK_ACCESS(this_ptr_ptr);
23332         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
23333         FREE((void*)this_ptr);
23334         APIError_free(this_ptr_conv);
23335 }
23336
23337 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
23338         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23339         *ret_copy = APIError_clone(arg);
23340 uintptr_t ret_ref = (uintptr_t)ret_copy;
23341         return ret_ref;
23342 }
23343 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23344         LDKAPIError* arg_conv = (LDKAPIError*)arg;
23345         intptr_t ret_val = APIError_clone_ptr(arg_conv);
23346         return ret_val;
23347 }
23348
23349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23350         LDKAPIError* orig_conv = (LDKAPIError*)orig;
23351         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23352         *ret_copy = APIError_clone(orig_conv);
23353         uintptr_t ret_ref = (uintptr_t)ret_copy;
23354         return ret_ref;
23355 }
23356
23357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
23358         LDKStr err_conv = java_to_owned_str(env, err);
23359         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23360         *ret_copy = APIError_apimisuse_error(err_conv);
23361         uintptr_t ret_ref = (uintptr_t)ret_copy;
23362         return ret_ref;
23363 }
23364
23365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
23366         LDKStr err_conv = java_to_owned_str(env, err);
23367         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23368         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
23369         uintptr_t ret_ref = (uintptr_t)ret_copy;
23370         return ret_ref;
23371 }
23372
23373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
23374         LDKStr err_conv = java_to_owned_str(env, err);
23375         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23376         *ret_copy = APIError_route_error(err_conv);
23377         uintptr_t ret_ref = (uintptr_t)ret_copy;
23378         return ret_ref;
23379 }
23380
23381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
23382         LDKStr err_conv = java_to_owned_str(env, err);
23383         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23384         *ret_copy = APIError_channel_unavailable(err_conv);
23385         uintptr_t ret_ref = (uintptr_t)ret_copy;
23386         return ret_ref;
23387 }
23388
23389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
23390         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23391         *ret_copy = APIError_monitor_update_failed();
23392         uintptr_t ret_ref = (uintptr_t)ret_copy;
23393         return ret_ref;
23394 }
23395
23396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
23397         LDKShutdownScript script_conv;
23398         script_conv.inner = (void*)(script & (~1));
23399         script_conv.is_owned = (script & 1) || (script == 0);
23400         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
23401         script_conv = ShutdownScript_clone(&script_conv);
23402         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23403         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
23404         uintptr_t ret_ref = (uintptr_t)ret_copy;
23405         return ret_ref;
23406 }
23407
23408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
23409         LDKu8slice msg_ref;
23410         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
23411         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
23412         unsigned char sk_arr[32];
23413         CHECK((*env)->GetArrayLength(env, sk) == 32);
23414         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
23415         unsigned char (*sk_ref)[32] = &sk_arr;
23416         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
23417         *ret_conv = sign(msg_ref, sk_ref);
23418         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
23419         return (uintptr_t)ret_conv;
23420 }
23421
23422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
23423         LDKu8slice msg_ref;
23424         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
23425         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
23426         LDKStr sig_conv = java_to_owned_str(env, sig);
23427         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
23428         *ret_conv = recover_pk(msg_ref, sig_conv);
23429         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
23430         return (uintptr_t)ret_conv;
23431 }
23432
23433 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
23434         LDKu8slice msg_ref;
23435         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
23436         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
23437         LDKStr sig_conv = java_to_owned_str(env, sig);
23438         LDKPublicKey pk_ref;
23439         CHECK((*env)->GetArrayLength(env, pk) == 33);
23440         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
23441         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
23442         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
23443         return ret_val;
23444 }
23445
23446 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
23447         LDKu8slice hrp_bytes_ref;
23448         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
23449         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
23450         LDKCVec_u5Z data_without_signature_constr;
23451         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
23452         if (data_without_signature_constr.datalen > 0)
23453                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
23454         else
23455                 data_without_signature_constr.data = NULL;
23456         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
23457         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
23458                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
23459                 
23460                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
23461         }
23462         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
23463         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
23464         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23465         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23466         CVec_u8Z_free(ret_var);
23467         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
23468         return ret_arr;
23469 }
23470
23471 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23472         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
23473         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
23474         return ret_conv;
23475 }
23476
23477 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
23478         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
23479         return ret_conv;
23480 }
23481
23482 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
23483         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
23484         return ret_conv;
23485 }
23486
23487 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
23488         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
23489         return ret_conv;
23490 }
23491
23492 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
23493         jclass ret_conv = LDKLevel_to_java(env, Level_info());
23494         return ret_conv;
23495 }
23496
23497 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
23498         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
23499         return ret_conv;
23500 }
23501
23502 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
23503         jclass ret_conv = LDKLevel_to_java(env, Level_error());
23504         return ret_conv;
23505 }
23506
23507 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23508         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
23509         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
23510         jboolean ret_val = Level_eq(a_conv, b_conv);
23511         return ret_val;
23512 }
23513
23514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
23515         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
23516         int64_t ret_val = Level_hash(o_conv);
23517         return ret_val;
23518 }
23519
23520 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
23521         jclass ret_conv = LDKLevel_to_java(env, Level_max());
23522         return ret_conv;
23523 }
23524
23525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23526         LDKRecord this_obj_conv;
23527         this_obj_conv.inner = (void*)(this_obj & (~1));
23528         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23530         Record_free(this_obj_conv);
23531 }
23532
23533 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
23534         LDKRecord this_ptr_conv;
23535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23536         this_ptr_conv.is_owned = false;
23537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23538         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
23539         return ret_conv;
23540 }
23541
23542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
23543         LDKRecord this_ptr_conv;
23544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23545         this_ptr_conv.is_owned = false;
23546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23547         LDKLevel val_conv = LDKLevel_from_java(env, val);
23548         Record_set_level(&this_ptr_conv, val_conv);
23549 }
23550
23551 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
23552         LDKRecord this_ptr_conv;
23553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23554         this_ptr_conv.is_owned = false;
23555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23556         LDKStr ret_str = Record_get_args(&this_ptr_conv);
23557         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
23558         Str_free(ret_str);
23559         return ret_conv;
23560 }
23561
23562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
23563         LDKRecord this_ptr_conv;
23564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23565         this_ptr_conv.is_owned = false;
23566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23567         LDKStr val_conv = java_to_owned_str(env, val);
23568         Record_set_args(&this_ptr_conv, val_conv);
23569 }
23570
23571 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
23572         LDKRecord this_ptr_conv;
23573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23574         this_ptr_conv.is_owned = false;
23575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23576         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
23577         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
23578         Str_free(ret_str);
23579         return ret_conv;
23580 }
23581
23582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
23583         LDKRecord this_ptr_conv;
23584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23585         this_ptr_conv.is_owned = false;
23586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23587         LDKStr val_conv = java_to_owned_str(env, val);
23588         Record_set_module_path(&this_ptr_conv, val_conv);
23589 }
23590
23591 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
23592         LDKRecord this_ptr_conv;
23593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23594         this_ptr_conv.is_owned = false;
23595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23596         LDKStr ret_str = Record_get_file(&this_ptr_conv);
23597         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
23598         Str_free(ret_str);
23599         return ret_conv;
23600 }
23601
23602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
23603         LDKRecord this_ptr_conv;
23604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23605         this_ptr_conv.is_owned = false;
23606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23607         LDKStr val_conv = java_to_owned_str(env, val);
23608         Record_set_file(&this_ptr_conv, val_conv);
23609 }
23610
23611 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
23612         LDKRecord this_ptr_conv;
23613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23614         this_ptr_conv.is_owned = false;
23615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23616         int32_t ret_val = Record_get_line(&this_ptr_conv);
23617         return ret_val;
23618 }
23619
23620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23621         LDKRecord this_ptr_conv;
23622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23623         this_ptr_conv.is_owned = false;
23624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23625         Record_set_line(&this_ptr_conv, val);
23626 }
23627
23628 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
23629         LDKRecord ret_var = Record_clone(arg);
23630 uintptr_t ret_ref = 0;
23631 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23632 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23633 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23634 ret_ref = (uintptr_t)ret_var.inner;
23635 if (ret_var.is_owned) {
23636         ret_ref |= 1;
23637 }
23638         return ret_ref;
23639 }
23640 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23641         LDKRecord arg_conv;
23642         arg_conv.inner = (void*)(arg & (~1));
23643         arg_conv.is_owned = false;
23644         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23645         intptr_t ret_val = Record_clone_ptr(&arg_conv);
23646         return ret_val;
23647 }
23648
23649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23650         LDKRecord orig_conv;
23651         orig_conv.inner = (void*)(orig & (~1));
23652         orig_conv.is_owned = false;
23653         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23654         LDKRecord ret_var = Record_clone(&orig_conv);
23655         uintptr_t ret_ref = 0;
23656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23659         ret_ref = (uintptr_t)ret_var.inner;
23660         if (ret_var.is_owned) {
23661                 ret_ref |= 1;
23662         }
23663         return ret_ref;
23664 }
23665
23666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23667         if ((this_ptr & 1) != 0) return;
23668         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23669         CHECK_ACCESS(this_ptr_ptr);
23670         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
23671         FREE((void*)this_ptr);
23672         Logger_free(this_ptr_conv);
23673 }
23674
23675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23676         LDKChannelHandshakeConfig this_obj_conv;
23677         this_obj_conv.inner = (void*)(this_obj & (~1));
23678         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23680         ChannelHandshakeConfig_free(this_obj_conv);
23681 }
23682
23683 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
23684         LDKChannelHandshakeConfig this_ptr_conv;
23685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23686         this_ptr_conv.is_owned = false;
23687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23688         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
23689         return ret_val;
23690 }
23691
23692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23693         LDKChannelHandshakeConfig this_ptr_conv;
23694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23695         this_ptr_conv.is_owned = false;
23696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23697         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
23698 }
23699
23700 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
23701         LDKChannelHandshakeConfig this_ptr_conv;
23702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23703         this_ptr_conv.is_owned = false;
23704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23705         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
23706         return ret_val;
23707 }
23708
23709 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) {
23710         LDKChannelHandshakeConfig this_ptr_conv;
23711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23712         this_ptr_conv.is_owned = false;
23713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23714         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
23715 }
23716
23717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23718         LDKChannelHandshakeConfig this_ptr_conv;
23719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23720         this_ptr_conv.is_owned = false;
23721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23722         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
23723         return ret_val;
23724 }
23725
23726 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) {
23727         LDKChannelHandshakeConfig this_ptr_conv;
23728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23729         this_ptr_conv.is_owned = false;
23730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23731         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
23732 }
23733
23734 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) {
23735         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
23736         uintptr_t ret_ref = 0;
23737         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23738         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23740         ret_ref = (uintptr_t)ret_var.inner;
23741         if (ret_var.is_owned) {
23742                 ret_ref |= 1;
23743         }
23744         return ret_ref;
23745 }
23746
23747 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
23748         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
23749 uintptr_t ret_ref = 0;
23750 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23751 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23752 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23753 ret_ref = (uintptr_t)ret_var.inner;
23754 if (ret_var.is_owned) {
23755         ret_ref |= 1;
23756 }
23757         return ret_ref;
23758 }
23759 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23760         LDKChannelHandshakeConfig arg_conv;
23761         arg_conv.inner = (void*)(arg & (~1));
23762         arg_conv.is_owned = false;
23763         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23764         intptr_t ret_val = ChannelHandshakeConfig_clone_ptr(&arg_conv);
23765         return ret_val;
23766 }
23767
23768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23769         LDKChannelHandshakeConfig orig_conv;
23770         orig_conv.inner = (void*)(orig & (~1));
23771         orig_conv.is_owned = false;
23772         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23773         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
23774         uintptr_t ret_ref = 0;
23775         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23776         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23778         ret_ref = (uintptr_t)ret_var.inner;
23779         if (ret_var.is_owned) {
23780                 ret_ref |= 1;
23781         }
23782         return ret_ref;
23783 }
23784
23785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
23786         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
23787         uintptr_t ret_ref = 0;
23788         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23789         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23791         ret_ref = (uintptr_t)ret_var.inner;
23792         if (ret_var.is_owned) {
23793                 ret_ref |= 1;
23794         }
23795         return ret_ref;
23796 }
23797
23798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23799         LDKChannelHandshakeLimits this_obj_conv;
23800         this_obj_conv.inner = (void*)(this_obj & (~1));
23801         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23803         ChannelHandshakeLimits_free(this_obj_conv);
23804 }
23805
23806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
23807         LDKChannelHandshakeLimits this_ptr_conv;
23808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23809         this_ptr_conv.is_owned = false;
23810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23811         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
23812         return ret_val;
23813 }
23814
23815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23816         LDKChannelHandshakeLimits this_ptr_conv;
23817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23818         this_ptr_conv.is_owned = false;
23819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23820         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
23821 }
23822
23823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23824         LDKChannelHandshakeLimits this_ptr_conv;
23825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23826         this_ptr_conv.is_owned = false;
23827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23828         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
23829         return ret_val;
23830 }
23831
23832 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) {
23833         LDKChannelHandshakeLimits this_ptr_conv;
23834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23835         this_ptr_conv.is_owned = false;
23836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23837         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
23838 }
23839
23840 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) {
23841         LDKChannelHandshakeLimits this_ptr_conv;
23842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23843         this_ptr_conv.is_owned = false;
23844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23845         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
23846         return ret_val;
23847 }
23848
23849 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) {
23850         LDKChannelHandshakeLimits this_ptr_conv;
23851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23852         this_ptr_conv.is_owned = false;
23853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23854         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
23855 }
23856
23857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
23858         LDKChannelHandshakeLimits this_ptr_conv;
23859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23860         this_ptr_conv.is_owned = false;
23861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23862         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
23863         return ret_val;
23864 }
23865
23866 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) {
23867         LDKChannelHandshakeLimits this_ptr_conv;
23868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23869         this_ptr_conv.is_owned = false;
23870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23871         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
23872 }
23873
23874 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
23875         LDKChannelHandshakeLimits this_ptr_conv;
23876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23877         this_ptr_conv.is_owned = false;
23878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23879         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
23880         return ret_val;
23881 }
23882
23883 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) {
23884         LDKChannelHandshakeLimits this_ptr_conv;
23885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23886         this_ptr_conv.is_owned = false;
23887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23888         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
23889 }
23890
23891 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
23892         LDKChannelHandshakeLimits this_ptr_conv;
23893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23894         this_ptr_conv.is_owned = false;
23895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23896         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
23897         return ret_val;
23898 }
23899
23900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23901         LDKChannelHandshakeLimits this_ptr_conv;
23902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23903         this_ptr_conv.is_owned = false;
23904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23905         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
23906 }
23907
23908 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
23909         LDKChannelHandshakeLimits this_ptr_conv;
23910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23911         this_ptr_conv.is_owned = false;
23912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23913         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
23914         return ret_val;
23915 }
23916
23917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
23918         LDKChannelHandshakeLimits this_ptr_conv;
23919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23920         this_ptr_conv.is_owned = false;
23921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23922         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
23923 }
23924
23925 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
23926         LDKChannelHandshakeLimits this_ptr_conv;
23927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23928         this_ptr_conv.is_owned = false;
23929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23930         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
23931         return ret_val;
23932 }
23933
23934 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) {
23935         LDKChannelHandshakeLimits this_ptr_conv;
23936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23937         this_ptr_conv.is_owned = false;
23938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23939         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
23940 }
23941
23942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(JNIEnv *env, jclass clz, int64_t min_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int32_t max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
23943         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
23944         uintptr_t ret_ref = 0;
23945         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23946         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23948         ret_ref = (uintptr_t)ret_var.inner;
23949         if (ret_var.is_owned) {
23950                 ret_ref |= 1;
23951         }
23952         return ret_ref;
23953 }
23954
23955 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
23956         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
23957 uintptr_t ret_ref = 0;
23958 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23959 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23960 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23961 ret_ref = (uintptr_t)ret_var.inner;
23962 if (ret_var.is_owned) {
23963         ret_ref |= 1;
23964 }
23965         return ret_ref;
23966 }
23967 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23968         LDKChannelHandshakeLimits arg_conv;
23969         arg_conv.inner = (void*)(arg & (~1));
23970         arg_conv.is_owned = false;
23971         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23972         intptr_t ret_val = ChannelHandshakeLimits_clone_ptr(&arg_conv);
23973         return ret_val;
23974 }
23975
23976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23977         LDKChannelHandshakeLimits orig_conv;
23978         orig_conv.inner = (void*)(orig & (~1));
23979         orig_conv.is_owned = false;
23980         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23981         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
23982         uintptr_t ret_ref = 0;
23983         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23984         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23986         ret_ref = (uintptr_t)ret_var.inner;
23987         if (ret_var.is_owned) {
23988                 ret_ref |= 1;
23989         }
23990         return ret_ref;
23991 }
23992
23993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
23994         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
23995         uintptr_t ret_ref = 0;
23996         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23997         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23999         ret_ref = (uintptr_t)ret_var.inner;
24000         if (ret_var.is_owned) {
24001                 ret_ref |= 1;
24002         }
24003         return ret_ref;
24004 }
24005
24006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24007         LDKChannelConfig this_obj_conv;
24008         this_obj_conv.inner = (void*)(this_obj & (~1));
24009         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24011         ChannelConfig_free(this_obj_conv);
24012 }
24013
24014 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
24015         LDKChannelConfig this_ptr_conv;
24016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24017         this_ptr_conv.is_owned = false;
24018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24019         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
24020         return ret_val;
24021 }
24022
24023 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) {
24024         LDKChannelConfig this_ptr_conv;
24025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24026         this_ptr_conv.is_owned = false;
24027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24028         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
24029 }
24030
24031 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24032         LDKChannelConfig this_ptr_conv;
24033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24034         this_ptr_conv.is_owned = false;
24035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24036         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
24037         return ret_val;
24038 }
24039
24040 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) {
24041         LDKChannelConfig this_ptr_conv;
24042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24043         this_ptr_conv.is_owned = false;
24044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24045         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
24046 }
24047
24048 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24049         LDKChannelConfig this_ptr_conv;
24050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24051         this_ptr_conv.is_owned = false;
24052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24053         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
24054         return ret_val;
24055 }
24056
24057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
24058         LDKChannelConfig this_ptr_conv;
24059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24060         this_ptr_conv.is_owned = false;
24061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24062         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
24063 }
24064
24065 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
24066         LDKChannelConfig this_ptr_conv;
24067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24068         this_ptr_conv.is_owned = false;
24069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24070         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
24071         return ret_val;
24072 }
24073
24074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24075         LDKChannelConfig this_ptr_conv;
24076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24077         this_ptr_conv.is_owned = false;
24078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24079         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
24080 }
24081
24082 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
24083         LDKChannelConfig this_ptr_conv;
24084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24085         this_ptr_conv.is_owned = false;
24086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24087         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
24088         return ret_val;
24089 }
24090
24091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24092         LDKChannelConfig this_ptr_conv;
24093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24094         this_ptr_conv.is_owned = false;
24095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24096         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
24097 }
24098
24099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24100         LDKChannelConfig this_ptr_conv;
24101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24102         this_ptr_conv.is_owned = false;
24103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24104         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
24105         return ret_val;
24106 }
24107
24108 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) {
24109         LDKChannelConfig this_ptr_conv;
24110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24111         this_ptr_conv.is_owned = false;
24112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24113         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
24114 }
24115
24116 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) {
24117         LDKChannelConfig this_ptr_conv;
24118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24119         this_ptr_conv.is_owned = false;
24120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24121         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
24122         return ret_val;
24123 }
24124
24125 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) {
24126         LDKChannelConfig this_ptr_conv;
24127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24128         this_ptr_conv.is_owned = false;
24129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24130         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
24131 }
24132
24133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
24134         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
24135         uintptr_t ret_ref = 0;
24136         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24137         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24139         ret_ref = (uintptr_t)ret_var.inner;
24140         if (ret_var.is_owned) {
24141                 ret_ref |= 1;
24142         }
24143         return ret_ref;
24144 }
24145
24146 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
24147         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
24148 uintptr_t ret_ref = 0;
24149 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24150 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24151 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24152 ret_ref = (uintptr_t)ret_var.inner;
24153 if (ret_var.is_owned) {
24154         ret_ref |= 1;
24155 }
24156         return ret_ref;
24157 }
24158 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24159         LDKChannelConfig arg_conv;
24160         arg_conv.inner = (void*)(arg & (~1));
24161         arg_conv.is_owned = false;
24162         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24163         intptr_t ret_val = ChannelConfig_clone_ptr(&arg_conv);
24164         return ret_val;
24165 }
24166
24167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24168         LDKChannelConfig orig_conv;
24169         orig_conv.inner = (void*)(orig & (~1));
24170         orig_conv.is_owned = false;
24171         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24172         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
24173         uintptr_t ret_ref = 0;
24174         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24175         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24177         ret_ref = (uintptr_t)ret_var.inner;
24178         if (ret_var.is_owned) {
24179                 ret_ref |= 1;
24180         }
24181         return ret_ref;
24182 }
24183
24184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
24185         LDKChannelConfig ret_var = ChannelConfig_default();
24186         uintptr_t ret_ref = 0;
24187         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24188         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24190         ret_ref = (uintptr_t)ret_var.inner;
24191         if (ret_var.is_owned) {
24192                 ret_ref |= 1;
24193         }
24194         return ret_ref;
24195 }
24196
24197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
24198         LDKChannelConfig obj_conv;
24199         obj_conv.inner = (void*)(obj & (~1));
24200         obj_conv.is_owned = false;
24201         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24202         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
24203         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24204         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24205         CVec_u8Z_free(ret_var);
24206         return ret_arr;
24207 }
24208
24209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24210         LDKu8slice ser_ref;
24211         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24212         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24213         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
24214         *ret_conv = ChannelConfig_read(ser_ref);
24215         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24216         return (uintptr_t)ret_conv;
24217 }
24218
24219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24220         LDKUserConfig this_obj_conv;
24221         this_obj_conv.inner = (void*)(this_obj & (~1));
24222         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24224         UserConfig_free(this_obj_conv);
24225 }
24226
24227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
24228         LDKUserConfig this_ptr_conv;
24229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24230         this_ptr_conv.is_owned = false;
24231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24232         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
24233         uintptr_t ret_ref = 0;
24234         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24235         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24237         ret_ref = (uintptr_t)ret_var.inner;
24238         if (ret_var.is_owned) {
24239                 ret_ref |= 1;
24240         }
24241         return ret_ref;
24242 }
24243
24244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24245         LDKUserConfig this_ptr_conv;
24246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24247         this_ptr_conv.is_owned = false;
24248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24249         LDKChannelHandshakeConfig val_conv;
24250         val_conv.inner = (void*)(val & (~1));
24251         val_conv.is_owned = (val & 1) || (val == 0);
24252         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24253         val_conv = ChannelHandshakeConfig_clone(&val_conv);
24254         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
24255 }
24256
24257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
24258         LDKUserConfig this_ptr_conv;
24259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24260         this_ptr_conv.is_owned = false;
24261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24262         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
24263         uintptr_t ret_ref = 0;
24264         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24265         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24267         ret_ref = (uintptr_t)ret_var.inner;
24268         if (ret_var.is_owned) {
24269                 ret_ref |= 1;
24270         }
24271         return ret_ref;
24272 }
24273
24274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24275         LDKUserConfig this_ptr_conv;
24276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24277         this_ptr_conv.is_owned = false;
24278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24279         LDKChannelHandshakeLimits val_conv;
24280         val_conv.inner = (void*)(val & (~1));
24281         val_conv.is_owned = (val & 1) || (val == 0);
24282         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24283         val_conv = ChannelHandshakeLimits_clone(&val_conv);
24284         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
24285 }
24286
24287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
24288         LDKUserConfig this_ptr_conv;
24289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24290         this_ptr_conv.is_owned = false;
24291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24292         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
24293         uintptr_t ret_ref = 0;
24294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24297         ret_ref = (uintptr_t)ret_var.inner;
24298         if (ret_var.is_owned) {
24299                 ret_ref |= 1;
24300         }
24301         return ret_ref;
24302 }
24303
24304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24305         LDKUserConfig this_ptr_conv;
24306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24307         this_ptr_conv.is_owned = false;
24308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24309         LDKChannelConfig val_conv;
24310         val_conv.inner = (void*)(val & (~1));
24311         val_conv.is_owned = (val & 1) || (val == 0);
24312         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24313         val_conv = ChannelConfig_clone(&val_conv);
24314         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
24315 }
24316
24317 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
24318         LDKUserConfig this_ptr_conv;
24319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24320         this_ptr_conv.is_owned = false;
24321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24322         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
24323         return ret_val;
24324 }
24325
24326 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) {
24327         LDKUserConfig this_ptr_conv;
24328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24329         this_ptr_conv.is_owned = false;
24330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24331         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
24332 }
24333
24334 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
24335         LDKUserConfig this_ptr_conv;
24336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24337         this_ptr_conv.is_owned = false;
24338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24339         jboolean ret_val = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
24340         return ret_val;
24341 }
24342
24343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24344         LDKUserConfig this_ptr_conv;
24345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24346         this_ptr_conv.is_owned = false;
24347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24348         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
24349 }
24350
24351 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
24352         LDKUserConfig this_ptr_conv;
24353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24354         this_ptr_conv.is_owned = false;
24355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24356         jboolean ret_val = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
24357         return ret_val;
24358 }
24359
24360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24361         LDKUserConfig this_ptr_conv;
24362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24363         this_ptr_conv.is_owned = false;
24364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24365         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
24366 }
24367
24368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t own_channel_config_arg, int64_t peer_channel_config_limits_arg, int64_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg, jboolean manually_accept_inbound_channels_arg) {
24369         LDKChannelHandshakeConfig own_channel_config_arg_conv;
24370         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
24371         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
24372         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
24373         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
24374         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
24375         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
24376         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
24377         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
24378         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
24379         LDKChannelConfig channel_options_arg_conv;
24380         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
24381         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
24382         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
24383         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
24384         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg);
24385         uintptr_t ret_ref = 0;
24386         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24387         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24389         ret_ref = (uintptr_t)ret_var.inner;
24390         if (ret_var.is_owned) {
24391                 ret_ref |= 1;
24392         }
24393         return ret_ref;
24394 }
24395
24396 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
24397         LDKUserConfig ret_var = UserConfig_clone(arg);
24398 uintptr_t ret_ref = 0;
24399 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24400 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24401 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24402 ret_ref = (uintptr_t)ret_var.inner;
24403 if (ret_var.is_owned) {
24404         ret_ref |= 1;
24405 }
24406         return ret_ref;
24407 }
24408 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24409         LDKUserConfig arg_conv;
24410         arg_conv.inner = (void*)(arg & (~1));
24411         arg_conv.is_owned = false;
24412         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24413         intptr_t ret_val = UserConfig_clone_ptr(&arg_conv);
24414         return ret_val;
24415 }
24416
24417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24418         LDKUserConfig orig_conv;
24419         orig_conv.inner = (void*)(orig & (~1));
24420         orig_conv.is_owned = false;
24421         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24422         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
24423         uintptr_t ret_ref = 0;
24424         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24425         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24427         ret_ref = (uintptr_t)ret_var.inner;
24428         if (ret_var.is_owned) {
24429                 ret_ref |= 1;
24430         }
24431         return ret_ref;
24432 }
24433
24434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
24435         LDKUserConfig ret_var = UserConfig_default();
24436         uintptr_t ret_ref = 0;
24437         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24438         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24440         ret_ref = (uintptr_t)ret_var.inner;
24441         if (ret_var.is_owned) {
24442                 ret_ref |= 1;
24443         }
24444         return ret_ref;
24445 }
24446
24447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24448         LDKBestBlock this_obj_conv;
24449         this_obj_conv.inner = (void*)(this_obj & (~1));
24450         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24452         BestBlock_free(this_obj_conv);
24453 }
24454
24455 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
24456         LDKBestBlock ret_var = BestBlock_clone(arg);
24457 uintptr_t ret_ref = 0;
24458 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24459 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24460 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24461 ret_ref = (uintptr_t)ret_var.inner;
24462 if (ret_var.is_owned) {
24463         ret_ref |= 1;
24464 }
24465         return ret_ref;
24466 }
24467 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24468         LDKBestBlock arg_conv;
24469         arg_conv.inner = (void*)(arg & (~1));
24470         arg_conv.is_owned = false;
24471         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24472         intptr_t ret_val = BestBlock_clone_ptr(&arg_conv);
24473         return ret_val;
24474 }
24475
24476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24477         LDKBestBlock orig_conv;
24478         orig_conv.inner = (void*)(orig & (~1));
24479         orig_conv.is_owned = false;
24480         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24481         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
24482         uintptr_t ret_ref = 0;
24483         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24484         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24486         ret_ref = (uintptr_t)ret_var.inner;
24487         if (ret_var.is_owned) {
24488                 ret_ref |= 1;
24489         }
24490         return ret_ref;
24491 }
24492
24493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
24494         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
24495         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
24496         uintptr_t ret_ref = 0;
24497         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24498         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24499         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24500         ret_ref = (uintptr_t)ret_var.inner;
24501         if (ret_var.is_owned) {
24502                 ret_ref |= 1;
24503         }
24504         return ret_ref;
24505 }
24506
24507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
24508         LDKThirtyTwoBytes block_hash_ref;
24509         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
24510         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
24511         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
24512         uintptr_t ret_ref = 0;
24513         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24514         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24516         ret_ref = (uintptr_t)ret_var.inner;
24517         if (ret_var.is_owned) {
24518                 ret_ref |= 1;
24519         }
24520         return ret_ref;
24521 }
24522
24523 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
24524         LDKBestBlock this_arg_conv;
24525         this_arg_conv.inner = (void*)(this_arg & (~1));
24526         this_arg_conv.is_owned = false;
24527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24528         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24529         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
24530         return ret_arr;
24531 }
24532
24533 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
24534         LDKBestBlock this_arg_conv;
24535         this_arg_conv.inner = (void*)(this_arg & (~1));
24536         this_arg_conv.is_owned = false;
24537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24538         int32_t ret_val = BestBlock_height(&this_arg_conv);
24539         return ret_val;
24540 }
24541
24542 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24543         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
24544         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
24545         return ret_conv;
24546 }
24547
24548 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
24549         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
24550         return ret_conv;
24551 }
24552
24553 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
24554         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
24555         return ret_conv;
24556 }
24557
24558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24559         if ((this_ptr & 1) != 0) return;
24560         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24561         CHECK_ACCESS(this_ptr_ptr);
24562         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
24563         FREE((void*)this_ptr);
24564         Access_free(this_ptr_conv);
24565 }
24566
24567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24568         if ((this_ptr & 1) != 0) return;
24569         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24570         CHECK_ACCESS(this_ptr_ptr);
24571         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
24572         FREE((void*)this_ptr);
24573         Listen_free(this_ptr_conv);
24574 }
24575
24576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24577         if ((this_ptr & 1) != 0) return;
24578         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24579         CHECK_ACCESS(this_ptr_ptr);
24580         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
24581         FREE((void*)this_ptr);
24582         Confirm_free(this_ptr_conv);
24583 }
24584
24585 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24586         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
24587         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
24588         return ret_conv;
24589 }
24590
24591 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
24592         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
24593         return ret_conv;
24594 }
24595
24596 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
24597         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
24598         return ret_conv;
24599 }
24600
24601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24602         if ((this_ptr & 1) != 0) return;
24603         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24604         CHECK_ACCESS(this_ptr_ptr);
24605         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
24606         FREE((void*)this_ptr);
24607         Watch_free(this_ptr_conv);
24608 }
24609
24610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24611         if ((this_ptr & 1) != 0) return;
24612         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24613         CHECK_ACCESS(this_ptr_ptr);
24614         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
24615         FREE((void*)this_ptr);
24616         Filter_free(this_ptr_conv);
24617 }
24618
24619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24620         LDKWatchedOutput this_obj_conv;
24621         this_obj_conv.inner = (void*)(this_obj & (~1));
24622         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24624         WatchedOutput_free(this_obj_conv);
24625 }
24626
24627 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
24628         LDKWatchedOutput this_ptr_conv;
24629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24630         this_ptr_conv.is_owned = false;
24631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24632         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24633         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
24634         return ret_arr;
24635 }
24636
24637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24638         LDKWatchedOutput this_ptr_conv;
24639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24640         this_ptr_conv.is_owned = false;
24641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24642         LDKThirtyTwoBytes val_ref;
24643         CHECK((*env)->GetArrayLength(env, val) == 32);
24644         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24645         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
24646 }
24647
24648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
24649         LDKWatchedOutput this_ptr_conv;
24650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24651         this_ptr_conv.is_owned = false;
24652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24653         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
24654         uintptr_t ret_ref = 0;
24655         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24656         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24658         ret_ref = (uintptr_t)ret_var.inner;
24659         if (ret_var.is_owned) {
24660                 ret_ref |= 1;
24661         }
24662         return ret_ref;
24663 }
24664
24665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24666         LDKWatchedOutput this_ptr_conv;
24667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24668         this_ptr_conv.is_owned = false;
24669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24670         LDKOutPoint val_conv;
24671         val_conv.inner = (void*)(val & (~1));
24672         val_conv.is_owned = (val & 1) || (val == 0);
24673         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24674         val_conv = OutPoint_clone(&val_conv);
24675         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
24676 }
24677
24678 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
24679         LDKWatchedOutput this_ptr_conv;
24680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24681         this_ptr_conv.is_owned = false;
24682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24683         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
24684         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24685         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24686         return ret_arr;
24687 }
24688
24689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24690         LDKWatchedOutput this_ptr_conv;
24691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24692         this_ptr_conv.is_owned = false;
24693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24694         LDKCVec_u8Z val_ref;
24695         val_ref.datalen = (*env)->GetArrayLength(env, val);
24696         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
24697         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
24698         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
24699 }
24700
24701 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) {
24702         LDKThirtyTwoBytes block_hash_arg_ref;
24703         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
24704         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
24705         LDKOutPoint outpoint_arg_conv;
24706         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
24707         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
24708         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
24709         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
24710         LDKCVec_u8Z script_pubkey_arg_ref;
24711         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
24712         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
24713         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
24714         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
24715         uintptr_t ret_ref = 0;
24716         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24717         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24719         ret_ref = (uintptr_t)ret_var.inner;
24720         if (ret_var.is_owned) {
24721                 ret_ref |= 1;
24722         }
24723         return ret_ref;
24724 }
24725
24726 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
24727         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
24728 uintptr_t ret_ref = 0;
24729 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24730 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24731 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24732 ret_ref = (uintptr_t)ret_var.inner;
24733 if (ret_var.is_owned) {
24734         ret_ref |= 1;
24735 }
24736         return ret_ref;
24737 }
24738 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24739         LDKWatchedOutput arg_conv;
24740         arg_conv.inner = (void*)(arg & (~1));
24741         arg_conv.is_owned = false;
24742         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24743         intptr_t ret_val = WatchedOutput_clone_ptr(&arg_conv);
24744         return ret_val;
24745 }
24746
24747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24748         LDKWatchedOutput orig_conv;
24749         orig_conv.inner = (void*)(orig & (~1));
24750         orig_conv.is_owned = false;
24751         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24752         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
24753         uintptr_t ret_ref = 0;
24754         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24755         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24757         ret_ref = (uintptr_t)ret_var.inner;
24758         if (ret_var.is_owned) {
24759                 ret_ref |= 1;
24760         }
24761         return ret_ref;
24762 }
24763
24764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
24765         LDKWatchedOutput o_conv;
24766         o_conv.inner = (void*)(o & (~1));
24767         o_conv.is_owned = false;
24768         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24769         int64_t ret_val = WatchedOutput_hash(&o_conv);
24770         return ret_val;
24771 }
24772
24773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24774         if ((this_ptr & 1) != 0) return;
24775         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24776         CHECK_ACCESS(this_ptr_ptr);
24777         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
24778         FREE((void*)this_ptr);
24779         BroadcasterInterface_free(this_ptr_conv);
24780 }
24781
24782 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24783         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
24784         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
24785         return ret_conv;
24786 }
24787
24788 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
24789         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
24790         return ret_conv;
24791 }
24792
24793 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
24794         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
24795         return ret_conv;
24796 }
24797
24798 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
24799         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
24800         return ret_conv;
24801 }
24802
24803 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24804         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
24805         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
24806         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
24807         return ret_val;
24808 }
24809
24810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24811         if ((this_ptr & 1) != 0) return;
24812         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24813         CHECK_ACCESS(this_ptr_ptr);
24814         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
24815         FREE((void*)this_ptr);
24816         FeeEstimator_free(this_ptr_conv);
24817 }
24818
24819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24820         LDKMonitorUpdateId this_obj_conv;
24821         this_obj_conv.inner = (void*)(this_obj & (~1));
24822         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24824         MonitorUpdateId_free(this_obj_conv);
24825 }
24826
24827 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
24828         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
24829 uintptr_t ret_ref = 0;
24830 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24831 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24832 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24833 ret_ref = (uintptr_t)ret_var.inner;
24834 if (ret_var.is_owned) {
24835         ret_ref |= 1;
24836 }
24837         return ret_ref;
24838 }
24839 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24840         LDKMonitorUpdateId arg_conv;
24841         arg_conv.inner = (void*)(arg & (~1));
24842         arg_conv.is_owned = false;
24843         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24844         intptr_t ret_val = MonitorUpdateId_clone_ptr(&arg_conv);
24845         return ret_val;
24846 }
24847
24848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24849         LDKMonitorUpdateId orig_conv;
24850         orig_conv.inner = (void*)(orig & (~1));
24851         orig_conv.is_owned = false;
24852         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24853         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
24854         uintptr_t ret_ref = 0;
24855         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24856         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24858         ret_ref = (uintptr_t)ret_var.inner;
24859         if (ret_var.is_owned) {
24860                 ret_ref |= 1;
24861         }
24862         return ret_ref;
24863 }
24864
24865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
24866         LDKMonitorUpdateId o_conv;
24867         o_conv.inner = (void*)(o & (~1));
24868         o_conv.is_owned = false;
24869         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24870         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
24871         return ret_val;
24872 }
24873
24874 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24875         LDKMonitorUpdateId a_conv;
24876         a_conv.inner = (void*)(a & (~1));
24877         a_conv.is_owned = false;
24878         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24879         LDKMonitorUpdateId b_conv;
24880         b_conv.inner = (void*)(b & (~1));
24881         b_conv.is_owned = false;
24882         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
24883         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
24884         return ret_val;
24885 }
24886
24887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24888         if ((this_ptr & 1) != 0) return;
24889         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24890         CHECK_ACCESS(this_ptr_ptr);
24891         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
24892         FREE((void*)this_ptr);
24893         Persist_free(this_ptr_conv);
24894 }
24895
24896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24897         LDKLockedChannelMonitor this_obj_conv;
24898         this_obj_conv.inner = (void*)(this_obj & (~1));
24899         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24901         LockedChannelMonitor_free(this_obj_conv);
24902 }
24903
24904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24905         LDKChainMonitor this_obj_conv;
24906         this_obj_conv.inner = (void*)(this_obj & (~1));
24907         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24909         ChainMonitor_free(this_obj_conv);
24910 }
24911
24912 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) {
24913         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
24914         CHECK_ACCESS(chain_source_ptr);
24915         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
24916         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
24917         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
24918                 // Manually implement clone for Java trait instances
24919                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
24920                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24921                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
24922                 }
24923         }
24924         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24925         CHECK_ACCESS(broadcaster_ptr);
24926         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24927         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24928                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24929                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24930         }
24931         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24932         CHECK_ACCESS(logger_ptr);
24933         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24934         if (logger_conv.free == LDKLogger_JCalls_free) {
24935                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24936                 LDKLogger_JCalls_cloned(&logger_conv);
24937         }
24938         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
24939         CHECK_ACCESS(feeest_ptr);
24940         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
24941         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
24942                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24943                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
24944         }
24945         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
24946         CHECK_ACCESS(persister_ptr);
24947         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
24948         if (persister_conv.free == LDKPersist_JCalls_free) {
24949                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24950                 LDKPersist_JCalls_cloned(&persister_conv);
24951         }
24952         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
24953         uintptr_t ret_ref = 0;
24954         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24955         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24957         ret_ref = (uintptr_t)ret_var.inner;
24958         if (ret_var.is_owned) {
24959                 ret_ref |= 1;
24960         }
24961         return ret_ref;
24962 }
24963
24964 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) {
24965         LDKChainMonitor this_arg_conv;
24966         this_arg_conv.inner = (void*)(this_arg & (~1));
24967         this_arg_conv.is_owned = false;
24968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24969         LDKCVec_ChannelDetailsZ ignored_channels_constr;
24970         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
24971         if (ignored_channels_constr.datalen > 0)
24972                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
24973         else
24974                 ignored_channels_constr.data = NULL;
24975         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
24976         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
24977                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
24978                 LDKChannelDetails ignored_channels_conv_16_conv;
24979                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
24980                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
24981                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
24982                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
24983                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
24984         }
24985         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
24986         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
24987         int64_tArray ret_arr = NULL;
24988         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
24989         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
24990         for (size_t j = 0; j < ret_var.datalen; j++) {
24991                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
24992                 *ret_conv_9_copy = ret_var.data[j];
24993                 uintptr_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
24994                 ret_arr_ptr[j] = ret_conv_9_ref;
24995         }
24996         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
24997         FREE(ret_var.data);
24998         return ret_arr;
24999 }
25000
25001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
25002         LDKChainMonitor this_arg_conv;
25003         this_arg_conv.inner = (void*)(this_arg & (~1));
25004         this_arg_conv.is_owned = false;
25005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25006         LDKOutPoint funding_txo_conv;
25007         funding_txo_conv.inner = (void*)(funding_txo & (~1));
25008         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
25009         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25010         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25011         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
25012         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
25013         return (uintptr_t)ret_conv;
25014 }
25015
25016 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
25017         LDKChainMonitor this_arg_conv;
25018         this_arg_conv.inner = (void*)(this_arg & (~1));
25019         this_arg_conv.is_owned = false;
25020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25021         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
25022         int64_tArray ret_arr = NULL;
25023         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25024         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25025         for (size_t k = 0; k < ret_var.datalen; k++) {
25026                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
25027                 uintptr_t ret_conv_10_ref = 0;
25028                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25029                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25030                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
25031                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
25032                 if (ret_conv_10_var.is_owned) {
25033                         ret_conv_10_ref |= 1;
25034                 }
25035                 ret_arr_ptr[k] = ret_conv_10_ref;
25036         }
25037         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25038         FREE(ret_var.data);
25039         return ret_arr;
25040 }
25041
25042 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) {
25043         LDKChainMonitor this_arg_conv;
25044         this_arg_conv.inner = (void*)(this_arg & (~1));
25045         this_arg_conv.is_owned = false;
25046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25047         LDKOutPoint funding_txo_conv;
25048         funding_txo_conv.inner = (void*)(funding_txo & (~1));
25049         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
25050         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25051         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25052         LDKMonitorUpdateId completed_update_id_conv;
25053         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
25054         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
25055         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
25056         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
25057         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25058         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
25059         return (uintptr_t)ret_conv;
25060 }
25061
25062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
25063         LDKChainMonitor this_arg_conv;
25064         this_arg_conv.inner = (void*)(this_arg & (~1));
25065         this_arg_conv.is_owned = false;
25066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25067         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
25068         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
25069         return (uintptr_t)ret_ret;
25070 }
25071
25072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
25073         LDKChainMonitor this_arg_conv;
25074         this_arg_conv.inner = (void*)(this_arg & (~1));
25075         this_arg_conv.is_owned = false;
25076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25077         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
25078         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
25079         return (uintptr_t)ret_ret;
25080 }
25081
25082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
25083         LDKChainMonitor this_arg_conv;
25084         this_arg_conv.inner = (void*)(this_arg & (~1));
25085         this_arg_conv.is_owned = false;
25086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25087         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
25088         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
25089         return (uintptr_t)ret_ret;
25090 }
25091
25092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
25093         LDKChainMonitor this_arg_conv;
25094         this_arg_conv.inner = (void*)(this_arg & (~1));
25095         this_arg_conv.is_owned = false;
25096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25097         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
25098         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
25099         return (uintptr_t)ret_ret;
25100 }
25101
25102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25103         LDKChannelMonitorUpdate this_obj_conv;
25104         this_obj_conv.inner = (void*)(this_obj & (~1));
25105         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25107         ChannelMonitorUpdate_free(this_obj_conv);
25108 }
25109
25110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
25111         LDKChannelMonitorUpdate this_ptr_conv;
25112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25113         this_ptr_conv.is_owned = false;
25114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25115         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
25116         return ret_val;
25117 }
25118
25119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25120         LDKChannelMonitorUpdate this_ptr_conv;
25121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25122         this_ptr_conv.is_owned = false;
25123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25124         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
25125 }
25126
25127 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
25128         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
25129 uintptr_t ret_ref = 0;
25130 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25131 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25132 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25133 ret_ref = (uintptr_t)ret_var.inner;
25134 if (ret_var.is_owned) {
25135         ret_ref |= 1;
25136 }
25137         return ret_ref;
25138 }
25139 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25140         LDKChannelMonitorUpdate arg_conv;
25141         arg_conv.inner = (void*)(arg & (~1));
25142         arg_conv.is_owned = false;
25143         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25144         intptr_t ret_val = ChannelMonitorUpdate_clone_ptr(&arg_conv);
25145         return ret_val;
25146 }
25147
25148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25149         LDKChannelMonitorUpdate orig_conv;
25150         orig_conv.inner = (void*)(orig & (~1));
25151         orig_conv.is_owned = false;
25152         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25153         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
25154         uintptr_t ret_ref = 0;
25155         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25156         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25158         ret_ref = (uintptr_t)ret_var.inner;
25159         if (ret_var.is_owned) {
25160                 ret_ref |= 1;
25161         }
25162         return ret_ref;
25163 }
25164
25165 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
25166         LDKChannelMonitorUpdate obj_conv;
25167         obj_conv.inner = (void*)(obj & (~1));
25168         obj_conv.is_owned = false;
25169         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25170         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
25171         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25172         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25173         CVec_u8Z_free(ret_var);
25174         return ret_arr;
25175 }
25176
25177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25178         LDKu8slice ser_ref;
25179         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25180         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25181         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
25182         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
25183         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25184         return (uintptr_t)ret_conv;
25185 }
25186
25187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25188         if ((this_ptr & 1) != 0) return;
25189         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25190         CHECK_ACCESS(this_ptr_ptr);
25191         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
25192         FREE((void*)this_ptr);
25193         MonitorEvent_free(this_ptr_conv);
25194 }
25195
25196 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
25197         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25198         *ret_copy = MonitorEvent_clone(arg);
25199 uintptr_t ret_ref = (uintptr_t)ret_copy;
25200         return ret_ref;
25201 }
25202 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25203         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
25204         intptr_t ret_val = MonitorEvent_clone_ptr(arg_conv);
25205         return ret_val;
25206 }
25207
25208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25209         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
25210         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25211         *ret_copy = MonitorEvent_clone(orig_conv);
25212         uintptr_t ret_ref = (uintptr_t)ret_copy;
25213         return ret_ref;
25214 }
25215
25216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
25217         LDKHTLCUpdate a_conv;
25218         a_conv.inner = (void*)(a & (~1));
25219         a_conv.is_owned = (a & 1) || (a == 0);
25220         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25221         a_conv = HTLCUpdate_clone(&a_conv);
25222         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25223         *ret_copy = MonitorEvent_htlcevent(a_conv);
25224         uintptr_t ret_ref = (uintptr_t)ret_copy;
25225         return ret_ref;
25226 }
25227
25228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
25229         LDKOutPoint a_conv;
25230         a_conv.inner = (void*)(a & (~1));
25231         a_conv.is_owned = (a & 1) || (a == 0);
25232         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25233         a_conv = OutPoint_clone(&a_conv);
25234         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25235         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
25236         uintptr_t ret_ref = (uintptr_t)ret_copy;
25237         return ret_ref;
25238 }
25239
25240 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) {
25241         LDKOutPoint funding_txo_conv;
25242         funding_txo_conv.inner = (void*)(funding_txo & (~1));
25243         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
25244         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25245         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25246         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25247         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
25248         uintptr_t ret_ref = (uintptr_t)ret_copy;
25249         return ret_ref;
25250 }
25251
25252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
25253         LDKOutPoint a_conv;
25254         a_conv.inner = (void*)(a & (~1));
25255         a_conv.is_owned = (a & 1) || (a == 0);
25256         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25257         a_conv = OutPoint_clone(&a_conv);
25258         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25259         *ret_copy = MonitorEvent_update_failed(a_conv);
25260         uintptr_t ret_ref = (uintptr_t)ret_copy;
25261         return ret_ref;
25262 }
25263
25264 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
25265         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
25266         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
25267         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25268         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25269         CVec_u8Z_free(ret_var);
25270         return ret_arr;
25271 }
25272
25273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25274         LDKu8slice ser_ref;
25275         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25276         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25277         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
25278         *ret_conv = MonitorEvent_read(ser_ref);
25279         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25280         return (uintptr_t)ret_conv;
25281 }
25282
25283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25284         LDKHTLCUpdate this_obj_conv;
25285         this_obj_conv.inner = (void*)(this_obj & (~1));
25286         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25288         HTLCUpdate_free(this_obj_conv);
25289 }
25290
25291 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
25292         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
25293 uintptr_t ret_ref = 0;
25294 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25295 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25296 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25297 ret_ref = (uintptr_t)ret_var.inner;
25298 if (ret_var.is_owned) {
25299         ret_ref |= 1;
25300 }
25301         return ret_ref;
25302 }
25303 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25304         LDKHTLCUpdate arg_conv;
25305         arg_conv.inner = (void*)(arg & (~1));
25306         arg_conv.is_owned = false;
25307         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25308         intptr_t ret_val = HTLCUpdate_clone_ptr(&arg_conv);
25309         return ret_val;
25310 }
25311
25312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25313         LDKHTLCUpdate orig_conv;
25314         orig_conv.inner = (void*)(orig & (~1));
25315         orig_conv.is_owned = false;
25316         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25317         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
25318         uintptr_t ret_ref = 0;
25319         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25320         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25322         ret_ref = (uintptr_t)ret_var.inner;
25323         if (ret_var.is_owned) {
25324                 ret_ref |= 1;
25325         }
25326         return ret_ref;
25327 }
25328
25329 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
25330         LDKHTLCUpdate obj_conv;
25331         obj_conv.inner = (void*)(obj & (~1));
25332         obj_conv.is_owned = false;
25333         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25334         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
25335         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25336         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25337         CVec_u8Z_free(ret_var);
25338         return ret_arr;
25339 }
25340
25341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25342         LDKu8slice ser_ref;
25343         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25344         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25345         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
25346         *ret_conv = HTLCUpdate_read(ser_ref);
25347         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25348         return (uintptr_t)ret_conv;
25349 }
25350
25351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25352         if ((this_ptr & 1) != 0) return;
25353         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25354         CHECK_ACCESS(this_ptr_ptr);
25355         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
25356         FREE((void*)this_ptr);
25357         Balance_free(this_ptr_conv);
25358 }
25359
25360 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
25361         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25362         *ret_copy = Balance_clone(arg);
25363 uintptr_t ret_ref = (uintptr_t)ret_copy;
25364         return ret_ref;
25365 }
25366 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25367         LDKBalance* arg_conv = (LDKBalance*)arg;
25368         intptr_t ret_val = Balance_clone_ptr(arg_conv);
25369         return ret_val;
25370 }
25371
25372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25373         LDKBalance* orig_conv = (LDKBalance*)orig;
25374         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25375         *ret_copy = Balance_clone(orig_conv);
25376         uintptr_t ret_ref = (uintptr_t)ret_copy;
25377         return ret_ref;
25378 }
25379
25380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
25381         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25382         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
25383         uintptr_t ret_ref = (uintptr_t)ret_copy;
25384         return ret_ref;
25385 }
25386
25387 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) {
25388         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25389         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
25390         uintptr_t ret_ref = (uintptr_t)ret_copy;
25391         return ret_ref;
25392 }
25393
25394 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) {
25395         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25396         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
25397         uintptr_t ret_ref = (uintptr_t)ret_copy;
25398         return ret_ref;
25399 }
25400
25401 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) {
25402         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25403         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
25404         uintptr_t ret_ref = (uintptr_t)ret_copy;
25405         return ret_ref;
25406 }
25407
25408 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25409         LDKBalance* a_conv = (LDKBalance*)a;
25410         LDKBalance* b_conv = (LDKBalance*)b;
25411         jboolean ret_val = Balance_eq(a_conv, b_conv);
25412         return ret_val;
25413 }
25414
25415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25416         LDKChannelMonitor this_obj_conv;
25417         this_obj_conv.inner = (void*)(this_obj & (~1));
25418         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25420         ChannelMonitor_free(this_obj_conv);
25421 }
25422
25423 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
25424         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
25425 uintptr_t ret_ref = 0;
25426 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25427 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25428 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25429 ret_ref = (uintptr_t)ret_var.inner;
25430 if (ret_var.is_owned) {
25431         ret_ref |= 1;
25432 }
25433         return ret_ref;
25434 }
25435 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25436         LDKChannelMonitor arg_conv;
25437         arg_conv.inner = (void*)(arg & (~1));
25438         arg_conv.is_owned = false;
25439         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25440         intptr_t ret_val = ChannelMonitor_clone_ptr(&arg_conv);
25441         return ret_val;
25442 }
25443
25444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25445         LDKChannelMonitor orig_conv;
25446         orig_conv.inner = (void*)(orig & (~1));
25447         orig_conv.is_owned = false;
25448         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25449         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
25450         uintptr_t ret_ref = 0;
25451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25454         ret_ref = (uintptr_t)ret_var.inner;
25455         if (ret_var.is_owned) {
25456                 ret_ref |= 1;
25457         }
25458         return ret_ref;
25459 }
25460
25461 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
25462         LDKChannelMonitor obj_conv;
25463         obj_conv.inner = (void*)(obj & (~1));
25464         obj_conv.is_owned = false;
25465         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25466         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
25467         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25468         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25469         CVec_u8Z_free(ret_var);
25470         return ret_arr;
25471 }
25472
25473 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) {
25474         LDKChannelMonitor this_arg_conv;
25475         this_arg_conv.inner = (void*)(this_arg & (~1));
25476         this_arg_conv.is_owned = false;
25477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25478         LDKChannelMonitorUpdate updates_conv;
25479         updates_conv.inner = (void*)(updates & (~1));
25480         updates_conv.is_owned = false;
25481         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
25482         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
25483         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
25484         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
25485         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
25486         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
25487         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
25488         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25489         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
25490         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
25491         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
25492         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
25493         return (uintptr_t)ret_conv;
25494 }
25495
25496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
25497         LDKChannelMonitor this_arg_conv;
25498         this_arg_conv.inner = (void*)(this_arg & (~1));
25499         this_arg_conv.is_owned = false;
25500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25501         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
25502         return ret_val;
25503 }
25504
25505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
25506         LDKChannelMonitor this_arg_conv;
25507         this_arg_conv.inner = (void*)(this_arg & (~1));
25508         this_arg_conv.is_owned = false;
25509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25510         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
25511         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
25512         return ((uintptr_t)ret_conv);
25513 }
25514
25515 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
25516         LDKChannelMonitor this_arg_conv;
25517         this_arg_conv.inner = (void*)(this_arg & (~1));
25518         this_arg_conv.is_owned = false;
25519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25520         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
25521         int64_tArray ret_arr = NULL;
25522         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25523         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25524         for (size_t o = 0; o < ret_var.datalen; o++) {
25525                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
25526                 *ret_conv_40_conv = ret_var.data[o];
25527                 ret_arr_ptr[o] = ((uintptr_t)ret_conv_40_conv);
25528         }
25529         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25530         FREE(ret_var.data);
25531         return ret_arr;
25532 }
25533
25534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
25535         LDKChannelMonitor this_arg_conv;
25536         this_arg_conv.inner = (void*)(this_arg & (~1));
25537         this_arg_conv.is_owned = false;
25538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25539         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
25540         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
25541         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
25542         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
25543 }
25544
25545 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
25546         LDKChannelMonitor this_arg_conv;
25547         this_arg_conv.inner = (void*)(this_arg & (~1));
25548         this_arg_conv.is_owned = false;
25549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25550         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
25551         int64_tArray ret_arr = NULL;
25552         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25553         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25554         for (size_t o = 0; o < ret_var.datalen; o++) {
25555                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25556                 *ret_conv_14_copy = ret_var.data[o];
25557                 uintptr_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
25558                 ret_arr_ptr[o] = ret_conv_14_ref;
25559         }
25560         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25561         FREE(ret_var.data);
25562         return ret_arr;
25563 }
25564
25565 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
25566         LDKChannelMonitor this_arg_conv;
25567         this_arg_conv.inner = (void*)(this_arg & (~1));
25568         this_arg_conv.is_owned = false;
25569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25570         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
25571         int64_tArray ret_arr = NULL;
25572         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25573         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25574         for (size_t h = 0; h < ret_var.datalen; h++) {
25575                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25576                 *ret_conv_7_copy = ret_var.data[h];
25577                 uintptr_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
25578                 ret_arr_ptr[h] = ret_conv_7_ref;
25579         }
25580         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25581         FREE(ret_var.data);
25582         return ret_arr;
25583 }
25584
25585 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) {
25586         LDKChannelMonitor this_arg_conv;
25587         this_arg_conv.inner = (void*)(this_arg & (~1));
25588         this_arg_conv.is_owned = false;
25589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25590         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25591         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
25592         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
25593         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
25594         jobjectArray ret_arr = NULL;
25595         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
25596         ;
25597         for (size_t i = 0; i < ret_var.datalen; i++) {
25598                 LDKTransaction ret_conv_8_var = ret_var.data[i];
25599                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
25600                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
25601                 Transaction_free(ret_conv_8_var);
25602                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
25603         }
25604         
25605         FREE(ret_var.data);
25606         return ret_arr;
25607 }
25608
25609 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) {
25610         LDKChannelMonitor this_arg_conv;
25611         this_arg_conv.inner = (void*)(this_arg & (~1));
25612         this_arg_conv.is_owned = false;
25613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25614         unsigned char header_arr[80];
25615         CHECK((*env)->GetArrayLength(env, header) == 80);
25616         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
25617         unsigned char (*header_ref)[80] = &header_arr;
25618         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
25619         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
25620         if (txdata_constr.datalen > 0)
25621                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
25622         else
25623                 txdata_constr.data = NULL;
25624         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
25625         for (size_t c = 0; c < txdata_constr.datalen; c++) {
25626                 int64_t txdata_conv_28 = txdata_vals[c];
25627                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
25628                 CHECK_ACCESS(txdata_conv_28_ptr);
25629                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
25630                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
25631                 txdata_constr.data[c] = txdata_conv_28_conv;
25632         }
25633         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
25634         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
25635         CHECK_ACCESS(broadcaster_ptr);
25636         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
25637         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25638                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25639                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
25640         }
25641         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
25642         CHECK_ACCESS(fee_estimator_ptr);
25643         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
25644         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
25645                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25646                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
25647         }
25648         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25649         CHECK_ACCESS(logger_ptr);
25650         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25651         if (logger_conv.free == LDKLogger_JCalls_free) {
25652                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25653                 LDKLogger_JCalls_cloned(&logger_conv);
25654         }
25655         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);
25656         int64_tArray ret_arr = NULL;
25657         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25658         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25659         for (size_t n = 0; n < ret_var.datalen; n++) {
25660                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
25661                 *ret_conv_39_conv = ret_var.data[n];
25662                 ret_arr_ptr[n] = ((uintptr_t)ret_conv_39_conv);
25663         }
25664         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25665         FREE(ret_var.data);
25666         return ret_arr;
25667 }
25668
25669 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) {
25670         LDKChannelMonitor this_arg_conv;
25671         this_arg_conv.inner = (void*)(this_arg & (~1));
25672         this_arg_conv.is_owned = false;
25673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25674         unsigned char header_arr[80];
25675         CHECK((*env)->GetArrayLength(env, header) == 80);
25676         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
25677         unsigned char (*header_ref)[80] = &header_arr;
25678         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
25679         CHECK_ACCESS(broadcaster_ptr);
25680         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
25681         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25682                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25683                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
25684         }
25685         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
25686         CHECK_ACCESS(fee_estimator_ptr);
25687         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
25688         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
25689                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25690                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
25691         }
25692         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25693         CHECK_ACCESS(logger_ptr);
25694         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25695         if (logger_conv.free == LDKLogger_JCalls_free) {
25696                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25697                 LDKLogger_JCalls_cloned(&logger_conv);
25698         }
25699         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
25700 }
25701
25702 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) {
25703         LDKChannelMonitor this_arg_conv;
25704         this_arg_conv.inner = (void*)(this_arg & (~1));
25705         this_arg_conv.is_owned = false;
25706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25707         unsigned char header_arr[80];
25708         CHECK((*env)->GetArrayLength(env, header) == 80);
25709         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
25710         unsigned char (*header_ref)[80] = &header_arr;
25711         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
25712         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
25713         if (txdata_constr.datalen > 0)
25714                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
25715         else
25716                 txdata_constr.data = NULL;
25717         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
25718         for (size_t c = 0; c < txdata_constr.datalen; c++) {
25719                 int64_t txdata_conv_28 = txdata_vals[c];
25720                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
25721                 CHECK_ACCESS(txdata_conv_28_ptr);
25722                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
25723                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
25724                 txdata_constr.data[c] = txdata_conv_28_conv;
25725         }
25726         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
25727         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
25728         CHECK_ACCESS(broadcaster_ptr);
25729         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
25730         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25731                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25732                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
25733         }
25734         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
25735         CHECK_ACCESS(fee_estimator_ptr);
25736         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
25737         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
25738                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25739                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
25740         }
25741         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25742         CHECK_ACCESS(logger_ptr);
25743         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25744         if (logger_conv.free == LDKLogger_JCalls_free) {
25745                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25746                 LDKLogger_JCalls_cloned(&logger_conv);
25747         }
25748         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);
25749         int64_tArray ret_arr = NULL;
25750         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25751         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25752         for (size_t n = 0; n < ret_var.datalen; n++) {
25753                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
25754                 *ret_conv_39_conv = ret_var.data[n];
25755                 ret_arr_ptr[n] = ((uintptr_t)ret_conv_39_conv);
25756         }
25757         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25758         FREE(ret_var.data);
25759         return ret_arr;
25760 }
25761
25762 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) {
25763         LDKChannelMonitor this_arg_conv;
25764         this_arg_conv.inner = (void*)(this_arg & (~1));
25765         this_arg_conv.is_owned = false;
25766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25767         unsigned char txid_arr[32];
25768         CHECK((*env)->GetArrayLength(env, txid) == 32);
25769         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
25770         unsigned char (*txid_ref)[32] = &txid_arr;
25771         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
25772         CHECK_ACCESS(broadcaster_ptr);
25773         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
25774         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25775                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25776                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
25777         }
25778         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
25779         CHECK_ACCESS(fee_estimator_ptr);
25780         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
25781         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
25782                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25783                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
25784         }
25785         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25786         CHECK_ACCESS(logger_ptr);
25787         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25788         if (logger_conv.free == LDKLogger_JCalls_free) {
25789                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25790                 LDKLogger_JCalls_cloned(&logger_conv);
25791         }
25792         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
25793 }
25794
25795 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) {
25796         LDKChannelMonitor this_arg_conv;
25797         this_arg_conv.inner = (void*)(this_arg & (~1));
25798         this_arg_conv.is_owned = false;
25799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25800         unsigned char header_arr[80];
25801         CHECK((*env)->GetArrayLength(env, header) == 80);
25802         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
25803         unsigned char (*header_ref)[80] = &header_arr;
25804         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
25805         CHECK_ACCESS(broadcaster_ptr);
25806         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
25807         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25808                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25809                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
25810         }
25811         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
25812         CHECK_ACCESS(fee_estimator_ptr);
25813         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
25814         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
25815                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25816                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
25817         }
25818         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25819         CHECK_ACCESS(logger_ptr);
25820         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25821         if (logger_conv.free == LDKLogger_JCalls_free) {
25822                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25823                 LDKLogger_JCalls_cloned(&logger_conv);
25824         }
25825         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
25826         int64_tArray ret_arr = NULL;
25827         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25828         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25829         for (size_t n = 0; n < ret_var.datalen; n++) {
25830                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
25831                 *ret_conv_39_conv = ret_var.data[n];
25832                 ret_arr_ptr[n] = ((uintptr_t)ret_conv_39_conv);
25833         }
25834         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25835         FREE(ret_var.data);
25836         return ret_arr;
25837 }
25838
25839 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
25840         LDKChannelMonitor this_arg_conv;
25841         this_arg_conv.inner = (void*)(this_arg & (~1));
25842         this_arg_conv.is_owned = false;
25843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25844         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
25845         jobjectArray ret_arr = NULL;
25846         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
25847         ;
25848         for (size_t i = 0; i < ret_var.datalen; i++) {
25849                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
25850                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
25851                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
25852         }
25853         
25854         FREE(ret_var.data);
25855         return ret_arr;
25856 }
25857
25858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
25859         LDKChannelMonitor this_arg_conv;
25860         this_arg_conv.inner = (void*)(this_arg & (~1));
25861         this_arg_conv.is_owned = false;
25862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25863         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
25864         uintptr_t ret_ref = 0;
25865         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25866         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25868         ret_ref = (uintptr_t)ret_var.inner;
25869         if (ret_var.is_owned) {
25870                 ret_ref |= 1;
25871         }
25872         return ret_ref;
25873 }
25874
25875 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
25876         LDKChannelMonitor this_arg_conv;
25877         this_arg_conv.inner = (void*)(this_arg & (~1));
25878         this_arg_conv.is_owned = false;
25879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25880         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
25881         int64_tArray ret_arr = NULL;
25882         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25883         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25884         for (size_t j = 0; j < ret_var.datalen; j++) {
25885                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25886                 *ret_conv_9_copy = ret_var.data[j];
25887                 uintptr_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
25888                 ret_arr_ptr[j] = ret_conv_9_ref;
25889         }
25890         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25891         FREE(ret_var.data);
25892         return ret_arr;
25893 }
25894
25895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
25896         LDKu8slice ser_ref;
25897         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25898         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25899         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
25900         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
25901         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
25902         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
25903         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
25904         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25905         return (uintptr_t)ret_conv;
25906 }
25907
25908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25909         LDKOutPoint this_obj_conv;
25910         this_obj_conv.inner = (void*)(this_obj & (~1));
25911         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25913         OutPoint_free(this_obj_conv);
25914 }
25915
25916 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
25917         LDKOutPoint this_ptr_conv;
25918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25919         this_ptr_conv.is_owned = false;
25920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25921         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25922         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
25923         return ret_arr;
25924 }
25925
25926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25927         LDKOutPoint 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         LDKThirtyTwoBytes val_ref;
25932         CHECK((*env)->GetArrayLength(env, val) == 32);
25933         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25934         OutPoint_set_txid(&this_ptr_conv, val_ref);
25935 }
25936
25937 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
25938         LDKOutPoint this_ptr_conv;
25939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25940         this_ptr_conv.is_owned = false;
25941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25942         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
25943         return ret_val;
25944 }
25945
25946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25947         LDKOutPoint this_ptr_conv;
25948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25949         this_ptr_conv.is_owned = false;
25950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25951         OutPoint_set_index(&this_ptr_conv, val);
25952 }
25953
25954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
25955         LDKThirtyTwoBytes txid_arg_ref;
25956         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
25957         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
25958         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
25959         uintptr_t ret_ref = 0;
25960         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25961         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25963         ret_ref = (uintptr_t)ret_var.inner;
25964         if (ret_var.is_owned) {
25965                 ret_ref |= 1;
25966         }
25967         return ret_ref;
25968 }
25969
25970 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
25971         LDKOutPoint ret_var = OutPoint_clone(arg);
25972 uintptr_t ret_ref = 0;
25973 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25974 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25975 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25976 ret_ref = (uintptr_t)ret_var.inner;
25977 if (ret_var.is_owned) {
25978         ret_ref |= 1;
25979 }
25980         return ret_ref;
25981 }
25982 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25983         LDKOutPoint arg_conv;
25984         arg_conv.inner = (void*)(arg & (~1));
25985         arg_conv.is_owned = false;
25986         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25987         intptr_t ret_val = OutPoint_clone_ptr(&arg_conv);
25988         return ret_val;
25989 }
25990
25991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25992         LDKOutPoint orig_conv;
25993         orig_conv.inner = (void*)(orig & (~1));
25994         orig_conv.is_owned = false;
25995         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25996         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
25997         uintptr_t ret_ref = 0;
25998         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25999         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26001         ret_ref = (uintptr_t)ret_var.inner;
26002         if (ret_var.is_owned) {
26003                 ret_ref |= 1;
26004         }
26005         return ret_ref;
26006 }
26007
26008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26009         LDKOutPoint a_conv;
26010         a_conv.inner = (void*)(a & (~1));
26011         a_conv.is_owned = false;
26012         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26013         LDKOutPoint b_conv;
26014         b_conv.inner = (void*)(b & (~1));
26015         b_conv.is_owned = false;
26016         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
26017         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
26018         return ret_val;
26019 }
26020
26021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
26022         LDKOutPoint o_conv;
26023         o_conv.inner = (void*)(o & (~1));
26024         o_conv.is_owned = false;
26025         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26026         int64_t ret_val = OutPoint_hash(&o_conv);
26027         return ret_val;
26028 }
26029
26030 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
26031         LDKOutPoint this_arg_conv;
26032         this_arg_conv.inner = (void*)(this_arg & (~1));
26033         this_arg_conv.is_owned = false;
26034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26035         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26036         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
26037         return ret_arr;
26038 }
26039
26040 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
26041         LDKOutPoint obj_conv;
26042         obj_conv.inner = (void*)(obj & (~1));
26043         obj_conv.is_owned = false;
26044         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26045         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
26046         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26047         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26048         CVec_u8Z_free(ret_var);
26049         return ret_arr;
26050 }
26051
26052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26053         LDKu8slice ser_ref;
26054         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26055         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26056         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
26057         *ret_conv = OutPoint_read(ser_ref);
26058         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26059         return (uintptr_t)ret_conv;
26060 }
26061
26062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26063         LDKDelayedPaymentOutputDescriptor this_obj_conv;
26064         this_obj_conv.inner = (void*)(this_obj & (~1));
26065         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26067         DelayedPaymentOutputDescriptor_free(this_obj_conv);
26068 }
26069
26070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26071         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26073         this_ptr_conv.is_owned = false;
26074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26075         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
26076         uintptr_t ret_ref = 0;
26077         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26078         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26080         ret_ref = (uintptr_t)ret_var.inner;
26081         if (ret_var.is_owned) {
26082                 ret_ref |= 1;
26083         }
26084         return ret_ref;
26085 }
26086
26087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26088         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26090         this_ptr_conv.is_owned = false;
26091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26092         LDKOutPoint val_conv;
26093         val_conv.inner = (void*)(val & (~1));
26094         val_conv.is_owned = (val & 1) || (val == 0);
26095         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26096         val_conv = OutPoint_clone(&val_conv);
26097         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
26098 }
26099
26100 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
26101         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26103         this_ptr_conv.is_owned = false;
26104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26105         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26106         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
26107         return ret_arr;
26108 }
26109
26110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26111         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26113         this_ptr_conv.is_owned = false;
26114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26115         LDKPublicKey val_ref;
26116         CHECK((*env)->GetArrayLength(env, val) == 33);
26117         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26118         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
26119 }
26120
26121 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26122         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26124         this_ptr_conv.is_owned = false;
26125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26126         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
26127         return ret_val;
26128 }
26129
26130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26131         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26133         this_ptr_conv.is_owned = false;
26134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26135         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
26136 }
26137
26138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26139         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26141         this_ptr_conv.is_owned = false;
26142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26143         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26144         CHECK_ACCESS(val_ptr);
26145         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
26146         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
26147         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
26148 }
26149
26150 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26151         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26153         this_ptr_conv.is_owned = false;
26154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26155         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26156         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
26157         return ret_arr;
26158 }
26159
26160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26161         LDKDelayedPaymentOutputDescriptor 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         LDKPublicKey val_ref;
26166         CHECK((*env)->GetArrayLength(env, val) == 33);
26167         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26168         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
26169 }
26170
26171 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26172         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26174         this_ptr_conv.is_owned = false;
26175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26176         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26177         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
26178         return ret_arr;
26179 }
26180
26181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26182         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26184         this_ptr_conv.is_owned = false;
26185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26186         LDKThirtyTwoBytes val_ref;
26187         CHECK((*env)->GetArrayLength(env, val) == 32);
26188         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26189         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
26190 }
26191
26192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26193         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26195         this_ptr_conv.is_owned = false;
26196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26197         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
26198         return ret_val;
26199 }
26200
26201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26202         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26204         this_ptr_conv.is_owned = false;
26205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26206         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
26207 }
26208
26209 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) {
26210         LDKOutPoint outpoint_arg_conv;
26211         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
26212         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
26213         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
26214         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
26215         LDKPublicKey per_commitment_point_arg_ref;
26216         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
26217         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
26218         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
26219         CHECK_ACCESS(output_arg_ptr);
26220         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
26221         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
26222         LDKPublicKey revocation_pubkey_arg_ref;
26223         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
26224         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
26225         LDKThirtyTwoBytes channel_keys_id_arg_ref;
26226         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
26227         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
26228         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);
26229         uintptr_t ret_ref = 0;
26230         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26231         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26233         ret_ref = (uintptr_t)ret_var.inner;
26234         if (ret_var.is_owned) {
26235                 ret_ref |= 1;
26236         }
26237         return ret_ref;
26238 }
26239
26240 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
26241         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
26242 uintptr_t ret_ref = 0;
26243 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26244 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26245 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26246 ret_ref = (uintptr_t)ret_var.inner;
26247 if (ret_var.is_owned) {
26248         ret_ref |= 1;
26249 }
26250         return ret_ref;
26251 }
26252 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26253         LDKDelayedPaymentOutputDescriptor arg_conv;
26254         arg_conv.inner = (void*)(arg & (~1));
26255         arg_conv.is_owned = false;
26256         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26257         intptr_t ret_val = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
26258         return ret_val;
26259 }
26260
26261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26262         LDKDelayedPaymentOutputDescriptor orig_conv;
26263         orig_conv.inner = (void*)(orig & (~1));
26264         orig_conv.is_owned = false;
26265         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26266         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
26267         uintptr_t ret_ref = 0;
26268         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26269         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26271         ret_ref = (uintptr_t)ret_var.inner;
26272         if (ret_var.is_owned) {
26273                 ret_ref |= 1;
26274         }
26275         return ret_ref;
26276 }
26277
26278 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
26279         LDKDelayedPaymentOutputDescriptor obj_conv;
26280         obj_conv.inner = (void*)(obj & (~1));
26281         obj_conv.is_owned = false;
26282         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26283         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
26284         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26285         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26286         CVec_u8Z_free(ret_var);
26287         return ret_arr;
26288 }
26289
26290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26291         LDKu8slice ser_ref;
26292         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26293         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26294         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
26295         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
26296         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26297         return (uintptr_t)ret_conv;
26298 }
26299
26300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26301         LDKStaticPaymentOutputDescriptor this_obj_conv;
26302         this_obj_conv.inner = (void*)(this_obj & (~1));
26303         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26305         StaticPaymentOutputDescriptor_free(this_obj_conv);
26306 }
26307
26308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26309         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26311         this_ptr_conv.is_owned = false;
26312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26313         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
26314         uintptr_t ret_ref = 0;
26315         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26316         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26318         ret_ref = (uintptr_t)ret_var.inner;
26319         if (ret_var.is_owned) {
26320                 ret_ref |= 1;
26321         }
26322         return ret_ref;
26323 }
26324
26325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26326         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26328         this_ptr_conv.is_owned = false;
26329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26330         LDKOutPoint val_conv;
26331         val_conv.inner = (void*)(val & (~1));
26332         val_conv.is_owned = (val & 1) || (val == 0);
26333         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26334         val_conv = OutPoint_clone(&val_conv);
26335         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
26336 }
26337
26338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26339         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26341         this_ptr_conv.is_owned = false;
26342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26343         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26344         CHECK_ACCESS(val_ptr);
26345         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
26346         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
26347         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
26348 }
26349
26350 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26351         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26353         this_ptr_conv.is_owned = false;
26354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26355         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26356         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
26357         return ret_arr;
26358 }
26359
26360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26361         LDKStaticPaymentOutputDescriptor 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         LDKThirtyTwoBytes val_ref;
26366         CHECK((*env)->GetArrayLength(env, val) == 32);
26367         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26368         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
26369 }
26370
26371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26372         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26374         this_ptr_conv.is_owned = false;
26375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26376         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
26377         return ret_val;
26378 }
26379
26380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26381         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26383         this_ptr_conv.is_owned = false;
26384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26385         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
26386 }
26387
26388 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) {
26389         LDKOutPoint outpoint_arg_conv;
26390         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
26391         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
26392         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
26393         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
26394         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
26395         CHECK_ACCESS(output_arg_ptr);
26396         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
26397         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
26398         LDKThirtyTwoBytes channel_keys_id_arg_ref;
26399         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
26400         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
26401         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
26402         uintptr_t ret_ref = 0;
26403         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26404         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26406         ret_ref = (uintptr_t)ret_var.inner;
26407         if (ret_var.is_owned) {
26408                 ret_ref |= 1;
26409         }
26410         return ret_ref;
26411 }
26412
26413 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
26414         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
26415 uintptr_t ret_ref = 0;
26416 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26417 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26418 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26419 ret_ref = (uintptr_t)ret_var.inner;
26420 if (ret_var.is_owned) {
26421         ret_ref |= 1;
26422 }
26423         return ret_ref;
26424 }
26425 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26426         LDKStaticPaymentOutputDescriptor arg_conv;
26427         arg_conv.inner = (void*)(arg & (~1));
26428         arg_conv.is_owned = false;
26429         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26430         intptr_t ret_val = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
26431         return ret_val;
26432 }
26433
26434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26435         LDKStaticPaymentOutputDescriptor orig_conv;
26436         orig_conv.inner = (void*)(orig & (~1));
26437         orig_conv.is_owned = false;
26438         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26439         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
26440         uintptr_t ret_ref = 0;
26441         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26442         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26444         ret_ref = (uintptr_t)ret_var.inner;
26445         if (ret_var.is_owned) {
26446                 ret_ref |= 1;
26447         }
26448         return ret_ref;
26449 }
26450
26451 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
26452         LDKStaticPaymentOutputDescriptor obj_conv;
26453         obj_conv.inner = (void*)(obj & (~1));
26454         obj_conv.is_owned = false;
26455         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26456         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
26457         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26458         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26459         CVec_u8Z_free(ret_var);
26460         return ret_arr;
26461 }
26462
26463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26464         LDKu8slice ser_ref;
26465         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26466         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26467         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
26468         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
26469         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26470         return (uintptr_t)ret_conv;
26471 }
26472
26473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26474         if ((this_ptr & 1) != 0) return;
26475         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26476         CHECK_ACCESS(this_ptr_ptr);
26477         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
26478         FREE((void*)this_ptr);
26479         SpendableOutputDescriptor_free(this_ptr_conv);
26480 }
26481
26482 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
26483         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
26484         *ret_copy = SpendableOutputDescriptor_clone(arg);
26485 uintptr_t ret_ref = (uintptr_t)ret_copy;
26486         return ret_ref;
26487 }
26488 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26489         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
26490         intptr_t ret_val = SpendableOutputDescriptor_clone_ptr(arg_conv);
26491         return ret_val;
26492 }
26493
26494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26495         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
26496         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
26497         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
26498         uintptr_t ret_ref = (uintptr_t)ret_copy;
26499         return ret_ref;
26500 }
26501
26502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
26503         LDKOutPoint outpoint_conv;
26504         outpoint_conv.inner = (void*)(outpoint & (~1));
26505         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
26506         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
26507         outpoint_conv = OutPoint_clone(&outpoint_conv);
26508         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
26509         CHECK_ACCESS(output_ptr);
26510         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
26511         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
26512         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
26513         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
26514         uintptr_t ret_ref = (uintptr_t)ret_copy;
26515         return ret_ref;
26516 }
26517
26518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
26519         LDKDelayedPaymentOutputDescriptor a_conv;
26520         a_conv.inner = (void*)(a & (~1));
26521         a_conv.is_owned = (a & 1) || (a == 0);
26522         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26523         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
26524         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
26525         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
26526         uintptr_t ret_ref = (uintptr_t)ret_copy;
26527         return ret_ref;
26528 }
26529
26530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
26531         LDKStaticPaymentOutputDescriptor a_conv;
26532         a_conv.inner = (void*)(a & (~1));
26533         a_conv.is_owned = (a & 1) || (a == 0);
26534         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26535         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
26536         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
26537         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
26538         uintptr_t ret_ref = (uintptr_t)ret_copy;
26539         return ret_ref;
26540 }
26541
26542 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
26543         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
26544         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
26545         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26546         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26547         CVec_u8Z_free(ret_var);
26548         return ret_arr;
26549 }
26550
26551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26552         LDKu8slice ser_ref;
26553         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26554         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26555         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
26556         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
26557         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26558         return (uintptr_t)ret_conv;
26559 }
26560
26561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26562         if ((this_ptr & 1) != 0) return;
26563         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26564         CHECK_ACCESS(this_ptr_ptr);
26565         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
26566         FREE((void*)this_ptr);
26567         BaseSign_free(this_ptr_conv);
26568 }
26569
26570 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
26571         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
26572         *ret_ret = Sign_clone(arg);
26573         return (uintptr_t)ret_ret;
26574 }
26575 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26576         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
26577         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
26578         LDKSign* arg_conv = (LDKSign*)arg_ptr;
26579         intptr_t ret_val = Sign_clone_ptr(arg_conv);
26580         return ret_val;
26581 }
26582
26583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26584         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
26585         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
26586         LDKSign* orig_conv = (LDKSign*)orig_ptr;
26587         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
26588         *ret_ret = Sign_clone(orig_conv);
26589         return (uintptr_t)ret_ret;
26590 }
26591
26592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26593         if ((this_ptr & 1) != 0) return;
26594         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26595         CHECK_ACCESS(this_ptr_ptr);
26596         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
26597         FREE((void*)this_ptr);
26598         Sign_free(this_ptr_conv);
26599 }
26600
26601 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26602         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
26603         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
26604         return ret_conv;
26605 }
26606
26607 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
26608         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
26609         return ret_conv;
26610 }
26611
26612 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
26613         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
26614         return ret_conv;
26615 }
26616
26617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26618         if ((this_ptr & 1) != 0) return;
26619         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26620         CHECK_ACCESS(this_ptr_ptr);
26621         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
26622         FREE((void*)this_ptr);
26623         KeysInterface_free(this_ptr_conv);
26624 }
26625
26626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26627         LDKInMemorySigner this_obj_conv;
26628         this_obj_conv.inner = (void*)(this_obj & (~1));
26629         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26631         InMemorySigner_free(this_obj_conv);
26632 }
26633
26634 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
26635         LDKInMemorySigner this_ptr_conv;
26636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26637         this_ptr_conv.is_owned = false;
26638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26639         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26640         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
26641         return ret_arr;
26642 }
26643
26644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26645         LDKInMemorySigner this_ptr_conv;
26646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26647         this_ptr_conv.is_owned = false;
26648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26649         LDKSecretKey val_ref;
26650         CHECK((*env)->GetArrayLength(env, val) == 32);
26651         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
26652         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
26653 }
26654
26655 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
26656         LDKInMemorySigner this_ptr_conv;
26657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26658         this_ptr_conv.is_owned = false;
26659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26660         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26661         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
26662         return ret_arr;
26663 }
26664
26665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26666         LDKInMemorySigner this_ptr_conv;
26667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26668         this_ptr_conv.is_owned = false;
26669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26670         LDKSecretKey val_ref;
26671         CHECK((*env)->GetArrayLength(env, val) == 32);
26672         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
26673         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
26674 }
26675
26676 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
26677         LDKInMemorySigner this_ptr_conv;
26678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26679         this_ptr_conv.is_owned = false;
26680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26681         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26682         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
26683         return ret_arr;
26684 }
26685
26686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26687         LDKInMemorySigner this_ptr_conv;
26688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26689         this_ptr_conv.is_owned = false;
26690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26691         LDKSecretKey val_ref;
26692         CHECK((*env)->GetArrayLength(env, val) == 32);
26693         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
26694         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
26695 }
26696
26697 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
26698         LDKInMemorySigner this_ptr_conv;
26699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26700         this_ptr_conv.is_owned = false;
26701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26702         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26703         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
26704         return ret_arr;
26705 }
26706
26707 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) {
26708         LDKInMemorySigner this_ptr_conv;
26709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26710         this_ptr_conv.is_owned = false;
26711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26712         LDKSecretKey val_ref;
26713         CHECK((*env)->GetArrayLength(env, val) == 32);
26714         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
26715         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
26716 }
26717
26718 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
26719         LDKInMemorySigner this_ptr_conv;
26720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26721         this_ptr_conv.is_owned = false;
26722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26723         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26724         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
26725         return ret_arr;
26726 }
26727
26728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26729         LDKInMemorySigner this_ptr_conv;
26730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26731         this_ptr_conv.is_owned = false;
26732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26733         LDKSecretKey val_ref;
26734         CHECK((*env)->GetArrayLength(env, val) == 32);
26735         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
26736         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
26737 }
26738
26739 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
26740         LDKInMemorySigner this_ptr_conv;
26741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26742         this_ptr_conv.is_owned = false;
26743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26744         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26745         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
26746         return ret_arr;
26747 }
26748
26749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26750         LDKInMemorySigner this_ptr_conv;
26751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26752         this_ptr_conv.is_owned = false;
26753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26754         LDKThirtyTwoBytes val_ref;
26755         CHECK((*env)->GetArrayLength(env, val) == 32);
26756         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26757         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
26758 }
26759
26760 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
26761         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
26762 uintptr_t ret_ref = 0;
26763 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26764 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26765 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26766 ret_ref = (uintptr_t)ret_var.inner;
26767 if (ret_var.is_owned) {
26768         ret_ref |= 1;
26769 }
26770         return ret_ref;
26771 }
26772 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26773         LDKInMemorySigner arg_conv;
26774         arg_conv.inner = (void*)(arg & (~1));
26775         arg_conv.is_owned = false;
26776         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26777         intptr_t ret_val = InMemorySigner_clone_ptr(&arg_conv);
26778         return ret_val;
26779 }
26780
26781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26782         LDKInMemorySigner orig_conv;
26783         orig_conv.inner = (void*)(orig & (~1));
26784         orig_conv.is_owned = false;
26785         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26786         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
26787         uintptr_t ret_ref = 0;
26788         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26789         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26791         ret_ref = (uintptr_t)ret_var.inner;
26792         if (ret_var.is_owned) {
26793                 ret_ref |= 1;
26794         }
26795         return ret_ref;
26796 }
26797
26798 JNIEXPORT 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) {
26799         LDKSecretKey node_secret_ref;
26800         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
26801         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
26802         LDKSecretKey funding_key_ref;
26803         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
26804         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
26805         LDKSecretKey revocation_base_key_ref;
26806         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
26807         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
26808         LDKSecretKey payment_key_ref;
26809         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
26810         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
26811         LDKSecretKey delayed_payment_base_key_ref;
26812         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
26813         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
26814         LDKSecretKey htlc_base_key_ref;
26815         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
26816         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
26817         LDKThirtyTwoBytes commitment_seed_ref;
26818         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
26819         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
26820         LDKThirtyTwoBytes channel_keys_id_ref;
26821         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
26822         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
26823         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);
26824         uintptr_t ret_ref = 0;
26825         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26826         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26827         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26828         ret_ref = (uintptr_t)ret_var.inner;
26829         if (ret_var.is_owned) {
26830                 ret_ref |= 1;
26831         }
26832         return ret_ref;
26833 }
26834
26835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
26836         LDKInMemorySigner this_arg_conv;
26837         this_arg_conv.inner = (void*)(this_arg & (~1));
26838         this_arg_conv.is_owned = false;
26839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26840         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
26841         uintptr_t ret_ref = 0;
26842         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26843         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26845         ret_ref = (uintptr_t)ret_var.inner;
26846         if (ret_var.is_owned) {
26847                 ret_ref |= 1;
26848         }
26849         return ret_ref;
26850 }
26851
26852 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
26853         LDKInMemorySigner this_arg_conv;
26854         this_arg_conv.inner = (void*)(this_arg & (~1));
26855         this_arg_conv.is_owned = false;
26856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26857         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
26858         return ret_val;
26859 }
26860
26861 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
26862         LDKInMemorySigner this_arg_conv;
26863         this_arg_conv.inner = (void*)(this_arg & (~1));
26864         this_arg_conv.is_owned = false;
26865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26866         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
26867         return ret_val;
26868 }
26869
26870 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
26871         LDKInMemorySigner this_arg_conv;
26872         this_arg_conv.inner = (void*)(this_arg & (~1));
26873         this_arg_conv.is_owned = false;
26874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26875         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
26876         return ret_val;
26877 }
26878
26879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
26880         LDKInMemorySigner this_arg_conv;
26881         this_arg_conv.inner = (void*)(this_arg & (~1));
26882         this_arg_conv.is_owned = false;
26883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26884         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
26885         uintptr_t ret_ref = 0;
26886         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26887         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26889         ret_ref = (uintptr_t)ret_var.inner;
26890         if (ret_var.is_owned) {
26891                 ret_ref |= 1;
26892         }
26893         return ret_ref;
26894 }
26895
26896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
26897         LDKInMemorySigner this_arg_conv;
26898         this_arg_conv.inner = (void*)(this_arg & (~1));
26899         this_arg_conv.is_owned = false;
26900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26901         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
26902         uintptr_t ret_ref = 0;
26903         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26904         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26906         ret_ref = (uintptr_t)ret_var.inner;
26907         if (ret_var.is_owned) {
26908                 ret_ref |= 1;
26909         }
26910         return ret_ref;
26911 }
26912
26913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
26914         LDKInMemorySigner this_arg_conv;
26915         this_arg_conv.inner = (void*)(this_arg & (~1));
26916         this_arg_conv.is_owned = false;
26917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26918         jboolean ret_val = InMemorySigner_opt_anchors(&this_arg_conv);
26919         return ret_val;
26920 }
26921
26922 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, intptr_t input_idx, int64_t descriptor) {
26923         LDKInMemorySigner this_arg_conv;
26924         this_arg_conv.inner = (void*)(this_arg & (~1));
26925         this_arg_conv.is_owned = false;
26926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26927         LDKTransaction spend_tx_ref;
26928         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
26929         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
26930         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
26931         spend_tx_ref.data_is_owned = true;
26932         LDKStaticPaymentOutputDescriptor descriptor_conv;
26933         descriptor_conv.inner = (void*)(descriptor & (~1));
26934         descriptor_conv.is_owned = false;
26935         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
26936         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
26937         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
26938         return (uintptr_t)ret_conv;
26939 }
26940
26941 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, intptr_t input_idx, int64_t descriptor) {
26942         LDKInMemorySigner this_arg_conv;
26943         this_arg_conv.inner = (void*)(this_arg & (~1));
26944         this_arg_conv.is_owned = false;
26945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26946         LDKTransaction spend_tx_ref;
26947         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
26948         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
26949         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
26950         spend_tx_ref.data_is_owned = true;
26951         LDKDelayedPaymentOutputDescriptor descriptor_conv;
26952         descriptor_conv.inner = (void*)(descriptor & (~1));
26953         descriptor_conv.is_owned = false;
26954         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
26955         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
26956         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
26957         return (uintptr_t)ret_conv;
26958 }
26959
26960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
26961         LDKInMemorySigner this_arg_conv;
26962         this_arg_conv.inner = (void*)(this_arg & (~1));
26963         this_arg_conv.is_owned = false;
26964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26965         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
26966         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
26967         return (uintptr_t)ret_ret;
26968 }
26969
26970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
26971         LDKInMemorySigner this_arg_conv;
26972         this_arg_conv.inner = (void*)(this_arg & (~1));
26973         this_arg_conv.is_owned = false;
26974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26975         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
26976         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
26977         return (uintptr_t)ret_ret;
26978 }
26979
26980 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
26981         LDKInMemorySigner obj_conv;
26982         obj_conv.inner = (void*)(obj & (~1));
26983         obj_conv.is_owned = false;
26984         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26985         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
26986         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26987         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26988         CVec_u8Z_free(ret_var);
26989         return ret_arr;
26990 }
26991
26992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
26993         LDKu8slice ser_ref;
26994         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26995         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26996         LDKSecretKey arg_ref;
26997         CHECK((*env)->GetArrayLength(env, arg) == 32);
26998         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
26999         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
27000         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
27001         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27002         return (uintptr_t)ret_conv;
27003 }
27004
27005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27006         LDKKeysManager this_obj_conv;
27007         this_obj_conv.inner = (void*)(this_obj & (~1));
27008         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27010         KeysManager_free(this_obj_conv);
27011 }
27012
27013 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) {
27014         unsigned char seed_arr[32];
27015         CHECK((*env)->GetArrayLength(env, seed) == 32);
27016         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
27017         unsigned char (*seed_ref)[32] = &seed_arr;
27018         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
27019         uintptr_t ret_ref = 0;
27020         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27021         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27023         ret_ref = (uintptr_t)ret_var.inner;
27024         if (ret_var.is_owned) {
27025                 ret_ref |= 1;
27026         }
27027         return ret_ref;
27028 }
27029
27030 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) {
27031         LDKKeysManager this_arg_conv;
27032         this_arg_conv.inner = (void*)(this_arg & (~1));
27033         this_arg_conv.is_owned = false;
27034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27035         unsigned char params_arr[32];
27036         CHECK((*env)->GetArrayLength(env, params) == 32);
27037         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
27038         unsigned char (*params_ref)[32] = &params_arr;
27039         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
27040         uintptr_t ret_ref = 0;
27041         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27042         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27044         ret_ref = (uintptr_t)ret_var.inner;
27045         if (ret_var.is_owned) {
27046                 ret_ref |= 1;
27047         }
27048         return ret_ref;
27049 }
27050
27051 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) {
27052         LDKKeysManager this_arg_conv;
27053         this_arg_conv.inner = (void*)(this_arg & (~1));
27054         this_arg_conv.is_owned = false;
27055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27056         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
27057         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
27058         if (descriptors_constr.datalen > 0)
27059                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
27060         else
27061                 descriptors_constr.data = NULL;
27062         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
27063         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
27064                 int64_t descriptors_conv_27 = descriptors_vals[b];
27065                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
27066                 CHECK_ACCESS(descriptors_conv_27_ptr);
27067                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
27068                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
27069                 descriptors_constr.data[b] = descriptors_conv_27_conv;
27070         }
27071         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
27072         LDKCVec_TxOutZ outputs_constr;
27073         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
27074         if (outputs_constr.datalen > 0)
27075                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
27076         else
27077                 outputs_constr.data = NULL;
27078         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
27079         for (size_t h = 0; h < outputs_constr.datalen; h++) {
27080                 int64_t outputs_conv_7 = outputs_vals[h];
27081                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
27082                 CHECK_ACCESS(outputs_conv_7_ptr);
27083                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
27084                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
27085                 outputs_constr.data[h] = outputs_conv_7_conv;
27086         }
27087         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
27088         LDKCVec_u8Z change_destination_script_ref;
27089         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
27090         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
27091         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
27092         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
27093         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
27094         return (uintptr_t)ret_conv;
27095 }
27096
27097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
27098         LDKKeysManager this_arg_conv;
27099         this_arg_conv.inner = (void*)(this_arg & (~1));
27100         this_arg_conv.is_owned = false;
27101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27102         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
27103         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
27104         return (uintptr_t)ret_ret;
27105 }
27106
27107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27108         LDKPhantomKeysManager this_obj_conv;
27109         this_obj_conv.inner = (void*)(this_obj & (~1));
27110         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27112         PhantomKeysManager_free(this_obj_conv);
27113 }
27114
27115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
27116         LDKPhantomKeysManager this_arg_conv;
27117         this_arg_conv.inner = (void*)(this_arg & (~1));
27118         this_arg_conv.is_owned = false;
27119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27120         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
27121         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
27122         return (uintptr_t)ret_ret;
27123 }
27124
27125 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) {
27126         unsigned char seed_arr[32];
27127         CHECK((*env)->GetArrayLength(env, seed) == 32);
27128         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
27129         unsigned char (*seed_ref)[32] = &seed_arr;
27130         unsigned char cross_node_seed_arr[32];
27131         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
27132         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
27133         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
27134         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
27135         uintptr_t ret_ref = 0;
27136         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27137         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27139         ret_ref = (uintptr_t)ret_var.inner;
27140         if (ret_var.is_owned) {
27141                 ret_ref |= 1;
27142         }
27143         return ret_ref;
27144 }
27145
27146 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) {
27147         LDKPhantomKeysManager this_arg_conv;
27148         this_arg_conv.inner = (void*)(this_arg & (~1));
27149         this_arg_conv.is_owned = false;
27150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27151         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
27152         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
27153         if (descriptors_constr.datalen > 0)
27154                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
27155         else
27156                 descriptors_constr.data = NULL;
27157         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
27158         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
27159                 int64_t descriptors_conv_27 = descriptors_vals[b];
27160                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
27161                 CHECK_ACCESS(descriptors_conv_27_ptr);
27162                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
27163                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
27164                 descriptors_constr.data[b] = descriptors_conv_27_conv;
27165         }
27166         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
27167         LDKCVec_TxOutZ outputs_constr;
27168         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
27169         if (outputs_constr.datalen > 0)
27170                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
27171         else
27172                 outputs_constr.data = NULL;
27173         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
27174         for (size_t h = 0; h < outputs_constr.datalen; h++) {
27175                 int64_t outputs_conv_7 = outputs_vals[h];
27176                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
27177                 CHECK_ACCESS(outputs_conv_7_ptr);
27178                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
27179                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
27180                 outputs_constr.data[h] = outputs_conv_7_conv;
27181         }
27182         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
27183         LDKCVec_u8Z change_destination_script_ref;
27184         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
27185         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
27186         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
27187         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
27188         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
27189         return (uintptr_t)ret_conv;
27190 }
27191
27192 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) {
27193         LDKPhantomKeysManager this_arg_conv;
27194         this_arg_conv.inner = (void*)(this_arg & (~1));
27195         this_arg_conv.is_owned = false;
27196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27197         unsigned char params_arr[32];
27198         CHECK((*env)->GetArrayLength(env, params) == 32);
27199         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
27200         unsigned char (*params_ref)[32] = &params_arr;
27201         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
27202         uintptr_t ret_ref = 0;
27203         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27204         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27206         ret_ref = (uintptr_t)ret_var.inner;
27207         if (ret_var.is_owned) {
27208                 ret_ref |= 1;
27209         }
27210         return ret_ref;
27211 }
27212
27213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27214         LDKChannelManager this_obj_conv;
27215         this_obj_conv.inner = (void*)(this_obj & (~1));
27216         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27218         ChannelManager_free(this_obj_conv);
27219 }
27220
27221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27222         LDKChainParameters this_obj_conv;
27223         this_obj_conv.inner = (void*)(this_obj & (~1));
27224         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27226         ChainParameters_free(this_obj_conv);
27227 }
27228
27229 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
27230         LDKChainParameters this_ptr_conv;
27231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27232         this_ptr_conv.is_owned = false;
27233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27234         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
27235         return ret_conv;
27236 }
27237
27238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
27239         LDKChainParameters this_ptr_conv;
27240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27241         this_ptr_conv.is_owned = false;
27242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27243         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
27244         ChainParameters_set_network(&this_ptr_conv, val_conv);
27245 }
27246
27247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
27248         LDKChainParameters this_ptr_conv;
27249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27250         this_ptr_conv.is_owned = false;
27251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27252         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
27253         uintptr_t ret_ref = 0;
27254         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27255         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27257         ret_ref = (uintptr_t)ret_var.inner;
27258         if (ret_var.is_owned) {
27259                 ret_ref |= 1;
27260         }
27261         return ret_ref;
27262 }
27263
27264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27265         LDKChainParameters this_ptr_conv;
27266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27267         this_ptr_conv.is_owned = false;
27268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27269         LDKBestBlock val_conv;
27270         val_conv.inner = (void*)(val & (~1));
27271         val_conv.is_owned = (val & 1) || (val == 0);
27272         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27273         val_conv = BestBlock_clone(&val_conv);
27274         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
27275 }
27276
27277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
27278         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
27279         LDKBestBlock best_block_arg_conv;
27280         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
27281         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
27282         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
27283         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
27284         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
27285         uintptr_t ret_ref = 0;
27286         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27287         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27289         ret_ref = (uintptr_t)ret_var.inner;
27290         if (ret_var.is_owned) {
27291                 ret_ref |= 1;
27292         }
27293         return ret_ref;
27294 }
27295
27296 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
27297         LDKChainParameters ret_var = ChainParameters_clone(arg);
27298 uintptr_t ret_ref = 0;
27299 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27300 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27301 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27302 ret_ref = (uintptr_t)ret_var.inner;
27303 if (ret_var.is_owned) {
27304         ret_ref |= 1;
27305 }
27306         return ret_ref;
27307 }
27308 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27309         LDKChainParameters arg_conv;
27310         arg_conv.inner = (void*)(arg & (~1));
27311         arg_conv.is_owned = false;
27312         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27313         intptr_t ret_val = ChainParameters_clone_ptr(&arg_conv);
27314         return ret_val;
27315 }
27316
27317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27318         LDKChainParameters orig_conv;
27319         orig_conv.inner = (void*)(orig & (~1));
27320         orig_conv.is_owned = false;
27321         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27322         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
27323         uintptr_t ret_ref = 0;
27324         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27325         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27327         ret_ref = (uintptr_t)ret_var.inner;
27328         if (ret_var.is_owned) {
27329                 ret_ref |= 1;
27330         }
27331         return ret_ref;
27332 }
27333
27334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27335         LDKCounterpartyForwardingInfo this_obj_conv;
27336         this_obj_conv.inner = (void*)(this_obj & (~1));
27337         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27339         CounterpartyForwardingInfo_free(this_obj_conv);
27340 }
27341
27342 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27343         LDKCounterpartyForwardingInfo this_ptr_conv;
27344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27345         this_ptr_conv.is_owned = false;
27346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27347         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
27348         return ret_val;
27349 }
27350
27351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27352         LDKCounterpartyForwardingInfo this_ptr_conv;
27353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27354         this_ptr_conv.is_owned = false;
27355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27356         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
27357 }
27358
27359 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
27360         LDKCounterpartyForwardingInfo this_ptr_conv;
27361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27362         this_ptr_conv.is_owned = false;
27363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27364         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
27365         return ret_val;
27366 }
27367
27368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27369         LDKCounterpartyForwardingInfo this_ptr_conv;
27370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27371         this_ptr_conv.is_owned = false;
27372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27373         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
27374 }
27375
27376 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
27377         LDKCounterpartyForwardingInfo this_ptr_conv;
27378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27379         this_ptr_conv.is_owned = false;
27380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27381         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
27382         return ret_val;
27383 }
27384
27385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27386         LDKCounterpartyForwardingInfo this_ptr_conv;
27387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27388         this_ptr_conv.is_owned = false;
27389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27390         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
27391 }
27392
27393 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) {
27394         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
27395         uintptr_t ret_ref = 0;
27396         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27397         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27398         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27399         ret_ref = (uintptr_t)ret_var.inner;
27400         if (ret_var.is_owned) {
27401                 ret_ref |= 1;
27402         }
27403         return ret_ref;
27404 }
27405
27406 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
27407         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
27408 uintptr_t ret_ref = 0;
27409 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27410 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27411 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27412 ret_ref = (uintptr_t)ret_var.inner;
27413 if (ret_var.is_owned) {
27414         ret_ref |= 1;
27415 }
27416         return ret_ref;
27417 }
27418 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27419         LDKCounterpartyForwardingInfo arg_conv;
27420         arg_conv.inner = (void*)(arg & (~1));
27421         arg_conv.is_owned = false;
27422         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27423         intptr_t ret_val = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
27424         return ret_val;
27425 }
27426
27427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27428         LDKCounterpartyForwardingInfo orig_conv;
27429         orig_conv.inner = (void*)(orig & (~1));
27430         orig_conv.is_owned = false;
27431         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27432         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
27433         uintptr_t ret_ref = 0;
27434         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27435         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27437         ret_ref = (uintptr_t)ret_var.inner;
27438         if (ret_var.is_owned) {
27439                 ret_ref |= 1;
27440         }
27441         return ret_ref;
27442 }
27443
27444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27445         LDKChannelCounterparty this_obj_conv;
27446         this_obj_conv.inner = (void*)(this_obj & (~1));
27447         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27449         ChannelCounterparty_free(this_obj_conv);
27450 }
27451
27452 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27453         LDKChannelCounterparty this_ptr_conv;
27454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27455         this_ptr_conv.is_owned = false;
27456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27457         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27458         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
27459         return ret_arr;
27460 }
27461
27462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27463         LDKChannelCounterparty this_ptr_conv;
27464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27465         this_ptr_conv.is_owned = false;
27466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27467         LDKPublicKey val_ref;
27468         CHECK((*env)->GetArrayLength(env, val) == 33);
27469         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27470         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
27471 }
27472
27473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
27474         LDKChannelCounterparty this_ptr_conv;
27475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27476         this_ptr_conv.is_owned = false;
27477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27478         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
27479         uintptr_t ret_ref = 0;
27480         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27481         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27483         ret_ref = (uintptr_t)ret_var.inner;
27484         if (ret_var.is_owned) {
27485                 ret_ref |= 1;
27486         }
27487         return ret_ref;
27488 }
27489
27490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27491         LDKChannelCounterparty this_ptr_conv;
27492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27493         this_ptr_conv.is_owned = false;
27494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27495         LDKInitFeatures val_conv;
27496         val_conv.inner = (void*)(val & (~1));
27497         val_conv.is_owned = (val & 1) || (val == 0);
27498         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27499         val_conv = InitFeatures_clone(&val_conv);
27500         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
27501 }
27502
27503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
27504         LDKChannelCounterparty this_ptr_conv;
27505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27506         this_ptr_conv.is_owned = false;
27507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27508         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
27509         return ret_val;
27510 }
27511
27512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27513         LDKChannelCounterparty this_ptr_conv;
27514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27515         this_ptr_conv.is_owned = false;
27516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27517         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
27518 }
27519
27520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
27521         LDKChannelCounterparty this_ptr_conv;
27522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27523         this_ptr_conv.is_owned = false;
27524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27525         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
27526         uintptr_t ret_ref = 0;
27527         if ((uintptr_t)ret_var.inner > 4096) {
27528                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27529                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27531                 ret_ref = (uintptr_t)ret_var.inner;
27532                 if (ret_var.is_owned) {
27533                         ret_ref |= 1;
27534                 }
27535         }
27536         return ret_ref;
27537 }
27538
27539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27540         LDKChannelCounterparty this_ptr_conv;
27541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27542         this_ptr_conv.is_owned = false;
27543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27544         LDKCounterpartyForwardingInfo val_conv;
27545         val_conv.inner = (void*)(val & (~1));
27546         val_conv.is_owned = (val & 1) || (val == 0);
27547         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27548         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
27549         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
27550 }
27551
27552 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) {
27553         LDKPublicKey node_id_arg_ref;
27554         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
27555         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
27556         LDKInitFeatures features_arg_conv;
27557         features_arg_conv.inner = (void*)(features_arg & (~1));
27558         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
27559         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
27560         features_arg_conv = InitFeatures_clone(&features_arg_conv);
27561         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
27562         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
27563         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
27564         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
27565         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
27566         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
27567         uintptr_t ret_ref = 0;
27568         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27569         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27571         ret_ref = (uintptr_t)ret_var.inner;
27572         if (ret_var.is_owned) {
27573                 ret_ref |= 1;
27574         }
27575         return ret_ref;
27576 }
27577
27578 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
27579         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
27580 uintptr_t ret_ref = 0;
27581 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27582 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27583 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27584 ret_ref = (uintptr_t)ret_var.inner;
27585 if (ret_var.is_owned) {
27586         ret_ref |= 1;
27587 }
27588         return ret_ref;
27589 }
27590 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27591         LDKChannelCounterparty arg_conv;
27592         arg_conv.inner = (void*)(arg & (~1));
27593         arg_conv.is_owned = false;
27594         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27595         intptr_t ret_val = ChannelCounterparty_clone_ptr(&arg_conv);
27596         return ret_val;
27597 }
27598
27599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27600         LDKChannelCounterparty orig_conv;
27601         orig_conv.inner = (void*)(orig & (~1));
27602         orig_conv.is_owned = false;
27603         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27604         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
27605         uintptr_t ret_ref = 0;
27606         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27607         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27609         ret_ref = (uintptr_t)ret_var.inner;
27610         if (ret_var.is_owned) {
27611                 ret_ref |= 1;
27612         }
27613         return ret_ref;
27614 }
27615
27616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27617         LDKChannelDetails this_obj_conv;
27618         this_obj_conv.inner = (void*)(this_obj & (~1));
27619         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27621         ChannelDetails_free(this_obj_conv);
27622 }
27623
27624 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27625         LDKChannelDetails this_ptr_conv;
27626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27627         this_ptr_conv.is_owned = false;
27628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27629         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27630         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
27631         return ret_arr;
27632 }
27633
27634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27635         LDKChannelDetails this_ptr_conv;
27636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27637         this_ptr_conv.is_owned = false;
27638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27639         LDKThirtyTwoBytes val_ref;
27640         CHECK((*env)->GetArrayLength(env, val) == 32);
27641         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27642         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
27643 }
27644
27645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
27646         LDKChannelDetails this_ptr_conv;
27647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27648         this_ptr_conv.is_owned = false;
27649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27650         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
27651         uintptr_t ret_ref = 0;
27652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27655         ret_ref = (uintptr_t)ret_var.inner;
27656         if (ret_var.is_owned) {
27657                 ret_ref |= 1;
27658         }
27659         return ret_ref;
27660 }
27661
27662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27663         LDKChannelDetails this_ptr_conv;
27664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27665         this_ptr_conv.is_owned = false;
27666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27667         LDKChannelCounterparty val_conv;
27668         val_conv.inner = (void*)(val & (~1));
27669         val_conv.is_owned = (val & 1) || (val == 0);
27670         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27671         val_conv = ChannelCounterparty_clone(&val_conv);
27672         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
27673 }
27674
27675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
27676         LDKChannelDetails this_ptr_conv;
27677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27678         this_ptr_conv.is_owned = false;
27679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27680         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
27681         uintptr_t ret_ref = 0;
27682         if ((uintptr_t)ret_var.inner > 4096) {
27683                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27684                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27686                 ret_ref = (uintptr_t)ret_var.inner;
27687                 if (ret_var.is_owned) {
27688                         ret_ref |= 1;
27689                 }
27690         }
27691         return ret_ref;
27692 }
27693
27694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27695         LDKChannelDetails this_ptr_conv;
27696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27697         this_ptr_conv.is_owned = false;
27698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27699         LDKOutPoint val_conv;
27700         val_conv.inner = (void*)(val & (~1));
27701         val_conv.is_owned = (val & 1) || (val == 0);
27702         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27703         val_conv = OutPoint_clone(&val_conv);
27704         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
27705 }
27706
27707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27708         LDKChannelDetails this_ptr_conv;
27709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27710         this_ptr_conv.is_owned = false;
27711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27712         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27713         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
27714         uintptr_t ret_ref = (uintptr_t)ret_copy;
27715         return ret_ref;
27716 }
27717
27718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27719         LDKChannelDetails this_ptr_conv;
27720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27721         this_ptr_conv.is_owned = false;
27722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27723         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27724         CHECK_ACCESS(val_ptr);
27725         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
27726         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
27727         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
27728 }
27729
27730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27731         LDKChannelDetails this_ptr_conv;
27732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27733         this_ptr_conv.is_owned = false;
27734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27735         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
27736         return ret_val;
27737 }
27738
27739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27740         LDKChannelDetails this_ptr_conv;
27741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27742         this_ptr_conv.is_owned = false;
27743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27744         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
27745 }
27746
27747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
27748         LDKChannelDetails this_ptr_conv;
27749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27750         this_ptr_conv.is_owned = false;
27751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27752         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27753         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
27754         uintptr_t ret_ref = (uintptr_t)ret_copy;
27755         return ret_ref;
27756 }
27757
27758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27759         LDKChannelDetails this_ptr_conv;
27760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27761         this_ptr_conv.is_owned = false;
27762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27763         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27764         CHECK_ACCESS(val_ptr);
27765         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
27766         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
27767         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
27768 }
27769
27770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27771         LDKChannelDetails this_ptr_conv;
27772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27773         this_ptr_conv.is_owned = false;
27774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27775         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
27776         return ret_val;
27777 }
27778
27779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27780         LDKChannelDetails this_ptr_conv;
27781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27782         this_ptr_conv.is_owned = false;
27783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27784         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
27785 }
27786
27787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27788         LDKChannelDetails this_ptr_conv;
27789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27790         this_ptr_conv.is_owned = false;
27791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27792         int64_t ret_val = ChannelDetails_get_balance_msat(&this_ptr_conv);
27793         return ret_val;
27794 }
27795
27796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27797         LDKChannelDetails this_ptr_conv;
27798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27799         this_ptr_conv.is_owned = false;
27800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27801         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
27802 }
27803
27804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27805         LDKChannelDetails this_ptr_conv;
27806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27807         this_ptr_conv.is_owned = false;
27808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27809         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
27810         return ret_val;
27811 }
27812
27813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27814         LDKChannelDetails this_ptr_conv;
27815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27816         this_ptr_conv.is_owned = false;
27817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27818         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
27819 }
27820
27821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27822         LDKChannelDetails this_ptr_conv;
27823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27824         this_ptr_conv.is_owned = false;
27825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27826         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
27827         return ret_val;
27828 }
27829
27830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27831         LDKChannelDetails this_ptr_conv;
27832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27833         this_ptr_conv.is_owned = false;
27834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27835         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
27836 }
27837
27838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
27839         LDKChannelDetails this_ptr_conv;
27840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27841         this_ptr_conv.is_owned = false;
27842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27843         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
27844         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
27845         uintptr_t ret_ref = (uintptr_t)ret_copy;
27846         return ret_ref;
27847 }
27848
27849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27850         LDKChannelDetails this_ptr_conv;
27851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27852         this_ptr_conv.is_owned = false;
27853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27854         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27855         CHECK_ACCESS(val_ptr);
27856         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
27857         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
27858         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
27859 }
27860
27861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
27862         LDKChannelDetails this_ptr_conv;
27863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27864         this_ptr_conv.is_owned = false;
27865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27866         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
27867         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
27868         uintptr_t ret_ref = (uintptr_t)ret_copy;
27869         return ret_ref;
27870 }
27871
27872 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) {
27873         LDKChannelDetails this_ptr_conv;
27874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27875         this_ptr_conv.is_owned = false;
27876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27877         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27878         CHECK_ACCESS(val_ptr);
27879         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
27880         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
27881         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
27882 }
27883
27884 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
27885         LDKChannelDetails this_ptr_conv;
27886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27887         this_ptr_conv.is_owned = false;
27888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27889         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
27890         return ret_val;
27891 }
27892
27893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27894         LDKChannelDetails this_ptr_conv;
27895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27896         this_ptr_conv.is_owned = false;
27897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27898         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
27899 }
27900
27901 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
27902         LDKChannelDetails this_ptr_conv;
27903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27904         this_ptr_conv.is_owned = false;
27905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27906         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
27907         return ret_val;
27908 }
27909
27910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27911         LDKChannelDetails this_ptr_conv;
27912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27913         this_ptr_conv.is_owned = false;
27914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27915         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
27916 }
27917
27918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
27919         LDKChannelDetails this_ptr_conv;
27920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27921         this_ptr_conv.is_owned = false;
27922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27923         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
27924         return ret_val;
27925 }
27926
27927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27928         LDKChannelDetails this_ptr_conv;
27929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27930         this_ptr_conv.is_owned = false;
27931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27932         ChannelDetails_set_is_usable(&this_ptr_conv, val);
27933 }
27934
27935 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
27936         LDKChannelDetails this_ptr_conv;
27937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27938         this_ptr_conv.is_owned = false;
27939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27940         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
27941         return ret_val;
27942 }
27943
27944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27945         LDKChannelDetails this_ptr_conv;
27946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27947         this_ptr_conv.is_owned = false;
27948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27949         ChannelDetails_set_is_public(&this_ptr_conv, val);
27950 }
27951
27952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t short_channel_id_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t balance_msat_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
27953         LDKThirtyTwoBytes channel_id_arg_ref;
27954         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
27955         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
27956         LDKChannelCounterparty counterparty_arg_conv;
27957         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
27958         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
27959         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
27960         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
27961         LDKOutPoint funding_txo_arg_conv;
27962         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
27963         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
27964         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
27965         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
27966         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
27967         CHECK_ACCESS(short_channel_id_arg_ptr);
27968         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
27969         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
27970         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
27971         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
27972         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
27973         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
27974         CHECK_ACCESS(confirmations_required_arg_ptr);
27975         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
27976         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
27977         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
27978         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
27979         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
27980         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
27981         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, balance_msat_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
27982         uintptr_t ret_ref = 0;
27983         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27984         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27986         ret_ref = (uintptr_t)ret_var.inner;
27987         if (ret_var.is_owned) {
27988                 ret_ref |= 1;
27989         }
27990         return ret_ref;
27991 }
27992
27993 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
27994         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
27995 uintptr_t ret_ref = 0;
27996 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27997 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27998 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27999 ret_ref = (uintptr_t)ret_var.inner;
28000 if (ret_var.is_owned) {
28001         ret_ref |= 1;
28002 }
28003         return ret_ref;
28004 }
28005 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28006         LDKChannelDetails arg_conv;
28007         arg_conv.inner = (void*)(arg & (~1));
28008         arg_conv.is_owned = false;
28009         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28010         intptr_t ret_val = ChannelDetails_clone_ptr(&arg_conv);
28011         return ret_val;
28012 }
28013
28014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28015         LDKChannelDetails orig_conv;
28016         orig_conv.inner = (void*)(orig & (~1));
28017         orig_conv.is_owned = false;
28018         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28019         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
28020         uintptr_t ret_ref = 0;
28021         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28022         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28024         ret_ref = (uintptr_t)ret_var.inner;
28025         if (ret_var.is_owned) {
28026                 ret_ref |= 1;
28027         }
28028         return ret_ref;
28029 }
28030
28031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28032         if ((this_ptr & 1) != 0) return;
28033         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28034         CHECK_ACCESS(this_ptr_ptr);
28035         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
28036         FREE((void*)this_ptr);
28037         PaymentSendFailure_free(this_ptr_conv);
28038 }
28039
28040 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
28041         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28042         *ret_copy = PaymentSendFailure_clone(arg);
28043 uintptr_t ret_ref = (uintptr_t)ret_copy;
28044         return ret_ref;
28045 }
28046 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28047         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
28048         intptr_t ret_val = PaymentSendFailure_clone_ptr(arg_conv);
28049         return ret_val;
28050 }
28051
28052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28053         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
28054         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28055         *ret_copy = PaymentSendFailure_clone(orig_conv);
28056         uintptr_t ret_ref = (uintptr_t)ret_copy;
28057         return ret_ref;
28058 }
28059
28060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
28061         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
28062         CHECK_ACCESS(a_ptr);
28063         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
28064         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
28065         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28066         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
28067         uintptr_t ret_ref = (uintptr_t)ret_copy;
28068         return ret_ref;
28069 }
28070
28071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
28072         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
28073         a_constr.datalen = (*env)->GetArrayLength(env, a);
28074         if (a_constr.datalen > 0)
28075                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
28076         else
28077                 a_constr.data = NULL;
28078         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
28079         for (size_t w = 0; w < a_constr.datalen; w++) {
28080                 int64_t a_conv_22 = a_vals[w];
28081                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
28082                 CHECK_ACCESS(a_conv_22_ptr);
28083                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
28084                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
28085                 a_constr.data[w] = a_conv_22_conv;
28086         }
28087         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
28088         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28089         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
28090         uintptr_t ret_ref = (uintptr_t)ret_copy;
28091         return ret_ref;
28092 }
28093
28094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
28095         LDKCVec_APIErrorZ a_constr;
28096         a_constr.datalen = (*env)->GetArrayLength(env, a);
28097         if (a_constr.datalen > 0)
28098                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
28099         else
28100                 a_constr.data = NULL;
28101         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
28102         for (size_t k = 0; k < a_constr.datalen; k++) {
28103                 int64_t a_conv_10 = a_vals[k];
28104                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
28105                 CHECK_ACCESS(a_conv_10_ptr);
28106                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
28107                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
28108                 a_constr.data[k] = a_conv_10_conv;
28109         }
28110         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
28111         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28112         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
28113         uintptr_t ret_ref = (uintptr_t)ret_copy;
28114         return ret_ref;
28115 }
28116
28117 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) {
28118         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
28119         results_constr.datalen = (*env)->GetArrayLength(env, results);
28120         if (results_constr.datalen > 0)
28121                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
28122         else
28123                 results_constr.data = NULL;
28124         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
28125         for (size_t w = 0; w < results_constr.datalen; w++) {
28126                 int64_t results_conv_22 = results_vals[w];
28127                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
28128                 CHECK_ACCESS(results_conv_22_ptr);
28129                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
28130                 results_constr.data[w] = results_conv_22_conv;
28131         }
28132         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
28133         LDKRouteParameters failed_paths_retry_conv;
28134         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
28135         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
28136         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
28137         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
28138         LDKThirtyTwoBytes payment_id_ref;
28139         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
28140         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
28141         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28142         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
28143         uintptr_t ret_ref = (uintptr_t)ret_copy;
28144         return ret_ref;
28145 }
28146
28147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28148         LDKPhantomRouteHints this_obj_conv;
28149         this_obj_conv.inner = (void*)(this_obj & (~1));
28150         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28152         PhantomRouteHints_free(this_obj_conv);
28153 }
28154
28155 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28156         LDKPhantomRouteHints this_ptr_conv;
28157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28158         this_ptr_conv.is_owned = false;
28159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28160         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
28161         int64_tArray ret_arr = NULL;
28162         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28163         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28164         for (size_t q = 0; q < ret_var.datalen; q++) {
28165                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
28166                 uintptr_t ret_conv_16_ref = 0;
28167                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28168                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28169                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
28170                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
28171                 if (ret_conv_16_var.is_owned) {
28172                         ret_conv_16_ref |= 1;
28173                 }
28174                 ret_arr_ptr[q] = ret_conv_16_ref;
28175         }
28176         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28177         FREE(ret_var.data);
28178         return ret_arr;
28179 }
28180
28181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
28182         LDKPhantomRouteHints this_ptr_conv;
28183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28184         this_ptr_conv.is_owned = false;
28185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28186         LDKCVec_ChannelDetailsZ val_constr;
28187         val_constr.datalen = (*env)->GetArrayLength(env, val);
28188         if (val_constr.datalen > 0)
28189                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
28190         else
28191                 val_constr.data = NULL;
28192         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
28193         for (size_t q = 0; q < val_constr.datalen; q++) {
28194                 int64_t val_conv_16 = val_vals[q];
28195                 LDKChannelDetails val_conv_16_conv;
28196                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
28197                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
28198                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
28199                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
28200                 val_constr.data[q] = val_conv_16_conv;
28201         }
28202         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
28203         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
28204 }
28205
28206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
28207         LDKPhantomRouteHints this_ptr_conv;
28208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28209         this_ptr_conv.is_owned = false;
28210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28211         int64_t ret_val = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
28212         return ret_val;
28213 }
28214
28215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28216         LDKPhantomRouteHints this_ptr_conv;
28217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28218         this_ptr_conv.is_owned = false;
28219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28220         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
28221 }
28222
28223 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28224         LDKPhantomRouteHints this_ptr_conv;
28225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28226         this_ptr_conv.is_owned = false;
28227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28228         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28229         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
28230         return ret_arr;
28231 }
28232
28233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28234         LDKPhantomRouteHints this_ptr_conv;
28235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28236         this_ptr_conv.is_owned = false;
28237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28238         LDKPublicKey val_ref;
28239         CHECK((*env)->GetArrayLength(env, val) == 33);
28240         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28241         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
28242 }
28243
28244 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) {
28245         LDKCVec_ChannelDetailsZ channels_arg_constr;
28246         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
28247         if (channels_arg_constr.datalen > 0)
28248                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
28249         else
28250                 channels_arg_constr.data = NULL;
28251         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
28252         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
28253                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
28254                 LDKChannelDetails channels_arg_conv_16_conv;
28255                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
28256                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
28257                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
28258                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
28259                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
28260         }
28261         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
28262         LDKPublicKey real_node_pubkey_arg_ref;
28263         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
28264         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
28265         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
28266         uintptr_t ret_ref = 0;
28267         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28268         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28270         ret_ref = (uintptr_t)ret_var.inner;
28271         if (ret_var.is_owned) {
28272                 ret_ref |= 1;
28273         }
28274         return ret_ref;
28275 }
28276
28277 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
28278         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
28279 uintptr_t ret_ref = 0;
28280 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28281 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28282 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28283 ret_ref = (uintptr_t)ret_var.inner;
28284 if (ret_var.is_owned) {
28285         ret_ref |= 1;
28286 }
28287         return ret_ref;
28288 }
28289 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28290         LDKPhantomRouteHints arg_conv;
28291         arg_conv.inner = (void*)(arg & (~1));
28292         arg_conv.is_owned = false;
28293         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28294         intptr_t ret_val = PhantomRouteHints_clone_ptr(&arg_conv);
28295         return ret_val;
28296 }
28297
28298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28299         LDKPhantomRouteHints orig_conv;
28300         orig_conv.inner = (void*)(orig & (~1));
28301         orig_conv.is_owned = false;
28302         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28303         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
28304         uintptr_t ret_ref = 0;
28305         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28306         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28307         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28308         ret_ref = (uintptr_t)ret_var.inner;
28309         if (ret_var.is_owned) {
28310                 ret_ref |= 1;
28311         }
28312         return ret_ref;
28313 }
28314
28315 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) {
28316         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
28317         CHECK_ACCESS(fee_est_ptr);
28318         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
28319         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
28320                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28321                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
28322         }
28323         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
28324         CHECK_ACCESS(chain_monitor_ptr);
28325         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
28326         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
28327                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28328                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
28329         }
28330         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
28331         CHECK_ACCESS(tx_broadcaster_ptr);
28332         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
28333         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28334                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28335                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
28336         }
28337         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
28338         CHECK_ACCESS(logger_ptr);
28339         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28340         if (logger_conv.free == LDKLogger_JCalls_free) {
28341                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28342                 LDKLogger_JCalls_cloned(&logger_conv);
28343         }
28344         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
28345         CHECK_ACCESS(keys_manager_ptr);
28346         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
28347         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
28348                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28349                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
28350         }
28351         LDKUserConfig config_conv;
28352         config_conv.inner = (void*)(config & (~1));
28353         config_conv.is_owned = (config & 1) || (config == 0);
28354         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
28355         config_conv = UserConfig_clone(&config_conv);
28356         LDKChainParameters params_conv;
28357         params_conv.inner = (void*)(params & (~1));
28358         params_conv.is_owned = (params & 1) || (params == 0);
28359         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
28360         params_conv = ChainParameters_clone(&params_conv);
28361         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
28362         uintptr_t ret_ref = 0;
28363         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28364         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28366         ret_ref = (uintptr_t)ret_var.inner;
28367         if (ret_var.is_owned) {
28368                 ret_ref |= 1;
28369         }
28370         return ret_ref;
28371 }
28372
28373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
28374         LDKChannelManager this_arg_conv;
28375         this_arg_conv.inner = (void*)(this_arg & (~1));
28376         this_arg_conv.is_owned = false;
28377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28378         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
28379         uintptr_t ret_ref = 0;
28380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28383         ret_ref = (uintptr_t)ret_var.inner;
28384         if (ret_var.is_owned) {
28385                 ret_ref |= 1;
28386         }
28387         return ret_ref;
28388 }
28389
28390 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) {
28391         LDKChannelManager this_arg_conv;
28392         this_arg_conv.inner = (void*)(this_arg & (~1));
28393         this_arg_conv.is_owned = false;
28394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28395         LDKPublicKey their_network_key_ref;
28396         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
28397         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
28398         LDKUserConfig override_config_conv;
28399         override_config_conv.inner = (void*)(override_config & (~1));
28400         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
28401         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
28402         override_config_conv = UserConfig_clone(&override_config_conv);
28403         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
28404         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
28405         return (uintptr_t)ret_conv;
28406 }
28407
28408 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
28409         LDKChannelManager this_arg_conv;
28410         this_arg_conv.inner = (void*)(this_arg & (~1));
28411         this_arg_conv.is_owned = false;
28412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28413         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
28414         int64_tArray ret_arr = NULL;
28415         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28416         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28417         for (size_t q = 0; q < ret_var.datalen; q++) {
28418                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
28419                 uintptr_t ret_conv_16_ref = 0;
28420                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28421                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28422                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
28423                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
28424                 if (ret_conv_16_var.is_owned) {
28425                         ret_conv_16_ref |= 1;
28426                 }
28427                 ret_arr_ptr[q] = ret_conv_16_ref;
28428         }
28429         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28430         FREE(ret_var.data);
28431         return ret_arr;
28432 }
28433
28434 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
28435         LDKChannelManager this_arg_conv;
28436         this_arg_conv.inner = (void*)(this_arg & (~1));
28437         this_arg_conv.is_owned = false;
28438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28439         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
28440         int64_tArray ret_arr = NULL;
28441         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28442         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28443         for (size_t q = 0; q < ret_var.datalen; q++) {
28444                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
28445                 uintptr_t ret_conv_16_ref = 0;
28446                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28447                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28448                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
28449                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
28450                 if (ret_conv_16_var.is_owned) {
28451                         ret_conv_16_ref |= 1;
28452                 }
28453                 ret_arr_ptr[q] = ret_conv_16_ref;
28454         }
28455         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28456         FREE(ret_var.data);
28457         return ret_arr;
28458 }
28459
28460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
28461         LDKChannelManager this_arg_conv;
28462         this_arg_conv.inner = (void*)(this_arg & (~1));
28463         this_arg_conv.is_owned = false;
28464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28465         unsigned char channel_id_arr[32];
28466         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
28467         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
28468         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
28469         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
28470         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
28471         return (uintptr_t)ret_conv;
28472 }
28473
28474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel_1with_1target_1feerate(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int32_t target_feerate_sats_per_1000_weight) {
28475         LDKChannelManager this_arg_conv;
28476         this_arg_conv.inner = (void*)(this_arg & (~1));
28477         this_arg_conv.is_owned = false;
28478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28479         unsigned char channel_id_arr[32];
28480         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
28481         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
28482         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
28483         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
28484         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
28485         return (uintptr_t)ret_conv;
28486 }
28487
28488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
28489         LDKChannelManager this_arg_conv;
28490         this_arg_conv.inner = (void*)(this_arg & (~1));
28491         this_arg_conv.is_owned = false;
28492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28493         unsigned char channel_id_arr[32];
28494         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
28495         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
28496         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
28497         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
28498         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
28499         return (uintptr_t)ret_conv;
28500 }
28501
28502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
28503         LDKChannelManager this_arg_conv;
28504         this_arg_conv.inner = (void*)(this_arg & (~1));
28505         this_arg_conv.is_owned = false;
28506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28507         ChannelManager_force_close_all_channels(&this_arg_conv);
28508 }
28509
28510 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) {
28511         LDKChannelManager this_arg_conv;
28512         this_arg_conv.inner = (void*)(this_arg & (~1));
28513         this_arg_conv.is_owned = false;
28514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28515         LDKRoute route_conv;
28516         route_conv.inner = (void*)(route & (~1));
28517         route_conv.is_owned = false;
28518         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
28519         LDKThirtyTwoBytes payment_hash_ref;
28520         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
28521         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
28522         LDKThirtyTwoBytes payment_secret_ref;
28523         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
28524         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
28525         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
28526         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
28527         return (uintptr_t)ret_conv;
28528 }
28529
28530 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) {
28531         LDKChannelManager this_arg_conv;
28532         this_arg_conv.inner = (void*)(this_arg & (~1));
28533         this_arg_conv.is_owned = false;
28534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28535         LDKRoute route_conv;
28536         route_conv.inner = (void*)(route & (~1));
28537         route_conv.is_owned = false;
28538         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
28539         LDKThirtyTwoBytes payment_id_ref;
28540         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
28541         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
28542         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
28543         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
28544         return (uintptr_t)ret_conv;
28545 }
28546
28547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
28548         LDKChannelManager this_arg_conv;
28549         this_arg_conv.inner = (void*)(this_arg & (~1));
28550         this_arg_conv.is_owned = false;
28551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28552         LDKThirtyTwoBytes payment_id_ref;
28553         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
28554         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
28555         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
28556 }
28557
28558 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) {
28559         LDKChannelManager this_arg_conv;
28560         this_arg_conv.inner = (void*)(this_arg & (~1));
28561         this_arg_conv.is_owned = false;
28562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28563         LDKRoute route_conv;
28564         route_conv.inner = (void*)(route & (~1));
28565         route_conv.is_owned = false;
28566         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
28567         LDKThirtyTwoBytes payment_preimage_ref;
28568         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
28569         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
28570         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
28571         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
28572         return (uintptr_t)ret_conv;
28573 }
28574
28575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1funding_1transaction_1generated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
28576         LDKChannelManager this_arg_conv;
28577         this_arg_conv.inner = (void*)(this_arg & (~1));
28578         this_arg_conv.is_owned = false;
28579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28580         unsigned char temporary_channel_id_arr[32];
28581         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
28582         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
28583         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
28584         LDKTransaction funding_transaction_ref;
28585         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
28586         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
28587         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
28588         funding_transaction_ref.data_is_owned = true;
28589         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
28590         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
28591         return (uintptr_t)ret_conv;
28592 }
28593
28594 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) {
28595         LDKChannelManager this_arg_conv;
28596         this_arg_conv.inner = (void*)(this_arg & (~1));
28597         this_arg_conv.is_owned = false;
28598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28599         LDKThreeBytes rgb_ref;
28600         CHECK((*env)->GetArrayLength(env, rgb) == 3);
28601         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
28602         LDKThirtyTwoBytes alias_ref;
28603         CHECK((*env)->GetArrayLength(env, alias) == 32);
28604         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
28605         LDKCVec_NetAddressZ addresses_constr;
28606         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
28607         if (addresses_constr.datalen > 0)
28608                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
28609         else
28610                 addresses_constr.data = NULL;
28611         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
28612         for (size_t m = 0; m < addresses_constr.datalen; m++) {
28613                 int64_t addresses_conv_12 = addresses_vals[m];
28614                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
28615                 CHECK_ACCESS(addresses_conv_12_ptr);
28616                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
28617                 addresses_constr.data[m] = addresses_conv_12_conv;
28618         }
28619         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
28620         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
28621 }
28622
28623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
28624         LDKChannelManager this_arg_conv;
28625         this_arg_conv.inner = (void*)(this_arg & (~1));
28626         this_arg_conv.is_owned = false;
28627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28628         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
28629 }
28630
28631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
28632         LDKChannelManager this_arg_conv;
28633         this_arg_conv.inner = (void*)(this_arg & (~1));
28634         this_arg_conv.is_owned = false;
28635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28636         ChannelManager_timer_tick_occurred(&this_arg_conv);
28637 }
28638
28639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
28640         LDKChannelManager this_arg_conv;
28641         this_arg_conv.inner = (void*)(this_arg & (~1));
28642         this_arg_conv.is_owned = false;
28643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28644         unsigned char payment_hash_arr[32];
28645         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
28646         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
28647         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
28648         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
28649         return ret_val;
28650 }
28651
28652 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
28653         LDKChannelManager this_arg_conv;
28654         this_arg_conv.inner = (void*)(this_arg & (~1));
28655         this_arg_conv.is_owned = false;
28656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28657         LDKThirtyTwoBytes payment_preimage_ref;
28658         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
28659         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
28660         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
28661         return ret_val;
28662 }
28663
28664 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
28665         LDKChannelManager this_arg_conv;
28666         this_arg_conv.inner = (void*)(this_arg & (~1));
28667         this_arg_conv.is_owned = false;
28668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28669         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28670         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
28671         return ret_arr;
28672 }
28673
28674 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) {
28675         LDKChannelManager this_arg_conv;
28676         this_arg_conv.inner = (void*)(this_arg & (~1));
28677         this_arg_conv.is_owned = false;
28678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28679         unsigned char temporary_channel_id_arr[32];
28680         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
28681         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
28682         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
28683         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
28684         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref);
28685         return (uintptr_t)ret_conv;
28686 }
28687
28688 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) {
28689         LDKChannelManager this_arg_conv;
28690         this_arg_conv.inner = (void*)(this_arg & (~1));
28691         this_arg_conv.is_owned = false;
28692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28693         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
28694         CHECK_ACCESS(min_value_msat_ptr);
28695         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
28696         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
28697         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
28698         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
28699         return (uintptr_t)ret_conv;
28700 }
28701
28702 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) {
28703         LDKChannelManager this_arg_conv;
28704         this_arg_conv.inner = (void*)(this_arg & (~1));
28705         this_arg_conv.is_owned = false;
28706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28707         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
28708         CHECK_ACCESS(min_value_msat_ptr);
28709         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
28710         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
28711         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
28712         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
28713         return (uintptr_t)ret_conv;
28714 }
28715
28716 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) {
28717         LDKChannelManager this_arg_conv;
28718         this_arg_conv.inner = (void*)(this_arg & (~1));
28719         this_arg_conv.is_owned = false;
28720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28721         LDKThirtyTwoBytes payment_hash_ref;
28722         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
28723         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
28724         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
28725         CHECK_ACCESS(min_value_msat_ptr);
28726         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
28727         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
28728         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
28729         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
28730         return (uintptr_t)ret_conv;
28731 }
28732
28733 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) {
28734         LDKChannelManager this_arg_conv;
28735         this_arg_conv.inner = (void*)(this_arg & (~1));
28736         this_arg_conv.is_owned = false;
28737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28738         LDKThirtyTwoBytes payment_hash_ref;
28739         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
28740         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
28741         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
28742         CHECK_ACCESS(min_value_msat_ptr);
28743         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
28744         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
28745         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
28746         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
28747         return (uintptr_t)ret_conv;
28748 }
28749
28750 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) {
28751         LDKChannelManager this_arg_conv;
28752         this_arg_conv.inner = (void*)(this_arg & (~1));
28753         this_arg_conv.is_owned = false;
28754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28755         LDKThirtyTwoBytes payment_hash_ref;
28756         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
28757         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
28758         LDKThirtyTwoBytes payment_secret_ref;
28759         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
28760         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
28761         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
28762         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
28763         return (uintptr_t)ret_conv;
28764 }
28765
28766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
28767         LDKChannelManager this_arg_conv;
28768         this_arg_conv.inner = (void*)(this_arg & (~1));
28769         this_arg_conv.is_owned = false;
28770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28771         int64_t ret_val = ChannelManager_get_phantom_scid(&this_arg_conv);
28772         return ret_val;
28773 }
28774
28775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
28776         LDKChannelManager this_arg_conv;
28777         this_arg_conv.inner = (void*)(this_arg & (~1));
28778         this_arg_conv.is_owned = false;
28779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28780         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
28781         uintptr_t ret_ref = 0;
28782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28785         ret_ref = (uintptr_t)ret_var.inner;
28786         if (ret_var.is_owned) {
28787                 ret_ref |= 1;
28788         }
28789         return ret_ref;
28790 }
28791
28792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
28793         LDKChannelManager this_arg_conv;
28794         this_arg_conv.inner = (void*)(this_arg & (~1));
28795         this_arg_conv.is_owned = false;
28796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28797         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
28798         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
28799         return (uintptr_t)ret_ret;
28800 }
28801
28802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
28803         LDKChannelManager this_arg_conv;
28804         this_arg_conv.inner = (void*)(this_arg & (~1));
28805         this_arg_conv.is_owned = false;
28806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28807         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
28808         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
28809         return (uintptr_t)ret_ret;
28810 }
28811
28812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
28813         LDKChannelManager this_arg_conv;
28814         this_arg_conv.inner = (void*)(this_arg & (~1));
28815         this_arg_conv.is_owned = false;
28816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28817         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
28818         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
28819         return (uintptr_t)ret_ret;
28820 }
28821
28822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
28823         LDKChannelManager this_arg_conv;
28824         this_arg_conv.inner = (void*)(this_arg & (~1));
28825         this_arg_conv.is_owned = false;
28826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28827         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
28828         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
28829         return (uintptr_t)ret_ret;
28830 }
28831
28832 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) {
28833         LDKChannelManager this_arg_conv;
28834         this_arg_conv.inner = (void*)(this_arg & (~1));
28835         this_arg_conv.is_owned = false;
28836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28837         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
28838         return ret_val;
28839 }
28840
28841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
28842         LDKChannelManager this_arg_conv;
28843         this_arg_conv.inner = (void*)(this_arg & (~1));
28844         this_arg_conv.is_owned = false;
28845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28846         ChannelManager_await_persistable_update(&this_arg_conv);
28847 }
28848
28849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
28850         LDKChannelManager this_arg_conv;
28851         this_arg_conv.inner = (void*)(this_arg & (~1));
28852         this_arg_conv.is_owned = false;
28853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28854         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
28855         uintptr_t ret_ref = 0;
28856         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28857         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28859         ret_ref = (uintptr_t)ret_var.inner;
28860         if (ret_var.is_owned) {
28861                 ret_ref |= 1;
28862         }
28863         return ret_ref;
28864 }
28865
28866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
28867         LDKChannelManager this_arg_conv;
28868         this_arg_conv.inner = (void*)(this_arg & (~1));
28869         this_arg_conv.is_owned = false;
28870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28871         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
28872         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
28873         return (uintptr_t)ret_ret;
28874 }
28875
28876 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
28877         LDKCounterpartyForwardingInfo obj_conv;
28878         obj_conv.inner = (void*)(obj & (~1));
28879         obj_conv.is_owned = false;
28880         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28881         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
28882         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28883         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28884         CVec_u8Z_free(ret_var);
28885         return ret_arr;
28886 }
28887
28888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28889         LDKu8slice ser_ref;
28890         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28891         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28892         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
28893         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
28894         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28895         return (uintptr_t)ret_conv;
28896 }
28897
28898 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
28899         LDKChannelCounterparty obj_conv;
28900         obj_conv.inner = (void*)(obj & (~1));
28901         obj_conv.is_owned = false;
28902         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28903         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
28904         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28905         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28906         CVec_u8Z_free(ret_var);
28907         return ret_arr;
28908 }
28909
28910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28911         LDKu8slice ser_ref;
28912         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28913         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28914         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
28915         *ret_conv = ChannelCounterparty_read(ser_ref);
28916         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28917         return (uintptr_t)ret_conv;
28918 }
28919
28920 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
28921         LDKChannelDetails obj_conv;
28922         obj_conv.inner = (void*)(obj & (~1));
28923         obj_conv.is_owned = false;
28924         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28925         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
28926         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28927         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28928         CVec_u8Z_free(ret_var);
28929         return ret_arr;
28930 }
28931
28932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28933         LDKu8slice ser_ref;
28934         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28935         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28936         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
28937         *ret_conv = ChannelDetails_read(ser_ref);
28938         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28939         return (uintptr_t)ret_conv;
28940 }
28941
28942 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
28943         LDKPhantomRouteHints obj_conv;
28944         obj_conv.inner = (void*)(obj & (~1));
28945         obj_conv.is_owned = false;
28946         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28947         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
28948         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28949         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28950         CVec_u8Z_free(ret_var);
28951         return ret_arr;
28952 }
28953
28954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28955         LDKu8slice ser_ref;
28956         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28957         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28958         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
28959         *ret_conv = PhantomRouteHints_read(ser_ref);
28960         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28961         return (uintptr_t)ret_conv;
28962 }
28963
28964 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
28965         LDKChannelManager obj_conv;
28966         obj_conv.inner = (void*)(obj & (~1));
28967         obj_conv.is_owned = false;
28968         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28969         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
28970         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28971         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28972         CVec_u8Z_free(ret_var);
28973         return ret_arr;
28974 }
28975
28976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28977         LDKChannelManagerReadArgs this_obj_conv;
28978         this_obj_conv.inner = (void*)(this_obj & (~1));
28979         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28981         ChannelManagerReadArgs_free(this_obj_conv);
28982 }
28983
28984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
28985         LDKChannelManagerReadArgs this_ptr_conv;
28986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28987         this_ptr_conv.is_owned = false;
28988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28989         // WARNING: This object doesn't live past this scope, needs clone!
28990         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
28991         return ret_ret;
28992 }
28993
28994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28995         LDKChannelManagerReadArgs this_ptr_conv;
28996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28997         this_ptr_conv.is_owned = false;
28998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28999         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29000         CHECK_ACCESS(val_ptr);
29001         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
29002         if (val_conv.free == LDKKeysInterface_JCalls_free) {
29003                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29004                 LDKKeysInterface_JCalls_cloned(&val_conv);
29005         }
29006         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
29007 }
29008
29009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
29010         LDKChannelManagerReadArgs this_ptr_conv;
29011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29012         this_ptr_conv.is_owned = false;
29013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29014         // WARNING: This object doesn't live past this scope, needs clone!
29015         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
29016         return ret_ret;
29017 }
29018
29019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29020         LDKChannelManagerReadArgs this_ptr_conv;
29021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29022         this_ptr_conv.is_owned = false;
29023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29024         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29025         CHECK_ACCESS(val_ptr);
29026         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
29027         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
29028                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29029                 LDKFeeEstimator_JCalls_cloned(&val_conv);
29030         }
29031         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
29032 }
29033
29034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
29035         LDKChannelManagerReadArgs this_ptr_conv;
29036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29037         this_ptr_conv.is_owned = false;
29038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29039         // WARNING: This object doesn't live past this scope, needs clone!
29040         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
29041         return ret_ret;
29042 }
29043
29044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29045         LDKChannelManagerReadArgs this_ptr_conv;
29046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29047         this_ptr_conv.is_owned = false;
29048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29049         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29050         CHECK_ACCESS(val_ptr);
29051         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
29052         if (val_conv.free == LDKWatch_JCalls_free) {
29053                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29054                 LDKWatch_JCalls_cloned(&val_conv);
29055         }
29056         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
29057 }
29058
29059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
29060         LDKChannelManagerReadArgs this_ptr_conv;
29061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29062         this_ptr_conv.is_owned = false;
29063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29064         // WARNING: This object doesn't live past this scope, needs clone!
29065         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
29066         return ret_ret;
29067 }
29068
29069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29070         LDKChannelManagerReadArgs this_ptr_conv;
29071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29072         this_ptr_conv.is_owned = false;
29073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29074         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29075         CHECK_ACCESS(val_ptr);
29076         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
29077         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
29078                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29079                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
29080         }
29081         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
29082 }
29083
29084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
29085         LDKChannelManagerReadArgs this_ptr_conv;
29086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29087         this_ptr_conv.is_owned = false;
29088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29089         // WARNING: This object doesn't live past this scope, needs clone!
29090         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
29091         return ret_ret;
29092 }
29093
29094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29095         LDKChannelManagerReadArgs this_ptr_conv;
29096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29097         this_ptr_conv.is_owned = false;
29098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29099         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29100         CHECK_ACCESS(val_ptr);
29101         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
29102         if (val_conv.free == LDKLogger_JCalls_free) {
29103                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29104                 LDKLogger_JCalls_cloned(&val_conv);
29105         }
29106         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
29107 }
29108
29109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
29110         LDKChannelManagerReadArgs this_ptr_conv;
29111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29112         this_ptr_conv.is_owned = false;
29113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29114         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
29115         uintptr_t ret_ref = 0;
29116         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29117         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29119         ret_ref = (uintptr_t)ret_var.inner;
29120         if (ret_var.is_owned) {
29121                 ret_ref |= 1;
29122         }
29123         return ret_ref;
29124 }
29125
29126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29127         LDKChannelManagerReadArgs this_ptr_conv;
29128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29129         this_ptr_conv.is_owned = false;
29130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29131         LDKUserConfig val_conv;
29132         val_conv.inner = (void*)(val & (~1));
29133         val_conv.is_owned = (val & 1) || (val == 0);
29134         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29135         val_conv = UserConfig_clone(&val_conv);
29136         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
29137 }
29138
29139 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) {
29140         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
29141         CHECK_ACCESS(keys_manager_ptr);
29142         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
29143         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
29144                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29145                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
29146         }
29147         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
29148         CHECK_ACCESS(fee_estimator_ptr);
29149         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29150         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29151                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29152                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29153         }
29154         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
29155         CHECK_ACCESS(chain_monitor_ptr);
29156         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
29157         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
29158                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29159                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
29160         }
29161         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
29162         CHECK_ACCESS(tx_broadcaster_ptr);
29163         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
29164         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29165                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29166                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
29167         }
29168         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
29169         CHECK_ACCESS(logger_ptr);
29170         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29171         if (logger_conv.free == LDKLogger_JCalls_free) {
29172                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29173                 LDKLogger_JCalls_cloned(&logger_conv);
29174         }
29175         LDKUserConfig default_config_conv;
29176         default_config_conv.inner = (void*)(default_config & (~1));
29177         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
29178         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
29179         default_config_conv = UserConfig_clone(&default_config_conv);
29180         LDKCVec_ChannelMonitorZ channel_monitors_constr;
29181         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
29182         if (channel_monitors_constr.datalen > 0)
29183                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
29184         else
29185                 channel_monitors_constr.data = NULL;
29186         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
29187         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
29188                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
29189                 LDKChannelMonitor channel_monitors_conv_16_conv;
29190                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
29191                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
29192                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
29193                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
29194         }
29195         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
29196         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);
29197         uintptr_t ret_ref = 0;
29198         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29199         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29201         ret_ref = (uintptr_t)ret_var.inner;
29202         if (ret_var.is_owned) {
29203                 ret_ref |= 1;
29204         }
29205         return ret_ref;
29206 }
29207
29208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
29209         LDKu8slice ser_ref;
29210         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29211         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29212         LDKChannelManagerReadArgs arg_conv;
29213         arg_conv.inner = (void*)(arg & (~1));
29214         arg_conv.is_owned = (arg & 1) || (arg == 0);
29215         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29216         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
29217         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
29218         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
29219         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29220         return (uintptr_t)ret_conv;
29221 }
29222
29223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29224         LDKDecodeError this_obj_conv;
29225         this_obj_conv.inner = (void*)(this_obj & (~1));
29226         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29228         DecodeError_free(this_obj_conv);
29229 }
29230
29231 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
29232         LDKDecodeError ret_var = DecodeError_clone(arg);
29233 uintptr_t ret_ref = 0;
29234 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29235 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29236 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29237 ret_ref = (uintptr_t)ret_var.inner;
29238 if (ret_var.is_owned) {
29239         ret_ref |= 1;
29240 }
29241         return ret_ref;
29242 }
29243 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29244         LDKDecodeError arg_conv;
29245         arg_conv.inner = (void*)(arg & (~1));
29246         arg_conv.is_owned = false;
29247         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29248         intptr_t ret_val = DecodeError_clone_ptr(&arg_conv);
29249         return ret_val;
29250 }
29251
29252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29253         LDKDecodeError orig_conv;
29254         orig_conv.inner = (void*)(orig & (~1));
29255         orig_conv.is_owned = false;
29256         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29257         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
29258         uintptr_t ret_ref = 0;
29259         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29260         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29262         ret_ref = (uintptr_t)ret_var.inner;
29263         if (ret_var.is_owned) {
29264                 ret_ref |= 1;
29265         }
29266         return ret_ref;
29267 }
29268
29269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29270         LDKInit this_obj_conv;
29271         this_obj_conv.inner = (void*)(this_obj & (~1));
29272         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29274         Init_free(this_obj_conv);
29275 }
29276
29277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
29278         LDKInit this_ptr_conv;
29279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29280         this_ptr_conv.is_owned = false;
29281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29282         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
29283         uintptr_t ret_ref = 0;
29284         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29285         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29287         ret_ref = (uintptr_t)ret_var.inner;
29288         if (ret_var.is_owned) {
29289                 ret_ref |= 1;
29290         }
29291         return ret_ref;
29292 }
29293
29294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29295         LDKInit this_ptr_conv;
29296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29297         this_ptr_conv.is_owned = false;
29298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29299         LDKInitFeatures val_conv;
29300         val_conv.inner = (void*)(val & (~1));
29301         val_conv.is_owned = (val & 1) || (val == 0);
29302         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29303         val_conv = InitFeatures_clone(&val_conv);
29304         Init_set_features(&this_ptr_conv, val_conv);
29305 }
29306
29307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
29308         LDKInitFeatures features_arg_conv;
29309         features_arg_conv.inner = (void*)(features_arg & (~1));
29310         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
29311         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
29312         features_arg_conv = InitFeatures_clone(&features_arg_conv);
29313         LDKInit ret_var = Init_new(features_arg_conv);
29314         uintptr_t ret_ref = 0;
29315         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29316         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29318         ret_ref = (uintptr_t)ret_var.inner;
29319         if (ret_var.is_owned) {
29320                 ret_ref |= 1;
29321         }
29322         return ret_ref;
29323 }
29324
29325 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
29326         LDKInit ret_var = Init_clone(arg);
29327 uintptr_t ret_ref = 0;
29328 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29329 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29330 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29331 ret_ref = (uintptr_t)ret_var.inner;
29332 if (ret_var.is_owned) {
29333         ret_ref |= 1;
29334 }
29335         return ret_ref;
29336 }
29337 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29338         LDKInit arg_conv;
29339         arg_conv.inner = (void*)(arg & (~1));
29340         arg_conv.is_owned = false;
29341         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29342         intptr_t ret_val = Init_clone_ptr(&arg_conv);
29343         return ret_val;
29344 }
29345
29346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29347         LDKInit orig_conv;
29348         orig_conv.inner = (void*)(orig & (~1));
29349         orig_conv.is_owned = false;
29350         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29351         LDKInit ret_var = Init_clone(&orig_conv);
29352         uintptr_t ret_ref = 0;
29353         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29354         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29356         ret_ref = (uintptr_t)ret_var.inner;
29357         if (ret_var.is_owned) {
29358                 ret_ref |= 1;
29359         }
29360         return ret_ref;
29361 }
29362
29363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29364         LDKErrorMessage this_obj_conv;
29365         this_obj_conv.inner = (void*)(this_obj & (~1));
29366         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29368         ErrorMessage_free(this_obj_conv);
29369 }
29370
29371 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29372         LDKErrorMessage this_ptr_conv;
29373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29374         this_ptr_conv.is_owned = false;
29375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29376         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29377         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
29378         return ret_arr;
29379 }
29380
29381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29382         LDKErrorMessage 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         LDKThirtyTwoBytes val_ref;
29387         CHECK((*env)->GetArrayLength(env, val) == 32);
29388         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29389         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
29390 }
29391
29392 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
29393         LDKErrorMessage this_ptr_conv;
29394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29395         this_ptr_conv.is_owned = false;
29396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29397         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
29398         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
29399         Str_free(ret_str);
29400         return ret_conv;
29401 }
29402
29403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
29404         LDKErrorMessage this_ptr_conv;
29405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29406         this_ptr_conv.is_owned = false;
29407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29408         LDKStr val_conv = java_to_owned_str(env, val);
29409         ErrorMessage_set_data(&this_ptr_conv, val_conv);
29410 }
29411
29412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
29413         LDKThirtyTwoBytes channel_id_arg_ref;
29414         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
29415         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
29416         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
29417         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
29418         uintptr_t ret_ref = 0;
29419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29422         ret_ref = (uintptr_t)ret_var.inner;
29423         if (ret_var.is_owned) {
29424                 ret_ref |= 1;
29425         }
29426         return ret_ref;
29427 }
29428
29429 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
29430         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
29431 uintptr_t ret_ref = 0;
29432 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29433 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29434 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29435 ret_ref = (uintptr_t)ret_var.inner;
29436 if (ret_var.is_owned) {
29437         ret_ref |= 1;
29438 }
29439         return ret_ref;
29440 }
29441 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29442         LDKErrorMessage arg_conv;
29443         arg_conv.inner = (void*)(arg & (~1));
29444         arg_conv.is_owned = false;
29445         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29446         intptr_t ret_val = ErrorMessage_clone_ptr(&arg_conv);
29447         return ret_val;
29448 }
29449
29450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29451         LDKErrorMessage orig_conv;
29452         orig_conv.inner = (void*)(orig & (~1));
29453         orig_conv.is_owned = false;
29454         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29455         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
29456         uintptr_t ret_ref = 0;
29457         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29458         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29460         ret_ref = (uintptr_t)ret_var.inner;
29461         if (ret_var.is_owned) {
29462                 ret_ref |= 1;
29463         }
29464         return ret_ref;
29465 }
29466
29467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29468         LDKWarningMessage this_obj_conv;
29469         this_obj_conv.inner = (void*)(this_obj & (~1));
29470         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29472         WarningMessage_free(this_obj_conv);
29473 }
29474
29475 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29476         LDKWarningMessage this_ptr_conv;
29477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29478         this_ptr_conv.is_owned = false;
29479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29480         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29481         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
29482         return ret_arr;
29483 }
29484
29485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29486         LDKWarningMessage 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         LDKThirtyTwoBytes val_ref;
29491         CHECK((*env)->GetArrayLength(env, val) == 32);
29492         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29493         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
29494 }
29495
29496 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
29497         LDKWarningMessage this_ptr_conv;
29498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29499         this_ptr_conv.is_owned = false;
29500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29501         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
29502         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
29503         Str_free(ret_str);
29504         return ret_conv;
29505 }
29506
29507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
29508         LDKWarningMessage this_ptr_conv;
29509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29510         this_ptr_conv.is_owned = false;
29511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29512         LDKStr val_conv = java_to_owned_str(env, val);
29513         WarningMessage_set_data(&this_ptr_conv, val_conv);
29514 }
29515
29516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
29517         LDKThirtyTwoBytes channel_id_arg_ref;
29518         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
29519         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
29520         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
29521         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
29522         uintptr_t ret_ref = 0;
29523         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29524         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29526         ret_ref = (uintptr_t)ret_var.inner;
29527         if (ret_var.is_owned) {
29528                 ret_ref |= 1;
29529         }
29530         return ret_ref;
29531 }
29532
29533 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
29534         LDKWarningMessage ret_var = WarningMessage_clone(arg);
29535 uintptr_t ret_ref = 0;
29536 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29537 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29538 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29539 ret_ref = (uintptr_t)ret_var.inner;
29540 if (ret_var.is_owned) {
29541         ret_ref |= 1;
29542 }
29543         return ret_ref;
29544 }
29545 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29546         LDKWarningMessage arg_conv;
29547         arg_conv.inner = (void*)(arg & (~1));
29548         arg_conv.is_owned = false;
29549         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29550         intptr_t ret_val = WarningMessage_clone_ptr(&arg_conv);
29551         return ret_val;
29552 }
29553
29554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29555         LDKWarningMessage orig_conv;
29556         orig_conv.inner = (void*)(orig & (~1));
29557         orig_conv.is_owned = false;
29558         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29559         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
29560         uintptr_t ret_ref = 0;
29561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29564         ret_ref = (uintptr_t)ret_var.inner;
29565         if (ret_var.is_owned) {
29566                 ret_ref |= 1;
29567         }
29568         return ret_ref;
29569 }
29570
29571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29572         LDKPing this_obj_conv;
29573         this_obj_conv.inner = (void*)(this_obj & (~1));
29574         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29576         Ping_free(this_obj_conv);
29577 }
29578
29579 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
29580         LDKPing 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         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
29585         return ret_val;
29586 }
29587
29588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29589         LDKPing this_ptr_conv;
29590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29591         this_ptr_conv.is_owned = false;
29592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29593         Ping_set_ponglen(&this_ptr_conv, val);
29594 }
29595
29596 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
29597         LDKPing this_ptr_conv;
29598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29599         this_ptr_conv.is_owned = false;
29600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29601         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
29602         return ret_val;
29603 }
29604
29605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29606         LDKPing this_ptr_conv;
29607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29608         this_ptr_conv.is_owned = false;
29609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29610         Ping_set_byteslen(&this_ptr_conv, val);
29611 }
29612
29613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
29614         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
29615         uintptr_t ret_ref = 0;
29616         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29617         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29619         ret_ref = (uintptr_t)ret_var.inner;
29620         if (ret_var.is_owned) {
29621                 ret_ref |= 1;
29622         }
29623         return ret_ref;
29624 }
29625
29626 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
29627         LDKPing ret_var = Ping_clone(arg);
29628 uintptr_t ret_ref = 0;
29629 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29630 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29631 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29632 ret_ref = (uintptr_t)ret_var.inner;
29633 if (ret_var.is_owned) {
29634         ret_ref |= 1;
29635 }
29636         return ret_ref;
29637 }
29638 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29639         LDKPing arg_conv;
29640         arg_conv.inner = (void*)(arg & (~1));
29641         arg_conv.is_owned = false;
29642         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29643         intptr_t ret_val = Ping_clone_ptr(&arg_conv);
29644         return ret_val;
29645 }
29646
29647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29648         LDKPing orig_conv;
29649         orig_conv.inner = (void*)(orig & (~1));
29650         orig_conv.is_owned = false;
29651         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29652         LDKPing ret_var = Ping_clone(&orig_conv);
29653         uintptr_t ret_ref = 0;
29654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29657         ret_ref = (uintptr_t)ret_var.inner;
29658         if (ret_var.is_owned) {
29659                 ret_ref |= 1;
29660         }
29661         return ret_ref;
29662 }
29663
29664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29665         LDKPong this_obj_conv;
29666         this_obj_conv.inner = (void*)(this_obj & (~1));
29667         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29669         Pong_free(this_obj_conv);
29670 }
29671
29672 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
29673         LDKPong this_ptr_conv;
29674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29675         this_ptr_conv.is_owned = false;
29676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29677         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
29678         return ret_val;
29679 }
29680
29681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29682         LDKPong this_ptr_conv;
29683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29684         this_ptr_conv.is_owned = false;
29685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29686         Pong_set_byteslen(&this_ptr_conv, val);
29687 }
29688
29689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
29690         LDKPong ret_var = Pong_new(byteslen_arg);
29691         uintptr_t ret_ref = 0;
29692         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29693         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29695         ret_ref = (uintptr_t)ret_var.inner;
29696         if (ret_var.is_owned) {
29697                 ret_ref |= 1;
29698         }
29699         return ret_ref;
29700 }
29701
29702 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
29703         LDKPong ret_var = Pong_clone(arg);
29704 uintptr_t ret_ref = 0;
29705 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29706 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29707 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29708 ret_ref = (uintptr_t)ret_var.inner;
29709 if (ret_var.is_owned) {
29710         ret_ref |= 1;
29711 }
29712         return ret_ref;
29713 }
29714 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29715         LDKPong arg_conv;
29716         arg_conv.inner = (void*)(arg & (~1));
29717         arg_conv.is_owned = false;
29718         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29719         intptr_t ret_val = Pong_clone_ptr(&arg_conv);
29720         return ret_val;
29721 }
29722
29723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29724         LDKPong orig_conv;
29725         orig_conv.inner = (void*)(orig & (~1));
29726         orig_conv.is_owned = false;
29727         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29728         LDKPong ret_var = Pong_clone(&orig_conv);
29729         uintptr_t ret_ref = 0;
29730         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29731         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29733         ret_ref = (uintptr_t)ret_var.inner;
29734         if (ret_var.is_owned) {
29735                 ret_ref |= 1;
29736         }
29737         return ret_ref;
29738 }
29739
29740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29741         LDKOpenChannel this_obj_conv;
29742         this_obj_conv.inner = (void*)(this_obj & (~1));
29743         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29745         OpenChannel_free(this_obj_conv);
29746 }
29747
29748 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
29749         LDKOpenChannel this_ptr_conv;
29750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29751         this_ptr_conv.is_owned = false;
29752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29753         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29754         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
29755         return ret_arr;
29756 }
29757
29758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29759         LDKOpenChannel this_ptr_conv;
29760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29761         this_ptr_conv.is_owned = false;
29762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29763         LDKThirtyTwoBytes val_ref;
29764         CHECK((*env)->GetArrayLength(env, val) == 32);
29765         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29766         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
29767 }
29768
29769 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29770         LDKOpenChannel this_ptr_conv;
29771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29772         this_ptr_conv.is_owned = false;
29773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29774         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29775         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
29776         return ret_arr;
29777 }
29778
29779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29780         LDKOpenChannel this_ptr_conv;
29781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29782         this_ptr_conv.is_owned = false;
29783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29784         LDKThirtyTwoBytes val_ref;
29785         CHECK((*env)->GetArrayLength(env, val) == 32);
29786         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29787         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
29788 }
29789
29790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29791         LDKOpenChannel this_ptr_conv;
29792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29793         this_ptr_conv.is_owned = false;
29794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29795         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
29796         return ret_val;
29797 }
29798
29799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29800         LDKOpenChannel this_ptr_conv;
29801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29802         this_ptr_conv.is_owned = false;
29803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29804         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
29805 }
29806
29807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29808         LDKOpenChannel this_ptr_conv;
29809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29810         this_ptr_conv.is_owned = false;
29811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29812         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
29813         return ret_val;
29814 }
29815
29816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29817         LDKOpenChannel 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         OpenChannel_set_push_msat(&this_ptr_conv, val);
29822 }
29823
29824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29825         LDKOpenChannel this_ptr_conv;
29826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29827         this_ptr_conv.is_owned = false;
29828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29829         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
29830         return ret_val;
29831 }
29832
29833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29834         LDKOpenChannel 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         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
29839 }
29840
29841 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) {
29842         LDKOpenChannel this_ptr_conv;
29843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29844         this_ptr_conv.is_owned = false;
29845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29846         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
29847         return ret_val;
29848 }
29849
29850 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) {
29851         LDKOpenChannel this_ptr_conv;
29852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29853         this_ptr_conv.is_owned = false;
29854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29855         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
29856 }
29857
29858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29859         LDKOpenChannel this_ptr_conv;
29860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29861         this_ptr_conv.is_owned = false;
29862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29863         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
29864         return ret_val;
29865 }
29866
29867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29868         LDKOpenChannel this_ptr_conv;
29869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29870         this_ptr_conv.is_owned = false;
29871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29872         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
29873 }
29874
29875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29876         LDKOpenChannel this_ptr_conv;
29877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29878         this_ptr_conv.is_owned = false;
29879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29880         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
29881         return ret_val;
29882 }
29883
29884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29885         LDKOpenChannel this_ptr_conv;
29886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29887         this_ptr_conv.is_owned = false;
29888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29889         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
29890 }
29891
29892 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
29893         LDKOpenChannel this_ptr_conv;
29894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29895         this_ptr_conv.is_owned = false;
29896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29897         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
29898         return ret_val;
29899 }
29900
29901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29902         LDKOpenChannel this_ptr_conv;
29903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29904         this_ptr_conv.is_owned = false;
29905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29906         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
29907 }
29908
29909 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
29910         LDKOpenChannel this_ptr_conv;
29911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29912         this_ptr_conv.is_owned = false;
29913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29914         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
29915         return ret_val;
29916 }
29917
29918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29919         LDKOpenChannel this_ptr_conv;
29920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29921         this_ptr_conv.is_owned = false;
29922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29923         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
29924 }
29925
29926 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
29927         LDKOpenChannel this_ptr_conv;
29928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29929         this_ptr_conv.is_owned = false;
29930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29931         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
29932         return ret_val;
29933 }
29934
29935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29936         LDKOpenChannel this_ptr_conv;
29937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29938         this_ptr_conv.is_owned = false;
29939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29940         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
29941 }
29942
29943 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
29944         LDKOpenChannel this_ptr_conv;
29945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29946         this_ptr_conv.is_owned = false;
29947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29948         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29949         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
29950         return ret_arr;
29951 }
29952
29953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29954         LDKOpenChannel this_ptr_conv;
29955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29956         this_ptr_conv.is_owned = false;
29957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29958         LDKPublicKey val_ref;
29959         CHECK((*env)->GetArrayLength(env, val) == 33);
29960         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29961         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
29962 }
29963
29964 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
29965         LDKOpenChannel this_ptr_conv;
29966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29967         this_ptr_conv.is_owned = false;
29968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29969         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29970         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
29971         return ret_arr;
29972 }
29973
29974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29975         LDKOpenChannel this_ptr_conv;
29976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29977         this_ptr_conv.is_owned = false;
29978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29979         LDKPublicKey val_ref;
29980         CHECK((*env)->GetArrayLength(env, val) == 33);
29981         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29982         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
29983 }
29984
29985 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
29986         LDKOpenChannel this_ptr_conv;
29987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29988         this_ptr_conv.is_owned = false;
29989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29990         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29991         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
29992         return ret_arr;
29993 }
29994
29995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29996         LDKOpenChannel this_ptr_conv;
29997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29998         this_ptr_conv.is_owned = false;
29999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30000         LDKPublicKey val_ref;
30001         CHECK((*env)->GetArrayLength(env, val) == 33);
30002         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30003         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
30004 }
30005
30006 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30007         LDKOpenChannel this_ptr_conv;
30008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30009         this_ptr_conv.is_owned = false;
30010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30011         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30012         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
30013         return ret_arr;
30014 }
30015
30016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30017         LDKOpenChannel this_ptr_conv;
30018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30019         this_ptr_conv.is_owned = false;
30020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30021         LDKPublicKey val_ref;
30022         CHECK((*env)->GetArrayLength(env, val) == 33);
30023         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30024         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
30025 }
30026
30027 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30028         LDKOpenChannel this_ptr_conv;
30029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30030         this_ptr_conv.is_owned = false;
30031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30032         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30033         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
30034         return ret_arr;
30035 }
30036
30037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30038         LDKOpenChannel this_ptr_conv;
30039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30040         this_ptr_conv.is_owned = false;
30041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30042         LDKPublicKey val_ref;
30043         CHECK((*env)->GetArrayLength(env, val) == 33);
30044         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30045         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
30046 }
30047
30048 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30049         LDKOpenChannel this_ptr_conv;
30050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30051         this_ptr_conv.is_owned = false;
30052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30053         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30054         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
30055         return ret_arr;
30056 }
30057
30058 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) {
30059         LDKOpenChannel this_ptr_conv;
30060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30061         this_ptr_conv.is_owned = false;
30062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30063         LDKPublicKey val_ref;
30064         CHECK((*env)->GetArrayLength(env, val) == 33);
30065         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30066         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
30067 }
30068
30069 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
30070         LDKOpenChannel this_ptr_conv;
30071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30072         this_ptr_conv.is_owned = false;
30073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30074         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
30075         return ret_val;
30076 }
30077
30078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
30079         LDKOpenChannel this_ptr_conv;
30080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30081         this_ptr_conv.is_owned = false;
30082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30083         OpenChannel_set_channel_flags(&this_ptr_conv, val);
30084 }
30085
30086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
30087         LDKOpenChannel this_ptr_conv;
30088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30089         this_ptr_conv.is_owned = false;
30090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30091         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
30092         uintptr_t ret_ref = 0;
30093         if ((uintptr_t)ret_var.inner > 4096) {
30094                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30095                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30097                 ret_ref = (uintptr_t)ret_var.inner;
30098                 if (ret_var.is_owned) {
30099                         ret_ref |= 1;
30100                 }
30101         }
30102         return ret_ref;
30103 }
30104
30105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30106         LDKOpenChannel this_ptr_conv;
30107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30108         this_ptr_conv.is_owned = false;
30109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30110         LDKChannelTypeFeatures val_conv;
30111         val_conv.inner = (void*)(val & (~1));
30112         val_conv.is_owned = (val & 1) || (val == 0);
30113         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30114         val_conv = ChannelTypeFeatures_clone(&val_conv);
30115         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
30116 }
30117
30118 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
30119         LDKOpenChannel ret_var = OpenChannel_clone(arg);
30120 uintptr_t ret_ref = 0;
30121 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30122 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30123 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30124 ret_ref = (uintptr_t)ret_var.inner;
30125 if (ret_var.is_owned) {
30126         ret_ref |= 1;
30127 }
30128         return ret_ref;
30129 }
30130 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30131         LDKOpenChannel arg_conv;
30132         arg_conv.inner = (void*)(arg & (~1));
30133         arg_conv.is_owned = false;
30134         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30135         intptr_t ret_val = OpenChannel_clone_ptr(&arg_conv);
30136         return ret_val;
30137 }
30138
30139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30140         LDKOpenChannel orig_conv;
30141         orig_conv.inner = (void*)(orig & (~1));
30142         orig_conv.is_owned = false;
30143         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30144         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
30145         uintptr_t ret_ref = 0;
30146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30149         ret_ref = (uintptr_t)ret_var.inner;
30150         if (ret_var.is_owned) {
30151                 ret_ref |= 1;
30152         }
30153         return ret_ref;
30154 }
30155
30156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30157         LDKAcceptChannel this_obj_conv;
30158         this_obj_conv.inner = (void*)(this_obj & (~1));
30159         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30161         AcceptChannel_free(this_obj_conv);
30162 }
30163
30164 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30165         LDKAcceptChannel this_ptr_conv;
30166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30167         this_ptr_conv.is_owned = false;
30168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30169         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30170         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
30171         return ret_arr;
30172 }
30173
30174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30175         LDKAcceptChannel this_ptr_conv;
30176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30177         this_ptr_conv.is_owned = false;
30178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30179         LDKThirtyTwoBytes val_ref;
30180         CHECK((*env)->GetArrayLength(env, val) == 32);
30181         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30182         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
30183 }
30184
30185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30186         LDKAcceptChannel this_ptr_conv;
30187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30188         this_ptr_conv.is_owned = false;
30189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30190         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
30191         return ret_val;
30192 }
30193
30194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30195         LDKAcceptChannel this_ptr_conv;
30196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30197         this_ptr_conv.is_owned = false;
30198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30199         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
30200 }
30201
30202 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) {
30203         LDKAcceptChannel this_ptr_conv;
30204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30205         this_ptr_conv.is_owned = false;
30206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30207         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
30208         return ret_val;
30209 }
30210
30211 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) {
30212         LDKAcceptChannel this_ptr_conv;
30213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30214         this_ptr_conv.is_owned = false;
30215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30216         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
30217 }
30218
30219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30220         LDKAcceptChannel this_ptr_conv;
30221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30222         this_ptr_conv.is_owned = false;
30223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30224         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
30225         return ret_val;
30226 }
30227
30228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30229         LDKAcceptChannel this_ptr_conv;
30230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30231         this_ptr_conv.is_owned = false;
30232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30233         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
30234 }
30235
30236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30237         LDKAcceptChannel this_ptr_conv;
30238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30239         this_ptr_conv.is_owned = false;
30240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30241         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
30242         return ret_val;
30243 }
30244
30245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30246         LDKAcceptChannel this_ptr_conv;
30247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30248         this_ptr_conv.is_owned = false;
30249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30250         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
30251 }
30252
30253 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
30254         LDKAcceptChannel this_ptr_conv;
30255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30256         this_ptr_conv.is_owned = false;
30257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30258         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
30259         return ret_val;
30260 }
30261
30262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30263         LDKAcceptChannel this_ptr_conv;
30264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30265         this_ptr_conv.is_owned = false;
30266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30267         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
30268 }
30269
30270 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30271         LDKAcceptChannel this_ptr_conv;
30272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30273         this_ptr_conv.is_owned = false;
30274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30275         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
30276         return ret_val;
30277 }
30278
30279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30280         LDKAcceptChannel this_ptr_conv;
30281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30282         this_ptr_conv.is_owned = false;
30283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30284         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
30285 }
30286
30287 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
30288         LDKAcceptChannel this_ptr_conv;
30289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30290         this_ptr_conv.is_owned = false;
30291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30292         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
30293         return ret_val;
30294 }
30295
30296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30297         LDKAcceptChannel this_ptr_conv;
30298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30299         this_ptr_conv.is_owned = false;
30300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30301         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
30302 }
30303
30304 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30305         LDKAcceptChannel this_ptr_conv;
30306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30307         this_ptr_conv.is_owned = false;
30308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30309         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30310         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
30311         return ret_arr;
30312 }
30313
30314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30315         LDKAcceptChannel this_ptr_conv;
30316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30317         this_ptr_conv.is_owned = false;
30318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30319         LDKPublicKey val_ref;
30320         CHECK((*env)->GetArrayLength(env, val) == 33);
30321         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30322         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
30323 }
30324
30325 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30326         LDKAcceptChannel this_ptr_conv;
30327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30328         this_ptr_conv.is_owned = false;
30329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30330         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30331         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
30332         return ret_arr;
30333 }
30334
30335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30336         LDKAcceptChannel this_ptr_conv;
30337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30338         this_ptr_conv.is_owned = false;
30339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30340         LDKPublicKey val_ref;
30341         CHECK((*env)->GetArrayLength(env, val) == 33);
30342         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30343         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
30344 }
30345
30346 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30347         LDKAcceptChannel this_ptr_conv;
30348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30349         this_ptr_conv.is_owned = false;
30350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30351         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30352         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
30353         return ret_arr;
30354 }
30355
30356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30357         LDKAcceptChannel this_ptr_conv;
30358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30359         this_ptr_conv.is_owned = false;
30360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30361         LDKPublicKey val_ref;
30362         CHECK((*env)->GetArrayLength(env, val) == 33);
30363         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30364         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
30365 }
30366
30367 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30368         LDKAcceptChannel this_ptr_conv;
30369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30370         this_ptr_conv.is_owned = false;
30371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30372         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30373         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
30374         return ret_arr;
30375 }
30376
30377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30378         LDKAcceptChannel this_ptr_conv;
30379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30380         this_ptr_conv.is_owned = false;
30381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30382         LDKPublicKey val_ref;
30383         CHECK((*env)->GetArrayLength(env, val) == 33);
30384         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30385         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
30386 }
30387
30388 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30389         LDKAcceptChannel this_ptr_conv;
30390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30391         this_ptr_conv.is_owned = false;
30392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30393         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30394         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
30395         return ret_arr;
30396 }
30397
30398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30399         LDKAcceptChannel this_ptr_conv;
30400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30401         this_ptr_conv.is_owned = false;
30402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30403         LDKPublicKey val_ref;
30404         CHECK((*env)->GetArrayLength(env, val) == 33);
30405         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30406         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
30407 }
30408
30409 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30410         LDKAcceptChannel this_ptr_conv;
30411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30412         this_ptr_conv.is_owned = false;
30413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30414         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30415         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
30416         return ret_arr;
30417 }
30418
30419 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) {
30420         LDKAcceptChannel this_ptr_conv;
30421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30422         this_ptr_conv.is_owned = false;
30423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30424         LDKPublicKey val_ref;
30425         CHECK((*env)->GetArrayLength(env, val) == 33);
30426         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30427         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
30428 }
30429
30430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
30431         LDKAcceptChannel this_ptr_conv;
30432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30433         this_ptr_conv.is_owned = false;
30434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30435         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
30436         uintptr_t ret_ref = 0;
30437         if ((uintptr_t)ret_var.inner > 4096) {
30438                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30439                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30441                 ret_ref = (uintptr_t)ret_var.inner;
30442                 if (ret_var.is_owned) {
30443                         ret_ref |= 1;
30444                 }
30445         }
30446         return ret_ref;
30447 }
30448
30449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30450         LDKAcceptChannel this_ptr_conv;
30451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30452         this_ptr_conv.is_owned = false;
30453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30454         LDKChannelTypeFeatures val_conv;
30455         val_conv.inner = (void*)(val & (~1));
30456         val_conv.is_owned = (val & 1) || (val == 0);
30457         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30458         val_conv = ChannelTypeFeatures_clone(&val_conv);
30459         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
30460 }
30461
30462 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
30463         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
30464 uintptr_t ret_ref = 0;
30465 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30466 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30467 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30468 ret_ref = (uintptr_t)ret_var.inner;
30469 if (ret_var.is_owned) {
30470         ret_ref |= 1;
30471 }
30472         return ret_ref;
30473 }
30474 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30475         LDKAcceptChannel arg_conv;
30476         arg_conv.inner = (void*)(arg & (~1));
30477         arg_conv.is_owned = false;
30478         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30479         intptr_t ret_val = AcceptChannel_clone_ptr(&arg_conv);
30480         return ret_val;
30481 }
30482
30483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30484         LDKAcceptChannel orig_conv;
30485         orig_conv.inner = (void*)(orig & (~1));
30486         orig_conv.is_owned = false;
30487         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30488         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
30489         uintptr_t ret_ref = 0;
30490         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30491         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30493         ret_ref = (uintptr_t)ret_var.inner;
30494         if (ret_var.is_owned) {
30495                 ret_ref |= 1;
30496         }
30497         return ret_ref;
30498 }
30499
30500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30501         LDKFundingCreated this_obj_conv;
30502         this_obj_conv.inner = (void*)(this_obj & (~1));
30503         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30505         FundingCreated_free(this_obj_conv);
30506 }
30507
30508 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30509         LDKFundingCreated this_ptr_conv;
30510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30511         this_ptr_conv.is_owned = false;
30512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30513         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30514         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
30515         return ret_arr;
30516 }
30517
30518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30519         LDKFundingCreated this_ptr_conv;
30520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30521         this_ptr_conv.is_owned = false;
30522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30523         LDKThirtyTwoBytes val_ref;
30524         CHECK((*env)->GetArrayLength(env, val) == 32);
30525         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30526         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
30527 }
30528
30529 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
30530         LDKFundingCreated this_ptr_conv;
30531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30532         this_ptr_conv.is_owned = false;
30533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30534         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30535         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
30536         return ret_arr;
30537 }
30538
30539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30540         LDKFundingCreated this_ptr_conv;
30541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30542         this_ptr_conv.is_owned = false;
30543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30544         LDKThirtyTwoBytes val_ref;
30545         CHECK((*env)->GetArrayLength(env, val) == 32);
30546         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30547         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
30548 }
30549
30550 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
30551         LDKFundingCreated this_ptr_conv;
30552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30553         this_ptr_conv.is_owned = false;
30554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30555         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
30556         return ret_val;
30557 }
30558
30559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30560         LDKFundingCreated this_ptr_conv;
30561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30562         this_ptr_conv.is_owned = false;
30563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30564         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
30565 }
30566
30567 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
30568         LDKFundingCreated this_ptr_conv;
30569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30570         this_ptr_conv.is_owned = false;
30571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30572         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
30573         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
30574         return ret_arr;
30575 }
30576
30577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30578         LDKFundingCreated this_ptr_conv;
30579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30580         this_ptr_conv.is_owned = false;
30581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30582         LDKSignature val_ref;
30583         CHECK((*env)->GetArrayLength(env, val) == 64);
30584         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
30585         FundingCreated_set_signature(&this_ptr_conv, val_ref);
30586 }
30587
30588 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) {
30589         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
30590         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
30591         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
30592         LDKThirtyTwoBytes funding_txid_arg_ref;
30593         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
30594         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
30595         LDKSignature signature_arg_ref;
30596         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
30597         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
30598         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
30599         uintptr_t ret_ref = 0;
30600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30603         ret_ref = (uintptr_t)ret_var.inner;
30604         if (ret_var.is_owned) {
30605                 ret_ref |= 1;
30606         }
30607         return ret_ref;
30608 }
30609
30610 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
30611         LDKFundingCreated ret_var = FundingCreated_clone(arg);
30612 uintptr_t ret_ref = 0;
30613 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30614 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30615 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30616 ret_ref = (uintptr_t)ret_var.inner;
30617 if (ret_var.is_owned) {
30618         ret_ref |= 1;
30619 }
30620         return ret_ref;
30621 }
30622 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30623         LDKFundingCreated arg_conv;
30624         arg_conv.inner = (void*)(arg & (~1));
30625         arg_conv.is_owned = false;
30626         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30627         intptr_t ret_val = FundingCreated_clone_ptr(&arg_conv);
30628         return ret_val;
30629 }
30630
30631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30632         LDKFundingCreated orig_conv;
30633         orig_conv.inner = (void*)(orig & (~1));
30634         orig_conv.is_owned = false;
30635         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30636         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
30637         uintptr_t ret_ref = 0;
30638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30641         ret_ref = (uintptr_t)ret_var.inner;
30642         if (ret_var.is_owned) {
30643                 ret_ref |= 1;
30644         }
30645         return ret_ref;
30646 }
30647
30648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30649         LDKFundingSigned this_obj_conv;
30650         this_obj_conv.inner = (void*)(this_obj & (~1));
30651         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30653         FundingSigned_free(this_obj_conv);
30654 }
30655
30656 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30657         LDKFundingSigned this_ptr_conv;
30658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30659         this_ptr_conv.is_owned = false;
30660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30661         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30662         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
30663         return ret_arr;
30664 }
30665
30666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30667         LDKFundingSigned this_ptr_conv;
30668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30669         this_ptr_conv.is_owned = false;
30670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30671         LDKThirtyTwoBytes val_ref;
30672         CHECK((*env)->GetArrayLength(env, val) == 32);
30673         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30674         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
30675 }
30676
30677 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
30678         LDKFundingSigned this_ptr_conv;
30679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30680         this_ptr_conv.is_owned = false;
30681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30682         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
30683         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
30684         return ret_arr;
30685 }
30686
30687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30688         LDKFundingSigned this_ptr_conv;
30689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30690         this_ptr_conv.is_owned = false;
30691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30692         LDKSignature val_ref;
30693         CHECK((*env)->GetArrayLength(env, val) == 64);
30694         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
30695         FundingSigned_set_signature(&this_ptr_conv, val_ref);
30696 }
30697
30698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
30699         LDKThirtyTwoBytes channel_id_arg_ref;
30700         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30701         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30702         LDKSignature signature_arg_ref;
30703         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
30704         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
30705         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
30706         uintptr_t ret_ref = 0;
30707         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30708         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30710         ret_ref = (uintptr_t)ret_var.inner;
30711         if (ret_var.is_owned) {
30712                 ret_ref |= 1;
30713         }
30714         return ret_ref;
30715 }
30716
30717 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
30718         LDKFundingSigned ret_var = FundingSigned_clone(arg);
30719 uintptr_t ret_ref = 0;
30720 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30721 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30722 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30723 ret_ref = (uintptr_t)ret_var.inner;
30724 if (ret_var.is_owned) {
30725         ret_ref |= 1;
30726 }
30727         return ret_ref;
30728 }
30729 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30730         LDKFundingSigned arg_conv;
30731         arg_conv.inner = (void*)(arg & (~1));
30732         arg_conv.is_owned = false;
30733         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30734         intptr_t ret_val = FundingSigned_clone_ptr(&arg_conv);
30735         return ret_val;
30736 }
30737
30738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30739         LDKFundingSigned orig_conv;
30740         orig_conv.inner = (void*)(orig & (~1));
30741         orig_conv.is_owned = false;
30742         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30743         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
30744         uintptr_t ret_ref = 0;
30745         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30746         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30748         ret_ref = (uintptr_t)ret_var.inner;
30749         if (ret_var.is_owned) {
30750                 ret_ref |= 1;
30751         }
30752         return ret_ref;
30753 }
30754
30755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30756         LDKFundingLocked this_obj_conv;
30757         this_obj_conv.inner = (void*)(this_obj & (~1));
30758         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30760         FundingLocked_free(this_obj_conv);
30761 }
30762
30763 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30764         LDKFundingLocked this_ptr_conv;
30765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30766         this_ptr_conv.is_owned = false;
30767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30768         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30769         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
30770         return ret_arr;
30771 }
30772
30773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30774         LDKFundingLocked this_ptr_conv;
30775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30776         this_ptr_conv.is_owned = false;
30777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30778         LDKThirtyTwoBytes val_ref;
30779         CHECK((*env)->GetArrayLength(env, val) == 32);
30780         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30781         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
30782 }
30783
30784 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30785         LDKFundingLocked this_ptr_conv;
30786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30787         this_ptr_conv.is_owned = false;
30788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30789         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30790         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
30791         return ret_arr;
30792 }
30793
30794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30795         LDKFundingLocked this_ptr_conv;
30796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30797         this_ptr_conv.is_owned = false;
30798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30799         LDKPublicKey val_ref;
30800         CHECK((*env)->GetArrayLength(env, val) == 33);
30801         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30802         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
30803 }
30804
30805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
30806         LDKThirtyTwoBytes channel_id_arg_ref;
30807         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30808         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30809         LDKPublicKey next_per_commitment_point_arg_ref;
30810         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
30811         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
30812         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
30813         uintptr_t ret_ref = 0;
30814         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30815         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30817         ret_ref = (uintptr_t)ret_var.inner;
30818         if (ret_var.is_owned) {
30819                 ret_ref |= 1;
30820         }
30821         return ret_ref;
30822 }
30823
30824 static inline uintptr_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
30825         LDKFundingLocked ret_var = FundingLocked_clone(arg);
30826 uintptr_t ret_ref = 0;
30827 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30828 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30829 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30830 ret_ref = (uintptr_t)ret_var.inner;
30831 if (ret_var.is_owned) {
30832         ret_ref |= 1;
30833 }
30834         return ret_ref;
30835 }
30836 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30837         LDKFundingLocked arg_conv;
30838         arg_conv.inner = (void*)(arg & (~1));
30839         arg_conv.is_owned = false;
30840         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30841         intptr_t ret_val = FundingLocked_clone_ptr(&arg_conv);
30842         return ret_val;
30843 }
30844
30845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30846         LDKFundingLocked orig_conv;
30847         orig_conv.inner = (void*)(orig & (~1));
30848         orig_conv.is_owned = false;
30849         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30850         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
30851         uintptr_t ret_ref = 0;
30852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30855         ret_ref = (uintptr_t)ret_var.inner;
30856         if (ret_var.is_owned) {
30857                 ret_ref |= 1;
30858         }
30859         return ret_ref;
30860 }
30861
30862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30863         LDKShutdown this_obj_conv;
30864         this_obj_conv.inner = (void*)(this_obj & (~1));
30865         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30867         Shutdown_free(this_obj_conv);
30868 }
30869
30870 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30871         LDKShutdown this_ptr_conv;
30872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30873         this_ptr_conv.is_owned = false;
30874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30875         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30876         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
30877         return ret_arr;
30878 }
30879
30880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30881         LDKShutdown this_ptr_conv;
30882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30883         this_ptr_conv.is_owned = false;
30884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30885         LDKThirtyTwoBytes val_ref;
30886         CHECK((*env)->GetArrayLength(env, val) == 32);
30887         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30888         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
30889 }
30890
30891 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30892         LDKShutdown this_ptr_conv;
30893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30894         this_ptr_conv.is_owned = false;
30895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30896         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
30897         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30898         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30899         return ret_arr;
30900 }
30901
30902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30903         LDKShutdown this_ptr_conv;
30904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30905         this_ptr_conv.is_owned = false;
30906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30907         LDKCVec_u8Z val_ref;
30908         val_ref.datalen = (*env)->GetArrayLength(env, val);
30909         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
30910         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
30911         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
30912 }
30913
30914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
30915         LDKThirtyTwoBytes channel_id_arg_ref;
30916         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30917         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30918         LDKCVec_u8Z scriptpubkey_arg_ref;
30919         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
30920         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
30921         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
30922         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
30923         uintptr_t ret_ref = 0;
30924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30927         ret_ref = (uintptr_t)ret_var.inner;
30928         if (ret_var.is_owned) {
30929                 ret_ref |= 1;
30930         }
30931         return ret_ref;
30932 }
30933
30934 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
30935         LDKShutdown ret_var = Shutdown_clone(arg);
30936 uintptr_t ret_ref = 0;
30937 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30938 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30939 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30940 ret_ref = (uintptr_t)ret_var.inner;
30941 if (ret_var.is_owned) {
30942         ret_ref |= 1;
30943 }
30944         return ret_ref;
30945 }
30946 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30947         LDKShutdown arg_conv;
30948         arg_conv.inner = (void*)(arg & (~1));
30949         arg_conv.is_owned = false;
30950         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30951         intptr_t ret_val = Shutdown_clone_ptr(&arg_conv);
30952         return ret_val;
30953 }
30954
30955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30956         LDKShutdown orig_conv;
30957         orig_conv.inner = (void*)(orig & (~1));
30958         orig_conv.is_owned = false;
30959         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30960         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
30961         uintptr_t ret_ref = 0;
30962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30965         ret_ref = (uintptr_t)ret_var.inner;
30966         if (ret_var.is_owned) {
30967                 ret_ref |= 1;
30968         }
30969         return ret_ref;
30970 }
30971
30972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30973         LDKClosingSignedFeeRange this_obj_conv;
30974         this_obj_conv.inner = (void*)(this_obj & (~1));
30975         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30977         ClosingSignedFeeRange_free(this_obj_conv);
30978 }
30979
30980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30981         LDKClosingSignedFeeRange this_ptr_conv;
30982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30983         this_ptr_conv.is_owned = false;
30984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30985         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
30986         return ret_val;
30987 }
30988
30989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30990         LDKClosingSignedFeeRange this_ptr_conv;
30991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30992         this_ptr_conv.is_owned = false;
30993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30994         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
30995 }
30996
30997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30998         LDKClosingSignedFeeRange this_ptr_conv;
30999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31000         this_ptr_conv.is_owned = false;
31001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31002         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
31003         return ret_val;
31004 }
31005
31006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31007         LDKClosingSignedFeeRange this_ptr_conv;
31008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31009         this_ptr_conv.is_owned = false;
31010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31011         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
31012 }
31013
31014 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) {
31015         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
31016         uintptr_t ret_ref = 0;
31017         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31018         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31020         ret_ref = (uintptr_t)ret_var.inner;
31021         if (ret_var.is_owned) {
31022                 ret_ref |= 1;
31023         }
31024         return ret_ref;
31025 }
31026
31027 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
31028         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
31029 uintptr_t ret_ref = 0;
31030 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31031 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31032 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31033 ret_ref = (uintptr_t)ret_var.inner;
31034 if (ret_var.is_owned) {
31035         ret_ref |= 1;
31036 }
31037         return ret_ref;
31038 }
31039 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31040         LDKClosingSignedFeeRange arg_conv;
31041         arg_conv.inner = (void*)(arg & (~1));
31042         arg_conv.is_owned = false;
31043         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31044         intptr_t ret_val = ClosingSignedFeeRange_clone_ptr(&arg_conv);
31045         return ret_val;
31046 }
31047
31048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31049         LDKClosingSignedFeeRange orig_conv;
31050         orig_conv.inner = (void*)(orig & (~1));
31051         orig_conv.is_owned = false;
31052         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31053         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
31054         uintptr_t ret_ref = 0;
31055         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31056         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31058         ret_ref = (uintptr_t)ret_var.inner;
31059         if (ret_var.is_owned) {
31060                 ret_ref |= 1;
31061         }
31062         return ret_ref;
31063 }
31064
31065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31066         LDKClosingSigned this_obj_conv;
31067         this_obj_conv.inner = (void*)(this_obj & (~1));
31068         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31070         ClosingSigned_free(this_obj_conv);
31071 }
31072
31073 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31074         LDKClosingSigned this_ptr_conv;
31075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31076         this_ptr_conv.is_owned = false;
31077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31078         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31079         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
31080         return ret_arr;
31081 }
31082
31083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31084         LDKClosingSigned this_ptr_conv;
31085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31086         this_ptr_conv.is_owned = false;
31087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31088         LDKThirtyTwoBytes val_ref;
31089         CHECK((*env)->GetArrayLength(env, val) == 32);
31090         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31091         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
31092 }
31093
31094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31095         LDKClosingSigned this_ptr_conv;
31096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31097         this_ptr_conv.is_owned = false;
31098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31099         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
31100         return ret_val;
31101 }
31102
31103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31104         LDKClosingSigned this_ptr_conv;
31105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31106         this_ptr_conv.is_owned = false;
31107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31108         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
31109 }
31110
31111 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
31112         LDKClosingSigned this_ptr_conv;
31113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31114         this_ptr_conv.is_owned = false;
31115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31116         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31117         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
31118         return ret_arr;
31119 }
31120
31121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31122         LDKClosingSigned this_ptr_conv;
31123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31124         this_ptr_conv.is_owned = false;
31125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31126         LDKSignature val_ref;
31127         CHECK((*env)->GetArrayLength(env, val) == 64);
31128         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31129         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
31130 }
31131
31132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
31133         LDKClosingSigned this_ptr_conv;
31134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31135         this_ptr_conv.is_owned = false;
31136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31137         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
31138         uintptr_t ret_ref = 0;
31139         if ((uintptr_t)ret_var.inner > 4096) {
31140                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31141                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31143                 ret_ref = (uintptr_t)ret_var.inner;
31144                 if (ret_var.is_owned) {
31145                         ret_ref |= 1;
31146                 }
31147         }
31148         return ret_ref;
31149 }
31150
31151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31152         LDKClosingSigned this_ptr_conv;
31153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31154         this_ptr_conv.is_owned = false;
31155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31156         LDKClosingSignedFeeRange val_conv;
31157         val_conv.inner = (void*)(val & (~1));
31158         val_conv.is_owned = (val & 1) || (val == 0);
31159         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31160         val_conv = ClosingSignedFeeRange_clone(&val_conv);
31161         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
31162 }
31163
31164 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) {
31165         LDKThirtyTwoBytes channel_id_arg_ref;
31166         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31167         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31168         LDKSignature signature_arg_ref;
31169         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
31170         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
31171         LDKClosingSignedFeeRange fee_range_arg_conv;
31172         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
31173         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
31174         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
31175         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
31176         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
31177         uintptr_t ret_ref = 0;
31178         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31179         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31181         ret_ref = (uintptr_t)ret_var.inner;
31182         if (ret_var.is_owned) {
31183                 ret_ref |= 1;
31184         }
31185         return ret_ref;
31186 }
31187
31188 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
31189         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
31190 uintptr_t ret_ref = 0;
31191 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31192 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31193 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31194 ret_ref = (uintptr_t)ret_var.inner;
31195 if (ret_var.is_owned) {
31196         ret_ref |= 1;
31197 }
31198         return ret_ref;
31199 }
31200 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31201         LDKClosingSigned arg_conv;
31202         arg_conv.inner = (void*)(arg & (~1));
31203         arg_conv.is_owned = false;
31204         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31205         intptr_t ret_val = ClosingSigned_clone_ptr(&arg_conv);
31206         return ret_val;
31207 }
31208
31209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31210         LDKClosingSigned orig_conv;
31211         orig_conv.inner = (void*)(orig & (~1));
31212         orig_conv.is_owned = false;
31213         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31214         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
31215         uintptr_t ret_ref = 0;
31216         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31217         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31219         ret_ref = (uintptr_t)ret_var.inner;
31220         if (ret_var.is_owned) {
31221                 ret_ref |= 1;
31222         }
31223         return ret_ref;
31224 }
31225
31226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31227         LDKUpdateAddHTLC this_obj_conv;
31228         this_obj_conv.inner = (void*)(this_obj & (~1));
31229         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31231         UpdateAddHTLC_free(this_obj_conv);
31232 }
31233
31234 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31235         LDKUpdateAddHTLC this_ptr_conv;
31236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31237         this_ptr_conv.is_owned = false;
31238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31239         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31240         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
31241         return ret_arr;
31242 }
31243
31244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31245         LDKUpdateAddHTLC this_ptr_conv;
31246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31247         this_ptr_conv.is_owned = false;
31248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31249         LDKThirtyTwoBytes val_ref;
31250         CHECK((*env)->GetArrayLength(env, val) == 32);
31251         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31252         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
31253 }
31254
31255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31256         LDKUpdateAddHTLC this_ptr_conv;
31257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31258         this_ptr_conv.is_owned = false;
31259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31260         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
31261         return ret_val;
31262 }
31263
31264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31265         LDKUpdateAddHTLC this_ptr_conv;
31266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31267         this_ptr_conv.is_owned = false;
31268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31269         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
31270 }
31271
31272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31273         LDKUpdateAddHTLC this_ptr_conv;
31274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31275         this_ptr_conv.is_owned = false;
31276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31277         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
31278         return ret_val;
31279 }
31280
31281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31282         LDKUpdateAddHTLC this_ptr_conv;
31283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31284         this_ptr_conv.is_owned = false;
31285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31286         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
31287 }
31288
31289 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
31290         LDKUpdateAddHTLC this_ptr_conv;
31291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31292         this_ptr_conv.is_owned = false;
31293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31294         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31295         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
31296         return ret_arr;
31297 }
31298
31299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31300         LDKUpdateAddHTLC this_ptr_conv;
31301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31302         this_ptr_conv.is_owned = false;
31303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31304         LDKThirtyTwoBytes val_ref;
31305         CHECK((*env)->GetArrayLength(env, val) == 32);
31306         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31307         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
31308 }
31309
31310 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
31311         LDKUpdateAddHTLC this_ptr_conv;
31312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31313         this_ptr_conv.is_owned = false;
31314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31315         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
31316         return ret_val;
31317 }
31318
31319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31320         LDKUpdateAddHTLC this_ptr_conv;
31321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31322         this_ptr_conv.is_owned = false;
31323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31324         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
31325 }
31326
31327 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
31328         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
31329 uintptr_t ret_ref = 0;
31330 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31331 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31332 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31333 ret_ref = (uintptr_t)ret_var.inner;
31334 if (ret_var.is_owned) {
31335         ret_ref |= 1;
31336 }
31337         return ret_ref;
31338 }
31339 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31340         LDKUpdateAddHTLC arg_conv;
31341         arg_conv.inner = (void*)(arg & (~1));
31342         arg_conv.is_owned = false;
31343         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31344         intptr_t ret_val = UpdateAddHTLC_clone_ptr(&arg_conv);
31345         return ret_val;
31346 }
31347
31348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31349         LDKUpdateAddHTLC orig_conv;
31350         orig_conv.inner = (void*)(orig & (~1));
31351         orig_conv.is_owned = false;
31352         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31353         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
31354         uintptr_t ret_ref = 0;
31355         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31356         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31358         ret_ref = (uintptr_t)ret_var.inner;
31359         if (ret_var.is_owned) {
31360                 ret_ref |= 1;
31361         }
31362         return ret_ref;
31363 }
31364
31365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31366         LDKUpdateFulfillHTLC this_obj_conv;
31367         this_obj_conv.inner = (void*)(this_obj & (~1));
31368         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31370         UpdateFulfillHTLC_free(this_obj_conv);
31371 }
31372
31373 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31374         LDKUpdateFulfillHTLC this_ptr_conv;
31375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31376         this_ptr_conv.is_owned = false;
31377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31378         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31379         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
31380         return ret_arr;
31381 }
31382
31383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31384         LDKUpdateFulfillHTLC this_ptr_conv;
31385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31386         this_ptr_conv.is_owned = false;
31387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31388         LDKThirtyTwoBytes val_ref;
31389         CHECK((*env)->GetArrayLength(env, val) == 32);
31390         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31391         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
31392 }
31393
31394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31395         LDKUpdateFulfillHTLC this_ptr_conv;
31396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31397         this_ptr_conv.is_owned = false;
31398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31399         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
31400         return ret_val;
31401 }
31402
31403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31404         LDKUpdateFulfillHTLC this_ptr_conv;
31405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31406         this_ptr_conv.is_owned = false;
31407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31408         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
31409 }
31410
31411 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
31412         LDKUpdateFulfillHTLC this_ptr_conv;
31413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31414         this_ptr_conv.is_owned = false;
31415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31416         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31417         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
31418         return ret_arr;
31419 }
31420
31421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31422         LDKUpdateFulfillHTLC this_ptr_conv;
31423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31424         this_ptr_conv.is_owned = false;
31425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31426         LDKThirtyTwoBytes val_ref;
31427         CHECK((*env)->GetArrayLength(env, val) == 32);
31428         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31429         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
31430 }
31431
31432 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) {
31433         LDKThirtyTwoBytes channel_id_arg_ref;
31434         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31435         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31436         LDKThirtyTwoBytes payment_preimage_arg_ref;
31437         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
31438         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
31439         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
31440         uintptr_t ret_ref = 0;
31441         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31442         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31444         ret_ref = (uintptr_t)ret_var.inner;
31445         if (ret_var.is_owned) {
31446                 ret_ref |= 1;
31447         }
31448         return ret_ref;
31449 }
31450
31451 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
31452         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
31453 uintptr_t ret_ref = 0;
31454 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31455 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31456 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31457 ret_ref = (uintptr_t)ret_var.inner;
31458 if (ret_var.is_owned) {
31459         ret_ref |= 1;
31460 }
31461         return ret_ref;
31462 }
31463 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31464         LDKUpdateFulfillHTLC arg_conv;
31465         arg_conv.inner = (void*)(arg & (~1));
31466         arg_conv.is_owned = false;
31467         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31468         intptr_t ret_val = UpdateFulfillHTLC_clone_ptr(&arg_conv);
31469         return ret_val;
31470 }
31471
31472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31473         LDKUpdateFulfillHTLC orig_conv;
31474         orig_conv.inner = (void*)(orig & (~1));
31475         orig_conv.is_owned = false;
31476         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31477         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
31478         uintptr_t ret_ref = 0;
31479         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31480         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31482         ret_ref = (uintptr_t)ret_var.inner;
31483         if (ret_var.is_owned) {
31484                 ret_ref |= 1;
31485         }
31486         return ret_ref;
31487 }
31488
31489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31490         LDKUpdateFailHTLC this_obj_conv;
31491         this_obj_conv.inner = (void*)(this_obj & (~1));
31492         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31494         UpdateFailHTLC_free(this_obj_conv);
31495 }
31496
31497 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31498         LDKUpdateFailHTLC this_ptr_conv;
31499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31500         this_ptr_conv.is_owned = false;
31501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31502         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31503         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
31504         return ret_arr;
31505 }
31506
31507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31508         LDKUpdateFailHTLC this_ptr_conv;
31509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31510         this_ptr_conv.is_owned = false;
31511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31512         LDKThirtyTwoBytes val_ref;
31513         CHECK((*env)->GetArrayLength(env, val) == 32);
31514         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31515         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
31516 }
31517
31518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31519         LDKUpdateFailHTLC this_ptr_conv;
31520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31521         this_ptr_conv.is_owned = false;
31522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31523         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
31524         return ret_val;
31525 }
31526
31527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31528         LDKUpdateFailHTLC this_ptr_conv;
31529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31530         this_ptr_conv.is_owned = false;
31531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31532         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
31533 }
31534
31535 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
31536         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
31537 uintptr_t ret_ref = 0;
31538 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31539 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31540 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31541 ret_ref = (uintptr_t)ret_var.inner;
31542 if (ret_var.is_owned) {
31543         ret_ref |= 1;
31544 }
31545         return ret_ref;
31546 }
31547 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31548         LDKUpdateFailHTLC arg_conv;
31549         arg_conv.inner = (void*)(arg & (~1));
31550         arg_conv.is_owned = false;
31551         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31552         intptr_t ret_val = UpdateFailHTLC_clone_ptr(&arg_conv);
31553         return ret_val;
31554 }
31555
31556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31557         LDKUpdateFailHTLC orig_conv;
31558         orig_conv.inner = (void*)(orig & (~1));
31559         orig_conv.is_owned = false;
31560         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31561         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
31562         uintptr_t ret_ref = 0;
31563         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31564         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31566         ret_ref = (uintptr_t)ret_var.inner;
31567         if (ret_var.is_owned) {
31568                 ret_ref |= 1;
31569         }
31570         return ret_ref;
31571 }
31572
31573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31574         LDKUpdateFailMalformedHTLC this_obj_conv;
31575         this_obj_conv.inner = (void*)(this_obj & (~1));
31576         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31578         UpdateFailMalformedHTLC_free(this_obj_conv);
31579 }
31580
31581 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31582         LDKUpdateFailMalformedHTLC this_ptr_conv;
31583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31584         this_ptr_conv.is_owned = false;
31585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31586         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31587         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
31588         return ret_arr;
31589 }
31590
31591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31592         LDKUpdateFailMalformedHTLC this_ptr_conv;
31593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31594         this_ptr_conv.is_owned = false;
31595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31596         LDKThirtyTwoBytes val_ref;
31597         CHECK((*env)->GetArrayLength(env, val) == 32);
31598         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31599         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
31600 }
31601
31602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31603         LDKUpdateFailMalformedHTLC this_ptr_conv;
31604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31605         this_ptr_conv.is_owned = false;
31606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31607         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
31608         return ret_val;
31609 }
31610
31611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31612         LDKUpdateFailMalformedHTLC this_ptr_conv;
31613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31614         this_ptr_conv.is_owned = false;
31615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31616         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
31617 }
31618
31619 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
31620         LDKUpdateFailMalformedHTLC this_ptr_conv;
31621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31622         this_ptr_conv.is_owned = false;
31623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31624         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
31625         return ret_val;
31626 }
31627
31628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31629         LDKUpdateFailMalformedHTLC this_ptr_conv;
31630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31631         this_ptr_conv.is_owned = false;
31632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31633         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
31634 }
31635
31636 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
31637         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
31638 uintptr_t ret_ref = 0;
31639 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31640 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31641 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31642 ret_ref = (uintptr_t)ret_var.inner;
31643 if (ret_var.is_owned) {
31644         ret_ref |= 1;
31645 }
31646         return ret_ref;
31647 }
31648 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31649         LDKUpdateFailMalformedHTLC arg_conv;
31650         arg_conv.inner = (void*)(arg & (~1));
31651         arg_conv.is_owned = false;
31652         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31653         intptr_t ret_val = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
31654         return ret_val;
31655 }
31656
31657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31658         LDKUpdateFailMalformedHTLC orig_conv;
31659         orig_conv.inner = (void*)(orig & (~1));
31660         orig_conv.is_owned = false;
31661         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31662         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
31663         uintptr_t ret_ref = 0;
31664         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31665         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31667         ret_ref = (uintptr_t)ret_var.inner;
31668         if (ret_var.is_owned) {
31669                 ret_ref |= 1;
31670         }
31671         return ret_ref;
31672 }
31673
31674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31675         LDKCommitmentSigned this_obj_conv;
31676         this_obj_conv.inner = (void*)(this_obj & (~1));
31677         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31679         CommitmentSigned_free(this_obj_conv);
31680 }
31681
31682 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31683         LDKCommitmentSigned this_ptr_conv;
31684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31685         this_ptr_conv.is_owned = false;
31686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31687         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31688         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
31689         return ret_arr;
31690 }
31691
31692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31693         LDKCommitmentSigned this_ptr_conv;
31694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31695         this_ptr_conv.is_owned = false;
31696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31697         LDKThirtyTwoBytes val_ref;
31698         CHECK((*env)->GetArrayLength(env, val) == 32);
31699         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31700         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
31701 }
31702
31703 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
31704         LDKCommitmentSigned this_ptr_conv;
31705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31706         this_ptr_conv.is_owned = false;
31707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31708         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31709         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
31710         return ret_arr;
31711 }
31712
31713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31714         LDKCommitmentSigned this_ptr_conv;
31715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31716         this_ptr_conv.is_owned = false;
31717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31718         LDKSignature val_ref;
31719         CHECK((*env)->GetArrayLength(env, val) == 64);
31720         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31721         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
31722 }
31723
31724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
31725         LDKCommitmentSigned this_ptr_conv;
31726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31727         this_ptr_conv.is_owned = false;
31728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31729         LDKCVec_SignatureZ val_constr;
31730         val_constr.datalen = (*env)->GetArrayLength(env, val);
31731         if (val_constr.datalen > 0)
31732                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
31733         else
31734                 val_constr.data = NULL;
31735         for (size_t i = 0; i < val_constr.datalen; i++) {
31736                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
31737                 LDKSignature val_conv_8_ref;
31738                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
31739                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
31740                 val_constr.data[i] = val_conv_8_ref;
31741         }
31742         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
31743 }
31744
31745 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) {
31746         LDKThirtyTwoBytes channel_id_arg_ref;
31747         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31748         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31749         LDKSignature signature_arg_ref;
31750         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
31751         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
31752         LDKCVec_SignatureZ htlc_signatures_arg_constr;
31753         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
31754         if (htlc_signatures_arg_constr.datalen > 0)
31755                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
31756         else
31757                 htlc_signatures_arg_constr.data = NULL;
31758         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
31759                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
31760                 LDKSignature htlc_signatures_arg_conv_8_ref;
31761                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
31762                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
31763                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
31764         }
31765         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
31766         uintptr_t ret_ref = 0;
31767         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31768         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31770         ret_ref = (uintptr_t)ret_var.inner;
31771         if (ret_var.is_owned) {
31772                 ret_ref |= 1;
31773         }
31774         return ret_ref;
31775 }
31776
31777 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
31778         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
31779 uintptr_t ret_ref = 0;
31780 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31781 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31782 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31783 ret_ref = (uintptr_t)ret_var.inner;
31784 if (ret_var.is_owned) {
31785         ret_ref |= 1;
31786 }
31787         return ret_ref;
31788 }
31789 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31790         LDKCommitmentSigned arg_conv;
31791         arg_conv.inner = (void*)(arg & (~1));
31792         arg_conv.is_owned = false;
31793         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31794         intptr_t ret_val = CommitmentSigned_clone_ptr(&arg_conv);
31795         return ret_val;
31796 }
31797
31798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31799         LDKCommitmentSigned orig_conv;
31800         orig_conv.inner = (void*)(orig & (~1));
31801         orig_conv.is_owned = false;
31802         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31803         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
31804         uintptr_t ret_ref = 0;
31805         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31806         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31808         ret_ref = (uintptr_t)ret_var.inner;
31809         if (ret_var.is_owned) {
31810                 ret_ref |= 1;
31811         }
31812         return ret_ref;
31813 }
31814
31815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31816         LDKRevokeAndACK this_obj_conv;
31817         this_obj_conv.inner = (void*)(this_obj & (~1));
31818         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31820         RevokeAndACK_free(this_obj_conv);
31821 }
31822
31823 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31824         LDKRevokeAndACK this_ptr_conv;
31825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31826         this_ptr_conv.is_owned = false;
31827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31828         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31829         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
31830         return ret_arr;
31831 }
31832
31833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31834         LDKRevokeAndACK this_ptr_conv;
31835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31836         this_ptr_conv.is_owned = false;
31837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31838         LDKThirtyTwoBytes val_ref;
31839         CHECK((*env)->GetArrayLength(env, val) == 32);
31840         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31841         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
31842 }
31843
31844 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
31845         LDKRevokeAndACK this_ptr_conv;
31846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31847         this_ptr_conv.is_owned = false;
31848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31849         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31850         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
31851         return ret_arr;
31852 }
31853
31854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31855         LDKRevokeAndACK this_ptr_conv;
31856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31857         this_ptr_conv.is_owned = false;
31858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31859         LDKThirtyTwoBytes val_ref;
31860         CHECK((*env)->GetArrayLength(env, val) == 32);
31861         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31862         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
31863 }
31864
31865 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31866         LDKRevokeAndACK this_ptr_conv;
31867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31868         this_ptr_conv.is_owned = false;
31869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31870         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31871         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
31872         return ret_arr;
31873 }
31874
31875 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) {
31876         LDKRevokeAndACK this_ptr_conv;
31877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31878         this_ptr_conv.is_owned = false;
31879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31880         LDKPublicKey val_ref;
31881         CHECK((*env)->GetArrayLength(env, val) == 33);
31882         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31883         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
31884 }
31885
31886 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) {
31887         LDKThirtyTwoBytes channel_id_arg_ref;
31888         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31889         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31890         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
31891         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
31892         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
31893         LDKPublicKey next_per_commitment_point_arg_ref;
31894         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
31895         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
31896         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
31897         uintptr_t ret_ref = 0;
31898         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31899         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31901         ret_ref = (uintptr_t)ret_var.inner;
31902         if (ret_var.is_owned) {
31903                 ret_ref |= 1;
31904         }
31905         return ret_ref;
31906 }
31907
31908 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
31909         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
31910 uintptr_t ret_ref = 0;
31911 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31912 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31913 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31914 ret_ref = (uintptr_t)ret_var.inner;
31915 if (ret_var.is_owned) {
31916         ret_ref |= 1;
31917 }
31918         return ret_ref;
31919 }
31920 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31921         LDKRevokeAndACK arg_conv;
31922         arg_conv.inner = (void*)(arg & (~1));
31923         arg_conv.is_owned = false;
31924         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31925         intptr_t ret_val = RevokeAndACK_clone_ptr(&arg_conv);
31926         return ret_val;
31927 }
31928
31929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31930         LDKRevokeAndACK orig_conv;
31931         orig_conv.inner = (void*)(orig & (~1));
31932         orig_conv.is_owned = false;
31933         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31934         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
31935         uintptr_t ret_ref = 0;
31936         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31937         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31939         ret_ref = (uintptr_t)ret_var.inner;
31940         if (ret_var.is_owned) {
31941                 ret_ref |= 1;
31942         }
31943         return ret_ref;
31944 }
31945
31946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31947         LDKUpdateFee this_obj_conv;
31948         this_obj_conv.inner = (void*)(this_obj & (~1));
31949         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31951         UpdateFee_free(this_obj_conv);
31952 }
31953
31954 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31955         LDKUpdateFee this_ptr_conv;
31956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31957         this_ptr_conv.is_owned = false;
31958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31959         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31960         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
31961         return ret_arr;
31962 }
31963
31964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31965         LDKUpdateFee this_ptr_conv;
31966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31967         this_ptr_conv.is_owned = false;
31968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31969         LDKThirtyTwoBytes val_ref;
31970         CHECK((*env)->GetArrayLength(env, val) == 32);
31971         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31972         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
31973 }
31974
31975 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
31976         LDKUpdateFee this_ptr_conv;
31977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31978         this_ptr_conv.is_owned = false;
31979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31980         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
31981         return ret_val;
31982 }
31983
31984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31985         LDKUpdateFee this_ptr_conv;
31986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31987         this_ptr_conv.is_owned = false;
31988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31989         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
31990 }
31991
31992 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) {
31993         LDKThirtyTwoBytes channel_id_arg_ref;
31994         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31995         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31996         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
31997         uintptr_t ret_ref = 0;
31998         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31999         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32001         ret_ref = (uintptr_t)ret_var.inner;
32002         if (ret_var.is_owned) {
32003                 ret_ref |= 1;
32004         }
32005         return ret_ref;
32006 }
32007
32008 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
32009         LDKUpdateFee ret_var = UpdateFee_clone(arg);
32010 uintptr_t ret_ref = 0;
32011 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32012 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32013 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32014 ret_ref = (uintptr_t)ret_var.inner;
32015 if (ret_var.is_owned) {
32016         ret_ref |= 1;
32017 }
32018         return ret_ref;
32019 }
32020 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32021         LDKUpdateFee arg_conv;
32022         arg_conv.inner = (void*)(arg & (~1));
32023         arg_conv.is_owned = false;
32024         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32025         intptr_t ret_val = UpdateFee_clone_ptr(&arg_conv);
32026         return ret_val;
32027 }
32028
32029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32030         LDKUpdateFee orig_conv;
32031         orig_conv.inner = (void*)(orig & (~1));
32032         orig_conv.is_owned = false;
32033         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32034         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
32035         uintptr_t ret_ref = 0;
32036         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32037         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32039         ret_ref = (uintptr_t)ret_var.inner;
32040         if (ret_var.is_owned) {
32041                 ret_ref |= 1;
32042         }
32043         return ret_ref;
32044 }
32045
32046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32047         LDKDataLossProtect this_obj_conv;
32048         this_obj_conv.inner = (void*)(this_obj & (~1));
32049         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32051         DataLossProtect_free(this_obj_conv);
32052 }
32053
32054 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
32055         LDKDataLossProtect this_ptr_conv;
32056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32057         this_ptr_conv.is_owned = false;
32058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32059         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32060         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
32061         return ret_arr;
32062 }
32063
32064 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) {
32065         LDKDataLossProtect 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         LDKThirtyTwoBytes val_ref;
32070         CHECK((*env)->GetArrayLength(env, val) == 32);
32071         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32072         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
32073 }
32074
32075 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32076         LDKDataLossProtect this_ptr_conv;
32077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32078         this_ptr_conv.is_owned = false;
32079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32080         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32081         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
32082         return ret_arr;
32083 }
32084
32085 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) {
32086         LDKDataLossProtect 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         LDKPublicKey val_ref;
32091         CHECK((*env)->GetArrayLength(env, val) == 33);
32092         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32093         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
32094 }
32095
32096 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) {
32097         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
32098         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
32099         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
32100         LDKPublicKey my_current_per_commitment_point_arg_ref;
32101         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
32102         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
32103         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
32104         uintptr_t ret_ref = 0;
32105         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32106         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32108         ret_ref = (uintptr_t)ret_var.inner;
32109         if (ret_var.is_owned) {
32110                 ret_ref |= 1;
32111         }
32112         return ret_ref;
32113 }
32114
32115 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
32116         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
32117 uintptr_t ret_ref = 0;
32118 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32119 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32120 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32121 ret_ref = (uintptr_t)ret_var.inner;
32122 if (ret_var.is_owned) {
32123         ret_ref |= 1;
32124 }
32125         return ret_ref;
32126 }
32127 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32128         LDKDataLossProtect arg_conv;
32129         arg_conv.inner = (void*)(arg & (~1));
32130         arg_conv.is_owned = false;
32131         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32132         intptr_t ret_val = DataLossProtect_clone_ptr(&arg_conv);
32133         return ret_val;
32134 }
32135
32136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32137         LDKDataLossProtect orig_conv;
32138         orig_conv.inner = (void*)(orig & (~1));
32139         orig_conv.is_owned = false;
32140         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32141         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
32142         uintptr_t ret_ref = 0;
32143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32146         ret_ref = (uintptr_t)ret_var.inner;
32147         if (ret_var.is_owned) {
32148                 ret_ref |= 1;
32149         }
32150         return ret_ref;
32151 }
32152
32153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32154         LDKChannelReestablish this_obj_conv;
32155         this_obj_conv.inner = (void*)(this_obj & (~1));
32156         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32158         ChannelReestablish_free(this_obj_conv);
32159 }
32160
32161 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32162         LDKChannelReestablish this_ptr_conv;
32163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32164         this_ptr_conv.is_owned = false;
32165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32166         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32167         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
32168         return ret_arr;
32169 }
32170
32171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32172         LDKChannelReestablish this_ptr_conv;
32173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32174         this_ptr_conv.is_owned = false;
32175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32176         LDKThirtyTwoBytes val_ref;
32177         CHECK((*env)->GetArrayLength(env, val) == 32);
32178         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32179         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
32180 }
32181
32182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
32183         LDKChannelReestablish this_ptr_conv;
32184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32185         this_ptr_conv.is_owned = false;
32186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32187         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
32188         return ret_val;
32189 }
32190
32191 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) {
32192         LDKChannelReestablish this_ptr_conv;
32193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32194         this_ptr_conv.is_owned = false;
32195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32196         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
32197 }
32198
32199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
32200         LDKChannelReestablish this_ptr_conv;
32201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32202         this_ptr_conv.is_owned = false;
32203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32204         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
32205         return ret_val;
32206 }
32207
32208 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) {
32209         LDKChannelReestablish this_ptr_conv;
32210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32211         this_ptr_conv.is_owned = false;
32212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32213         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
32214 }
32215
32216 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
32217         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
32218 uintptr_t ret_ref = 0;
32219 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32220 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32221 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32222 ret_ref = (uintptr_t)ret_var.inner;
32223 if (ret_var.is_owned) {
32224         ret_ref |= 1;
32225 }
32226         return ret_ref;
32227 }
32228 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32229         LDKChannelReestablish arg_conv;
32230         arg_conv.inner = (void*)(arg & (~1));
32231         arg_conv.is_owned = false;
32232         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32233         intptr_t ret_val = ChannelReestablish_clone_ptr(&arg_conv);
32234         return ret_val;
32235 }
32236
32237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32238         LDKChannelReestablish orig_conv;
32239         orig_conv.inner = (void*)(orig & (~1));
32240         orig_conv.is_owned = false;
32241         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32242         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
32243         uintptr_t ret_ref = 0;
32244         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32245         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32247         ret_ref = (uintptr_t)ret_var.inner;
32248         if (ret_var.is_owned) {
32249                 ret_ref |= 1;
32250         }
32251         return ret_ref;
32252 }
32253
32254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32255         LDKAnnouncementSignatures this_obj_conv;
32256         this_obj_conv.inner = (void*)(this_obj & (~1));
32257         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32259         AnnouncementSignatures_free(this_obj_conv);
32260 }
32261
32262 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32263         LDKAnnouncementSignatures this_ptr_conv;
32264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32265         this_ptr_conv.is_owned = false;
32266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32267         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32268         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
32269         return ret_arr;
32270 }
32271
32272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32273         LDKAnnouncementSignatures this_ptr_conv;
32274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32275         this_ptr_conv.is_owned = false;
32276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32277         LDKThirtyTwoBytes val_ref;
32278         CHECK((*env)->GetArrayLength(env, val) == 32);
32279         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32280         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
32281 }
32282
32283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32284         LDKAnnouncementSignatures this_ptr_conv;
32285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32286         this_ptr_conv.is_owned = false;
32287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32288         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
32289         return ret_val;
32290 }
32291
32292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32293         LDKAnnouncementSignatures this_ptr_conv;
32294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32295         this_ptr_conv.is_owned = false;
32296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32297         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
32298 }
32299
32300 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32301         LDKAnnouncementSignatures this_ptr_conv;
32302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32303         this_ptr_conv.is_owned = false;
32304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32305         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32306         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
32307         return ret_arr;
32308 }
32309
32310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32311         LDKAnnouncementSignatures this_ptr_conv;
32312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32313         this_ptr_conv.is_owned = false;
32314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32315         LDKSignature val_ref;
32316         CHECK((*env)->GetArrayLength(env, val) == 64);
32317         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32318         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
32319 }
32320
32321 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32322         LDKAnnouncementSignatures this_ptr_conv;
32323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32324         this_ptr_conv.is_owned = false;
32325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32326         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32327         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
32328         return ret_arr;
32329 }
32330
32331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32332         LDKAnnouncementSignatures this_ptr_conv;
32333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32334         this_ptr_conv.is_owned = false;
32335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32336         LDKSignature val_ref;
32337         CHECK((*env)->GetArrayLength(env, val) == 64);
32338         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32339         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
32340 }
32341
32342 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) {
32343         LDKThirtyTwoBytes channel_id_arg_ref;
32344         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32345         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32346         LDKSignature node_signature_arg_ref;
32347         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
32348         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
32349         LDKSignature bitcoin_signature_arg_ref;
32350         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
32351         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
32352         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
32353         uintptr_t ret_ref = 0;
32354         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32355         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32357         ret_ref = (uintptr_t)ret_var.inner;
32358         if (ret_var.is_owned) {
32359                 ret_ref |= 1;
32360         }
32361         return ret_ref;
32362 }
32363
32364 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
32365         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
32366 uintptr_t ret_ref = 0;
32367 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32368 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32369 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32370 ret_ref = (uintptr_t)ret_var.inner;
32371 if (ret_var.is_owned) {
32372         ret_ref |= 1;
32373 }
32374         return ret_ref;
32375 }
32376 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32377         LDKAnnouncementSignatures arg_conv;
32378         arg_conv.inner = (void*)(arg & (~1));
32379         arg_conv.is_owned = false;
32380         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32381         intptr_t ret_val = AnnouncementSignatures_clone_ptr(&arg_conv);
32382         return ret_val;
32383 }
32384
32385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32386         LDKAnnouncementSignatures orig_conv;
32387         orig_conv.inner = (void*)(orig & (~1));
32388         orig_conv.is_owned = false;
32389         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32390         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
32391         uintptr_t ret_ref = 0;
32392         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32393         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32395         ret_ref = (uintptr_t)ret_var.inner;
32396         if (ret_var.is_owned) {
32397                 ret_ref |= 1;
32398         }
32399         return ret_ref;
32400 }
32401
32402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32403         if ((this_ptr & 1) != 0) return;
32404         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32405         CHECK_ACCESS(this_ptr_ptr);
32406         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
32407         FREE((void*)this_ptr);
32408         NetAddress_free(this_ptr_conv);
32409 }
32410
32411 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
32412         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
32413         *ret_copy = NetAddress_clone(arg);
32414 uintptr_t ret_ref = (uintptr_t)ret_copy;
32415         return ret_ref;
32416 }
32417 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32418         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
32419         intptr_t ret_val = NetAddress_clone_ptr(arg_conv);
32420         return ret_val;
32421 }
32422
32423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32424         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
32425         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
32426         *ret_copy = NetAddress_clone(orig_conv);
32427         uintptr_t ret_ref = (uintptr_t)ret_copy;
32428         return ret_ref;
32429 }
32430
32431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
32432         LDKFourBytes addr_ref;
32433         CHECK((*env)->GetArrayLength(env, addr) == 4);
32434         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
32435         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
32436         *ret_copy = NetAddress_ipv4(addr_ref, port);
32437         uintptr_t ret_ref = (uintptr_t)ret_copy;
32438         return ret_ref;
32439 }
32440
32441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
32442         LDKSixteenBytes addr_ref;
32443         CHECK((*env)->GetArrayLength(env, addr) == 16);
32444         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
32445         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
32446         *ret_copy = NetAddress_ipv6(addr_ref, port);
32447         uintptr_t ret_ref = (uintptr_t)ret_copy;
32448         return ret_ref;
32449 }
32450
32451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
32452         LDKTwelveBytes a_ref;
32453         CHECK((*env)->GetArrayLength(env, a) == 12);
32454         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
32455         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
32456         *ret_copy = NetAddress_onion_v2(a_ref);
32457         uintptr_t ret_ref = (uintptr_t)ret_copy;
32458         return ret_ref;
32459 }
32460
32461 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) {
32462         LDKThirtyTwoBytes ed25519_pubkey_ref;
32463         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
32464         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
32465         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
32466         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
32467         uintptr_t ret_ref = (uintptr_t)ret_copy;
32468         return ret_ref;
32469 }
32470
32471 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
32472         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
32473         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
32474         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32475         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32476         CVec_u8Z_free(ret_var);
32477         return ret_arr;
32478 }
32479
32480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32481         LDKu8slice ser_ref;
32482         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32483         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32484         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
32485         *ret_conv = NetAddress_read(ser_ref);
32486         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32487         return (uintptr_t)ret_conv;
32488 }
32489
32490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32491         LDKUnsignedNodeAnnouncement this_obj_conv;
32492         this_obj_conv.inner = (void*)(this_obj & (~1));
32493         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32495         UnsignedNodeAnnouncement_free(this_obj_conv);
32496 }
32497
32498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
32499         LDKUnsignedNodeAnnouncement 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         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
32504         uintptr_t ret_ref = 0;
32505         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32506         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32508         ret_ref = (uintptr_t)ret_var.inner;
32509         if (ret_var.is_owned) {
32510                 ret_ref |= 1;
32511         }
32512         return ret_ref;
32513 }
32514
32515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32516         LDKUnsignedNodeAnnouncement 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         LDKNodeFeatures val_conv;
32521         val_conv.inner = (void*)(val & (~1));
32522         val_conv.is_owned = (val & 1) || (val == 0);
32523         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32524         val_conv = NodeFeatures_clone(&val_conv);
32525         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
32526 }
32527
32528 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
32529         LDKUnsignedNodeAnnouncement this_ptr_conv;
32530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32531         this_ptr_conv.is_owned = false;
32532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32533         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
32534         return ret_val;
32535 }
32536
32537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32538         LDKUnsignedNodeAnnouncement this_ptr_conv;
32539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32540         this_ptr_conv.is_owned = false;
32541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32542         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
32543 }
32544
32545 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32546         LDKUnsignedNodeAnnouncement this_ptr_conv;
32547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32548         this_ptr_conv.is_owned = false;
32549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32550         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32551         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
32552         return ret_arr;
32553 }
32554
32555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32556         LDKUnsignedNodeAnnouncement this_ptr_conv;
32557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32558         this_ptr_conv.is_owned = false;
32559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32560         LDKPublicKey val_ref;
32561         CHECK((*env)->GetArrayLength(env, val) == 33);
32562         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32563         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
32564 }
32565
32566 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
32567         LDKUnsignedNodeAnnouncement this_ptr_conv;
32568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32569         this_ptr_conv.is_owned = false;
32570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32571         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
32572         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
32573         return ret_arr;
32574 }
32575
32576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32577         LDKUnsignedNodeAnnouncement this_ptr_conv;
32578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32579         this_ptr_conv.is_owned = false;
32580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32581         LDKThreeBytes val_ref;
32582         CHECK((*env)->GetArrayLength(env, val) == 3);
32583         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
32584         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
32585 }
32586
32587 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
32588         LDKUnsignedNodeAnnouncement this_ptr_conv;
32589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32590         this_ptr_conv.is_owned = false;
32591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32592         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32593         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
32594         return ret_arr;
32595 }
32596
32597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32598         LDKUnsignedNodeAnnouncement this_ptr_conv;
32599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32600         this_ptr_conv.is_owned = false;
32601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32602         LDKThirtyTwoBytes val_ref;
32603         CHECK((*env)->GetArrayLength(env, val) == 32);
32604         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32605         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
32606 }
32607
32608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
32609         LDKUnsignedNodeAnnouncement this_ptr_conv;
32610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32611         this_ptr_conv.is_owned = false;
32612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32613         LDKCVec_NetAddressZ val_constr;
32614         val_constr.datalen = (*env)->GetArrayLength(env, val);
32615         if (val_constr.datalen > 0)
32616                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
32617         else
32618                 val_constr.data = NULL;
32619         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
32620         for (size_t m = 0; m < val_constr.datalen; m++) {
32621                 int64_t val_conv_12 = val_vals[m];
32622                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
32623                 CHECK_ACCESS(val_conv_12_ptr);
32624                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
32625                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
32626                 val_constr.data[m] = val_conv_12_conv;
32627         }
32628         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
32629         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
32630 }
32631
32632 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
32633         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
32634 uintptr_t ret_ref = 0;
32635 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32636 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32637 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32638 ret_ref = (uintptr_t)ret_var.inner;
32639 if (ret_var.is_owned) {
32640         ret_ref |= 1;
32641 }
32642         return ret_ref;
32643 }
32644 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32645         LDKUnsignedNodeAnnouncement arg_conv;
32646         arg_conv.inner = (void*)(arg & (~1));
32647         arg_conv.is_owned = false;
32648         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32649         intptr_t ret_val = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
32650         return ret_val;
32651 }
32652
32653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32654         LDKUnsignedNodeAnnouncement orig_conv;
32655         orig_conv.inner = (void*)(orig & (~1));
32656         orig_conv.is_owned = false;
32657         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32658         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
32659         uintptr_t ret_ref = 0;
32660         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32661         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32663         ret_ref = (uintptr_t)ret_var.inner;
32664         if (ret_var.is_owned) {
32665                 ret_ref |= 1;
32666         }
32667         return ret_ref;
32668 }
32669
32670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32671         LDKNodeAnnouncement this_obj_conv;
32672         this_obj_conv.inner = (void*)(this_obj & (~1));
32673         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32675         NodeAnnouncement_free(this_obj_conv);
32676 }
32677
32678 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32679         LDKNodeAnnouncement this_ptr_conv;
32680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32681         this_ptr_conv.is_owned = false;
32682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32683         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32684         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
32685         return ret_arr;
32686 }
32687
32688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32689         LDKNodeAnnouncement this_ptr_conv;
32690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32691         this_ptr_conv.is_owned = false;
32692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32693         LDKSignature val_ref;
32694         CHECK((*env)->GetArrayLength(env, val) == 64);
32695         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32696         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
32697 }
32698
32699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
32700         LDKNodeAnnouncement this_ptr_conv;
32701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32702         this_ptr_conv.is_owned = false;
32703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32704         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
32705         uintptr_t ret_ref = 0;
32706         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32707         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32709         ret_ref = (uintptr_t)ret_var.inner;
32710         if (ret_var.is_owned) {
32711                 ret_ref |= 1;
32712         }
32713         return ret_ref;
32714 }
32715
32716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32717         LDKNodeAnnouncement this_ptr_conv;
32718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32719         this_ptr_conv.is_owned = false;
32720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32721         LDKUnsignedNodeAnnouncement val_conv;
32722         val_conv.inner = (void*)(val & (~1));
32723         val_conv.is_owned = (val & 1) || (val == 0);
32724         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32725         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
32726         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
32727 }
32728
32729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
32730         LDKSignature signature_arg_ref;
32731         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
32732         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
32733         LDKUnsignedNodeAnnouncement contents_arg_conv;
32734         contents_arg_conv.inner = (void*)(contents_arg & (~1));
32735         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
32736         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
32737         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
32738         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
32739         uintptr_t ret_ref = 0;
32740         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32741         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32743         ret_ref = (uintptr_t)ret_var.inner;
32744         if (ret_var.is_owned) {
32745                 ret_ref |= 1;
32746         }
32747         return ret_ref;
32748 }
32749
32750 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
32751         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
32752 uintptr_t ret_ref = 0;
32753 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32754 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32755 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32756 ret_ref = (uintptr_t)ret_var.inner;
32757 if (ret_var.is_owned) {
32758         ret_ref |= 1;
32759 }
32760         return ret_ref;
32761 }
32762 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32763         LDKNodeAnnouncement arg_conv;
32764         arg_conv.inner = (void*)(arg & (~1));
32765         arg_conv.is_owned = false;
32766         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32767         intptr_t ret_val = NodeAnnouncement_clone_ptr(&arg_conv);
32768         return ret_val;
32769 }
32770
32771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32772         LDKNodeAnnouncement orig_conv;
32773         orig_conv.inner = (void*)(orig & (~1));
32774         orig_conv.is_owned = false;
32775         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32776         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
32777         uintptr_t ret_ref = 0;
32778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32781         ret_ref = (uintptr_t)ret_var.inner;
32782         if (ret_var.is_owned) {
32783                 ret_ref |= 1;
32784         }
32785         return ret_ref;
32786 }
32787
32788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32789         LDKUnsignedChannelAnnouncement this_obj_conv;
32790         this_obj_conv.inner = (void*)(this_obj & (~1));
32791         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32793         UnsignedChannelAnnouncement_free(this_obj_conv);
32794 }
32795
32796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
32797         LDKUnsignedChannelAnnouncement this_ptr_conv;
32798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32799         this_ptr_conv.is_owned = false;
32800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32801         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
32802         uintptr_t ret_ref = 0;
32803         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32804         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32806         ret_ref = (uintptr_t)ret_var.inner;
32807         if (ret_var.is_owned) {
32808                 ret_ref |= 1;
32809         }
32810         return ret_ref;
32811 }
32812
32813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32814         LDKUnsignedChannelAnnouncement this_ptr_conv;
32815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32816         this_ptr_conv.is_owned = false;
32817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32818         LDKChannelFeatures val_conv;
32819         val_conv.inner = (void*)(val & (~1));
32820         val_conv.is_owned = (val & 1) || (val == 0);
32821         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32822         val_conv = ChannelFeatures_clone(&val_conv);
32823         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
32824 }
32825
32826 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
32827         LDKUnsignedChannelAnnouncement this_ptr_conv;
32828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32829         this_ptr_conv.is_owned = false;
32830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32831         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32832         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
32833         return ret_arr;
32834 }
32835
32836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32837         LDKUnsignedChannelAnnouncement this_ptr_conv;
32838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32839         this_ptr_conv.is_owned = false;
32840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32841         LDKThirtyTwoBytes val_ref;
32842         CHECK((*env)->GetArrayLength(env, val) == 32);
32843         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32844         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
32845 }
32846
32847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32848         LDKUnsignedChannelAnnouncement this_ptr_conv;
32849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32850         this_ptr_conv.is_owned = false;
32851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32852         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
32853         return ret_val;
32854 }
32855
32856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32857         LDKUnsignedChannelAnnouncement this_ptr_conv;
32858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32859         this_ptr_conv.is_owned = false;
32860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32861         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
32862 }
32863
32864 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
32865         LDKUnsignedChannelAnnouncement this_ptr_conv;
32866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32867         this_ptr_conv.is_owned = false;
32868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32869         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32870         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
32871         return ret_arr;
32872 }
32873
32874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32875         LDKUnsignedChannelAnnouncement this_ptr_conv;
32876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32877         this_ptr_conv.is_owned = false;
32878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32879         LDKPublicKey val_ref;
32880         CHECK((*env)->GetArrayLength(env, val) == 33);
32881         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32882         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
32883 }
32884
32885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
32886         LDKUnsignedChannelAnnouncement 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32891         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
32892         return ret_arr;
32893 }
32894
32895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32896         LDKUnsignedChannelAnnouncement this_ptr_conv;
32897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32898         this_ptr_conv.is_owned = false;
32899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32900         LDKPublicKey val_ref;
32901         CHECK((*env)->GetArrayLength(env, val) == 33);
32902         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32903         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
32904 }
32905
32906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
32907         LDKUnsignedChannelAnnouncement this_ptr_conv;
32908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32909         this_ptr_conv.is_owned = false;
32910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32911         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32912         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
32913         return ret_arr;
32914 }
32915
32916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32917         LDKUnsignedChannelAnnouncement this_ptr_conv;
32918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32919         this_ptr_conv.is_owned = false;
32920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32921         LDKPublicKey val_ref;
32922         CHECK((*env)->GetArrayLength(env, val) == 33);
32923         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32924         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
32925 }
32926
32927 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
32928         LDKUnsignedChannelAnnouncement this_ptr_conv;
32929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32930         this_ptr_conv.is_owned = false;
32931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32932         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32933         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
32934         return ret_arr;
32935 }
32936
32937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32938         LDKUnsignedChannelAnnouncement this_ptr_conv;
32939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32940         this_ptr_conv.is_owned = false;
32941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32942         LDKPublicKey val_ref;
32943         CHECK((*env)->GetArrayLength(env, val) == 33);
32944         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32945         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
32946 }
32947
32948 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
32949         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
32950 uintptr_t ret_ref = 0;
32951 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32952 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32953 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32954 ret_ref = (uintptr_t)ret_var.inner;
32955 if (ret_var.is_owned) {
32956         ret_ref |= 1;
32957 }
32958         return ret_ref;
32959 }
32960 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32961         LDKUnsignedChannelAnnouncement arg_conv;
32962         arg_conv.inner = (void*)(arg & (~1));
32963         arg_conv.is_owned = false;
32964         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32965         intptr_t ret_val = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
32966         return ret_val;
32967 }
32968
32969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32970         LDKUnsignedChannelAnnouncement orig_conv;
32971         orig_conv.inner = (void*)(orig & (~1));
32972         orig_conv.is_owned = false;
32973         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32974         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
32975         uintptr_t ret_ref = 0;
32976         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32977         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32979         ret_ref = (uintptr_t)ret_var.inner;
32980         if (ret_var.is_owned) {
32981                 ret_ref |= 1;
32982         }
32983         return ret_ref;
32984 }
32985
32986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32987         LDKChannelAnnouncement this_obj_conv;
32988         this_obj_conv.inner = (void*)(this_obj & (~1));
32989         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32991         ChannelAnnouncement_free(this_obj_conv);
32992 }
32993
32994 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
32995         LDKChannelAnnouncement this_ptr_conv;
32996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32997         this_ptr_conv.is_owned = false;
32998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32999         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33000         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
33001         return ret_arr;
33002 }
33003
33004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33005         LDKChannelAnnouncement this_ptr_conv;
33006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33007         this_ptr_conv.is_owned = false;
33008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33009         LDKSignature val_ref;
33010         CHECK((*env)->GetArrayLength(env, val) == 64);
33011         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33012         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
33013 }
33014
33015 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33016         LDKChannelAnnouncement this_ptr_conv;
33017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33018         this_ptr_conv.is_owned = false;
33019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33020         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33021         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
33022         return ret_arr;
33023 }
33024
33025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33026         LDKChannelAnnouncement this_ptr_conv;
33027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33028         this_ptr_conv.is_owned = false;
33029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33030         LDKSignature val_ref;
33031         CHECK((*env)->GetArrayLength(env, val) == 64);
33032         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33033         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
33034 }
33035
33036 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33037         LDKChannelAnnouncement this_ptr_conv;
33038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33039         this_ptr_conv.is_owned = false;
33040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33041         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33042         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
33043         return ret_arr;
33044 }
33045
33046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33047         LDKChannelAnnouncement this_ptr_conv;
33048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33049         this_ptr_conv.is_owned = false;
33050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33051         LDKSignature val_ref;
33052         CHECK((*env)->GetArrayLength(env, val) == 64);
33053         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33054         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
33055 }
33056
33057 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33058         LDKChannelAnnouncement this_ptr_conv;
33059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33060         this_ptr_conv.is_owned = false;
33061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33062         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33063         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
33064         return ret_arr;
33065 }
33066
33067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33068         LDKChannelAnnouncement this_ptr_conv;
33069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33070         this_ptr_conv.is_owned = false;
33071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33072         LDKSignature val_ref;
33073         CHECK((*env)->GetArrayLength(env, val) == 64);
33074         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33075         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
33076 }
33077
33078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
33079         LDKChannelAnnouncement this_ptr_conv;
33080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33081         this_ptr_conv.is_owned = false;
33082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33083         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
33084         uintptr_t ret_ref = 0;
33085         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33086         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33087         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33088         ret_ref = (uintptr_t)ret_var.inner;
33089         if (ret_var.is_owned) {
33090                 ret_ref |= 1;
33091         }
33092         return ret_ref;
33093 }
33094
33095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33096         LDKChannelAnnouncement this_ptr_conv;
33097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33098         this_ptr_conv.is_owned = false;
33099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33100         LDKUnsignedChannelAnnouncement val_conv;
33101         val_conv.inner = (void*)(val & (~1));
33102         val_conv.is_owned = (val & 1) || (val == 0);
33103         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33104         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
33105         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
33106 }
33107
33108 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) {
33109         LDKSignature node_signature_1_arg_ref;
33110         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
33111         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
33112         LDKSignature node_signature_2_arg_ref;
33113         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
33114         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
33115         LDKSignature bitcoin_signature_1_arg_ref;
33116         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
33117         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
33118         LDKSignature bitcoin_signature_2_arg_ref;
33119         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
33120         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
33121         LDKUnsignedChannelAnnouncement contents_arg_conv;
33122         contents_arg_conv.inner = (void*)(contents_arg & (~1));
33123         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
33124         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
33125         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
33126         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);
33127         uintptr_t ret_ref = 0;
33128         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33129         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33131         ret_ref = (uintptr_t)ret_var.inner;
33132         if (ret_var.is_owned) {
33133                 ret_ref |= 1;
33134         }
33135         return ret_ref;
33136 }
33137
33138 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
33139         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
33140 uintptr_t ret_ref = 0;
33141 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33142 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33143 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33144 ret_ref = (uintptr_t)ret_var.inner;
33145 if (ret_var.is_owned) {
33146         ret_ref |= 1;
33147 }
33148         return ret_ref;
33149 }
33150 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33151         LDKChannelAnnouncement arg_conv;
33152         arg_conv.inner = (void*)(arg & (~1));
33153         arg_conv.is_owned = false;
33154         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33155         intptr_t ret_val = ChannelAnnouncement_clone_ptr(&arg_conv);
33156         return ret_val;
33157 }
33158
33159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33160         LDKChannelAnnouncement orig_conv;
33161         orig_conv.inner = (void*)(orig & (~1));
33162         orig_conv.is_owned = false;
33163         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33164         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
33165         uintptr_t ret_ref = 0;
33166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33169         ret_ref = (uintptr_t)ret_var.inner;
33170         if (ret_var.is_owned) {
33171                 ret_ref |= 1;
33172         }
33173         return ret_ref;
33174 }
33175
33176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33177         LDKUnsignedChannelUpdate this_obj_conv;
33178         this_obj_conv.inner = (void*)(this_obj & (~1));
33179         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33181         UnsignedChannelUpdate_free(this_obj_conv);
33182 }
33183
33184 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33185         LDKUnsignedChannelUpdate this_ptr_conv;
33186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33187         this_ptr_conv.is_owned = false;
33188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33189         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33190         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
33191         return ret_arr;
33192 }
33193
33194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33195         LDKUnsignedChannelUpdate this_ptr_conv;
33196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33197         this_ptr_conv.is_owned = false;
33198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33199         LDKThirtyTwoBytes val_ref;
33200         CHECK((*env)->GetArrayLength(env, val) == 32);
33201         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33202         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
33203 }
33204
33205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33206         LDKUnsignedChannelUpdate this_ptr_conv;
33207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33208         this_ptr_conv.is_owned = false;
33209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33210         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
33211         return ret_val;
33212 }
33213
33214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33215         LDKUnsignedChannelUpdate this_ptr_conv;
33216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33217         this_ptr_conv.is_owned = false;
33218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33219         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
33220 }
33221
33222 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
33223         LDKUnsignedChannelUpdate this_ptr_conv;
33224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33225         this_ptr_conv.is_owned = false;
33226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33227         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
33228         return ret_val;
33229 }
33230
33231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33232         LDKUnsignedChannelUpdate this_ptr_conv;
33233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33234         this_ptr_conv.is_owned = false;
33235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33236         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
33237 }
33238
33239 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
33240         LDKUnsignedChannelUpdate this_ptr_conv;
33241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33242         this_ptr_conv.is_owned = false;
33243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33244         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
33245         return ret_val;
33246 }
33247
33248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
33249         LDKUnsignedChannelUpdate this_ptr_conv;
33250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33251         this_ptr_conv.is_owned = false;
33252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33253         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
33254 }
33255
33256 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
33257         LDKUnsignedChannelUpdate this_ptr_conv;
33258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33259         this_ptr_conv.is_owned = false;
33260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33261         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
33262         return ret_val;
33263 }
33264
33265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33266         LDKUnsignedChannelUpdate this_ptr_conv;
33267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33268         this_ptr_conv.is_owned = false;
33269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33270         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
33271 }
33272
33273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33274         LDKUnsignedChannelUpdate this_ptr_conv;
33275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33276         this_ptr_conv.is_owned = false;
33277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33278         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
33279         return ret_val;
33280 }
33281
33282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33283         LDKUnsignedChannelUpdate this_ptr_conv;
33284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33285         this_ptr_conv.is_owned = false;
33286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33287         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
33288 }
33289
33290 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33291         LDKUnsignedChannelUpdate this_ptr_conv;
33292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33293         this_ptr_conv.is_owned = false;
33294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33295         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
33296         return ret_val;
33297 }
33298
33299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33300         LDKUnsignedChannelUpdate this_ptr_conv;
33301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33302         this_ptr_conv.is_owned = false;
33303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33304         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
33305 }
33306
33307 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
33308         LDKUnsignedChannelUpdate this_ptr_conv;
33309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33310         this_ptr_conv.is_owned = false;
33311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33312         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
33313         return ret_val;
33314 }
33315
33316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33317         LDKUnsignedChannelUpdate this_ptr_conv;
33318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33319         this_ptr_conv.is_owned = false;
33320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33321         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
33322 }
33323
33324 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
33325         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
33326 uintptr_t ret_ref = 0;
33327 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33328 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33329 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33330 ret_ref = (uintptr_t)ret_var.inner;
33331 if (ret_var.is_owned) {
33332         ret_ref |= 1;
33333 }
33334         return ret_ref;
33335 }
33336 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33337         LDKUnsignedChannelUpdate arg_conv;
33338         arg_conv.inner = (void*)(arg & (~1));
33339         arg_conv.is_owned = false;
33340         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33341         intptr_t ret_val = UnsignedChannelUpdate_clone_ptr(&arg_conv);
33342         return ret_val;
33343 }
33344
33345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33346         LDKUnsignedChannelUpdate orig_conv;
33347         orig_conv.inner = (void*)(orig & (~1));
33348         orig_conv.is_owned = false;
33349         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33350         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
33351         uintptr_t ret_ref = 0;
33352         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33353         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33355         ret_ref = (uintptr_t)ret_var.inner;
33356         if (ret_var.is_owned) {
33357                 ret_ref |= 1;
33358         }
33359         return ret_ref;
33360 }
33361
33362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33363         LDKChannelUpdate this_obj_conv;
33364         this_obj_conv.inner = (void*)(this_obj & (~1));
33365         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33367         ChannelUpdate_free(this_obj_conv);
33368 }
33369
33370 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33371         LDKChannelUpdate this_ptr_conv;
33372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33373         this_ptr_conv.is_owned = false;
33374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33375         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33376         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
33377         return ret_arr;
33378 }
33379
33380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33381         LDKChannelUpdate this_ptr_conv;
33382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33383         this_ptr_conv.is_owned = false;
33384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33385         LDKSignature val_ref;
33386         CHECK((*env)->GetArrayLength(env, val) == 64);
33387         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33388         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
33389 }
33390
33391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
33392         LDKChannelUpdate this_ptr_conv;
33393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33394         this_ptr_conv.is_owned = false;
33395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33396         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
33397         uintptr_t ret_ref = 0;
33398         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33399         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33401         ret_ref = (uintptr_t)ret_var.inner;
33402         if (ret_var.is_owned) {
33403                 ret_ref |= 1;
33404         }
33405         return ret_ref;
33406 }
33407
33408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33409         LDKChannelUpdate this_ptr_conv;
33410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33411         this_ptr_conv.is_owned = false;
33412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33413         LDKUnsignedChannelUpdate val_conv;
33414         val_conv.inner = (void*)(val & (~1));
33415         val_conv.is_owned = (val & 1) || (val == 0);
33416         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33417         val_conv = UnsignedChannelUpdate_clone(&val_conv);
33418         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
33419 }
33420
33421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
33422         LDKSignature signature_arg_ref;
33423         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33424         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33425         LDKUnsignedChannelUpdate contents_arg_conv;
33426         contents_arg_conv.inner = (void*)(contents_arg & (~1));
33427         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
33428         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
33429         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
33430         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
33431         uintptr_t ret_ref = 0;
33432         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33433         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33435         ret_ref = (uintptr_t)ret_var.inner;
33436         if (ret_var.is_owned) {
33437                 ret_ref |= 1;
33438         }
33439         return ret_ref;
33440 }
33441
33442 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
33443         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
33444 uintptr_t ret_ref = 0;
33445 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33446 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33447 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33448 ret_ref = (uintptr_t)ret_var.inner;
33449 if (ret_var.is_owned) {
33450         ret_ref |= 1;
33451 }
33452         return ret_ref;
33453 }
33454 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33455         LDKChannelUpdate arg_conv;
33456         arg_conv.inner = (void*)(arg & (~1));
33457         arg_conv.is_owned = false;
33458         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33459         intptr_t ret_val = ChannelUpdate_clone_ptr(&arg_conv);
33460         return ret_val;
33461 }
33462
33463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33464         LDKChannelUpdate orig_conv;
33465         orig_conv.inner = (void*)(orig & (~1));
33466         orig_conv.is_owned = false;
33467         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33468         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
33469         uintptr_t ret_ref = 0;
33470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33473         ret_ref = (uintptr_t)ret_var.inner;
33474         if (ret_var.is_owned) {
33475                 ret_ref |= 1;
33476         }
33477         return ret_ref;
33478 }
33479
33480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33481         LDKQueryChannelRange this_obj_conv;
33482         this_obj_conv.inner = (void*)(this_obj & (~1));
33483         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33485         QueryChannelRange_free(this_obj_conv);
33486 }
33487
33488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33489         LDKQueryChannelRange this_ptr_conv;
33490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33491         this_ptr_conv.is_owned = false;
33492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33493         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33494         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
33495         return ret_arr;
33496 }
33497
33498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33499         LDKQueryChannelRange this_ptr_conv;
33500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33501         this_ptr_conv.is_owned = false;
33502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33503         LDKThirtyTwoBytes val_ref;
33504         CHECK((*env)->GetArrayLength(env, val) == 32);
33505         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33506         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
33507 }
33508
33509 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
33510         LDKQueryChannelRange this_ptr_conv;
33511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33512         this_ptr_conv.is_owned = false;
33513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33514         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
33515         return ret_val;
33516 }
33517
33518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33519         LDKQueryChannelRange 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         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
33524 }
33525
33526 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
33527         LDKQueryChannelRange this_ptr_conv;
33528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33529         this_ptr_conv.is_owned = false;
33530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33531         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
33532         return ret_val;
33533 }
33534
33535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33536         LDKQueryChannelRange this_ptr_conv;
33537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33538         this_ptr_conv.is_owned = false;
33539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33540         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
33541 }
33542
33543 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) {
33544         LDKThirtyTwoBytes chain_hash_arg_ref;
33545         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
33546         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
33547         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
33548         uintptr_t ret_ref = 0;
33549         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33550         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33552         ret_ref = (uintptr_t)ret_var.inner;
33553         if (ret_var.is_owned) {
33554                 ret_ref |= 1;
33555         }
33556         return ret_ref;
33557 }
33558
33559 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
33560         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
33561 uintptr_t ret_ref = 0;
33562 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33563 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33564 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33565 ret_ref = (uintptr_t)ret_var.inner;
33566 if (ret_var.is_owned) {
33567         ret_ref |= 1;
33568 }
33569         return ret_ref;
33570 }
33571 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33572         LDKQueryChannelRange arg_conv;
33573         arg_conv.inner = (void*)(arg & (~1));
33574         arg_conv.is_owned = false;
33575         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33576         intptr_t ret_val = QueryChannelRange_clone_ptr(&arg_conv);
33577         return ret_val;
33578 }
33579
33580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33581         LDKQueryChannelRange orig_conv;
33582         orig_conv.inner = (void*)(orig & (~1));
33583         orig_conv.is_owned = false;
33584         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33585         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
33586         uintptr_t ret_ref = 0;
33587         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33588         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33590         ret_ref = (uintptr_t)ret_var.inner;
33591         if (ret_var.is_owned) {
33592                 ret_ref |= 1;
33593         }
33594         return ret_ref;
33595 }
33596
33597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33598         LDKReplyChannelRange this_obj_conv;
33599         this_obj_conv.inner = (void*)(this_obj & (~1));
33600         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33602         ReplyChannelRange_free(this_obj_conv);
33603 }
33604
33605 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33606         LDKReplyChannelRange 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33611         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
33612         return ret_arr;
33613 }
33614
33615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33616         LDKReplyChannelRange this_ptr_conv;
33617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33618         this_ptr_conv.is_owned = false;
33619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33620         LDKThirtyTwoBytes val_ref;
33621         CHECK((*env)->GetArrayLength(env, val) == 32);
33622         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33623         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
33624 }
33625
33626 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
33627         LDKReplyChannelRange this_ptr_conv;
33628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33629         this_ptr_conv.is_owned = false;
33630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33631         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
33632         return ret_val;
33633 }
33634
33635 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33636         LDKReplyChannelRange this_ptr_conv;
33637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33638         this_ptr_conv.is_owned = false;
33639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33640         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
33641 }
33642
33643 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
33644         LDKReplyChannelRange this_ptr_conv;
33645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33646         this_ptr_conv.is_owned = false;
33647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33648         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
33649         return ret_val;
33650 }
33651
33652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33653         LDKReplyChannelRange this_ptr_conv;
33654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33655         this_ptr_conv.is_owned = false;
33656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33657         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
33658 }
33659
33660 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
33661         LDKReplyChannelRange this_ptr_conv;
33662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33663         this_ptr_conv.is_owned = false;
33664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33665         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
33666         return ret_val;
33667 }
33668
33669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
33670         LDKReplyChannelRange this_ptr_conv;
33671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33672         this_ptr_conv.is_owned = false;
33673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33674         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
33675 }
33676
33677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
33678         LDKReplyChannelRange this_ptr_conv;
33679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33680         this_ptr_conv.is_owned = false;
33681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33682         LDKCVec_u64Z val_constr;
33683         val_constr.datalen = (*env)->GetArrayLength(env, val);
33684         if (val_constr.datalen > 0)
33685                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
33686         else
33687                 val_constr.data = NULL;
33688         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
33689         for (size_t g = 0; g < val_constr.datalen; g++) {
33690                 int64_t val_conv_6 = val_vals[g];
33691                 val_constr.data[g] = val_conv_6;
33692         }
33693         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
33694         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
33695 }
33696
33697 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) {
33698         LDKThirtyTwoBytes chain_hash_arg_ref;
33699         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
33700         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
33701         LDKCVec_u64Z short_channel_ids_arg_constr;
33702         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
33703         if (short_channel_ids_arg_constr.datalen > 0)
33704                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
33705         else
33706                 short_channel_ids_arg_constr.data = NULL;
33707         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
33708         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
33709                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
33710                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
33711         }
33712         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
33713         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
33714         uintptr_t ret_ref = 0;
33715         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33716         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33718         ret_ref = (uintptr_t)ret_var.inner;
33719         if (ret_var.is_owned) {
33720                 ret_ref |= 1;
33721         }
33722         return ret_ref;
33723 }
33724
33725 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
33726         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
33727 uintptr_t ret_ref = 0;
33728 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33729 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33730 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33731 ret_ref = (uintptr_t)ret_var.inner;
33732 if (ret_var.is_owned) {
33733         ret_ref |= 1;
33734 }
33735         return ret_ref;
33736 }
33737 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33738         LDKReplyChannelRange arg_conv;
33739         arg_conv.inner = (void*)(arg & (~1));
33740         arg_conv.is_owned = false;
33741         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33742         intptr_t ret_val = ReplyChannelRange_clone_ptr(&arg_conv);
33743         return ret_val;
33744 }
33745
33746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33747         LDKReplyChannelRange orig_conv;
33748         orig_conv.inner = (void*)(orig & (~1));
33749         orig_conv.is_owned = false;
33750         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33751         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
33752         uintptr_t ret_ref = 0;
33753         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33754         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33756         ret_ref = (uintptr_t)ret_var.inner;
33757         if (ret_var.is_owned) {
33758                 ret_ref |= 1;
33759         }
33760         return ret_ref;
33761 }
33762
33763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33764         LDKQueryShortChannelIds this_obj_conv;
33765         this_obj_conv.inner = (void*)(this_obj & (~1));
33766         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33768         QueryShortChannelIds_free(this_obj_conv);
33769 }
33770
33771 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33772         LDKQueryShortChannelIds this_ptr_conv;
33773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33774         this_ptr_conv.is_owned = false;
33775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33776         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33777         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
33778         return ret_arr;
33779 }
33780
33781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33782         LDKQueryShortChannelIds this_ptr_conv;
33783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33784         this_ptr_conv.is_owned = false;
33785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33786         LDKThirtyTwoBytes val_ref;
33787         CHECK((*env)->GetArrayLength(env, val) == 32);
33788         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33789         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
33790 }
33791
33792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
33793         LDKQueryShortChannelIds this_ptr_conv;
33794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33795         this_ptr_conv.is_owned = false;
33796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33797         LDKCVec_u64Z val_constr;
33798         val_constr.datalen = (*env)->GetArrayLength(env, val);
33799         if (val_constr.datalen > 0)
33800                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
33801         else
33802                 val_constr.data = NULL;
33803         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
33804         for (size_t g = 0; g < val_constr.datalen; g++) {
33805                 int64_t val_conv_6 = val_vals[g];
33806                 val_constr.data[g] = val_conv_6;
33807         }
33808         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
33809         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
33810 }
33811
33812 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) {
33813         LDKThirtyTwoBytes chain_hash_arg_ref;
33814         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
33815         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
33816         LDKCVec_u64Z short_channel_ids_arg_constr;
33817         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
33818         if (short_channel_ids_arg_constr.datalen > 0)
33819                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
33820         else
33821                 short_channel_ids_arg_constr.data = NULL;
33822         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
33823         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
33824                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
33825                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
33826         }
33827         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
33828         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
33829         uintptr_t ret_ref = 0;
33830         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33831         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33832         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33833         ret_ref = (uintptr_t)ret_var.inner;
33834         if (ret_var.is_owned) {
33835                 ret_ref |= 1;
33836         }
33837         return ret_ref;
33838 }
33839
33840 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
33841         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
33842 uintptr_t ret_ref = 0;
33843 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33844 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33845 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33846 ret_ref = (uintptr_t)ret_var.inner;
33847 if (ret_var.is_owned) {
33848         ret_ref |= 1;
33849 }
33850         return ret_ref;
33851 }
33852 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33853         LDKQueryShortChannelIds arg_conv;
33854         arg_conv.inner = (void*)(arg & (~1));
33855         arg_conv.is_owned = false;
33856         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33857         intptr_t ret_val = QueryShortChannelIds_clone_ptr(&arg_conv);
33858         return ret_val;
33859 }
33860
33861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33862         LDKQueryShortChannelIds orig_conv;
33863         orig_conv.inner = (void*)(orig & (~1));
33864         orig_conv.is_owned = false;
33865         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33866         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
33867         uintptr_t ret_ref = 0;
33868         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33869         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33871         ret_ref = (uintptr_t)ret_var.inner;
33872         if (ret_var.is_owned) {
33873                 ret_ref |= 1;
33874         }
33875         return ret_ref;
33876 }
33877
33878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33879         LDKReplyShortChannelIdsEnd this_obj_conv;
33880         this_obj_conv.inner = (void*)(this_obj & (~1));
33881         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33883         ReplyShortChannelIdsEnd_free(this_obj_conv);
33884 }
33885
33886 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33887         LDKReplyShortChannelIdsEnd this_ptr_conv;
33888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33889         this_ptr_conv.is_owned = false;
33890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33891         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33892         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
33893         return ret_arr;
33894 }
33895
33896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33897         LDKReplyShortChannelIdsEnd this_ptr_conv;
33898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33899         this_ptr_conv.is_owned = false;
33900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33901         LDKThirtyTwoBytes val_ref;
33902         CHECK((*env)->GetArrayLength(env, val) == 32);
33903         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33904         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
33905 }
33906
33907 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
33908         LDKReplyShortChannelIdsEnd this_ptr_conv;
33909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33910         this_ptr_conv.is_owned = false;
33911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33912         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
33913         return ret_val;
33914 }
33915
33916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
33917         LDKReplyShortChannelIdsEnd this_ptr_conv;
33918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33919         this_ptr_conv.is_owned = false;
33920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33921         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
33922 }
33923
33924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
33925         LDKThirtyTwoBytes chain_hash_arg_ref;
33926         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
33927         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
33928         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
33929         uintptr_t ret_ref = 0;
33930         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33931         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33932         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33933         ret_ref = (uintptr_t)ret_var.inner;
33934         if (ret_var.is_owned) {
33935                 ret_ref |= 1;
33936         }
33937         return ret_ref;
33938 }
33939
33940 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
33941         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
33942 uintptr_t ret_ref = 0;
33943 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33944 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33945 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33946 ret_ref = (uintptr_t)ret_var.inner;
33947 if (ret_var.is_owned) {
33948         ret_ref |= 1;
33949 }
33950         return ret_ref;
33951 }
33952 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33953         LDKReplyShortChannelIdsEnd arg_conv;
33954         arg_conv.inner = (void*)(arg & (~1));
33955         arg_conv.is_owned = false;
33956         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33957         intptr_t ret_val = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
33958         return ret_val;
33959 }
33960
33961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33962         LDKReplyShortChannelIdsEnd orig_conv;
33963         orig_conv.inner = (void*)(orig & (~1));
33964         orig_conv.is_owned = false;
33965         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33966         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
33967         uintptr_t ret_ref = 0;
33968         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33969         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33970         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33971         ret_ref = (uintptr_t)ret_var.inner;
33972         if (ret_var.is_owned) {
33973                 ret_ref |= 1;
33974         }
33975         return ret_ref;
33976 }
33977
33978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33979         LDKGossipTimestampFilter this_obj_conv;
33980         this_obj_conv.inner = (void*)(this_obj & (~1));
33981         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33983         GossipTimestampFilter_free(this_obj_conv);
33984 }
33985
33986 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33987         LDKGossipTimestampFilter this_ptr_conv;
33988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33989         this_ptr_conv.is_owned = false;
33990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33991         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33992         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
33993         return ret_arr;
33994 }
33995
33996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33997         LDKGossipTimestampFilter this_ptr_conv;
33998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33999         this_ptr_conv.is_owned = false;
34000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34001         LDKThirtyTwoBytes val_ref;
34002         CHECK((*env)->GetArrayLength(env, val) == 32);
34003         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34004         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
34005 }
34006
34007 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
34008         LDKGossipTimestampFilter this_ptr_conv;
34009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34010         this_ptr_conv.is_owned = false;
34011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34012         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
34013         return ret_val;
34014 }
34015
34016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34017         LDKGossipTimestampFilter this_ptr_conv;
34018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34019         this_ptr_conv.is_owned = false;
34020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34021         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
34022 }
34023
34024 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
34025         LDKGossipTimestampFilter this_ptr_conv;
34026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34027         this_ptr_conv.is_owned = false;
34028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34029         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
34030         return ret_val;
34031 }
34032
34033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34034         LDKGossipTimestampFilter this_ptr_conv;
34035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34036         this_ptr_conv.is_owned = false;
34037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34038         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
34039 }
34040
34041 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) {
34042         LDKThirtyTwoBytes chain_hash_arg_ref;
34043         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34044         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34045         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
34046         uintptr_t ret_ref = 0;
34047         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34048         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34049         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34050         ret_ref = (uintptr_t)ret_var.inner;
34051         if (ret_var.is_owned) {
34052                 ret_ref |= 1;
34053         }
34054         return ret_ref;
34055 }
34056
34057 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
34058         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
34059 uintptr_t ret_ref = 0;
34060 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34061 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34062 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34063 ret_ref = (uintptr_t)ret_var.inner;
34064 if (ret_var.is_owned) {
34065         ret_ref |= 1;
34066 }
34067         return ret_ref;
34068 }
34069 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34070         LDKGossipTimestampFilter arg_conv;
34071         arg_conv.inner = (void*)(arg & (~1));
34072         arg_conv.is_owned = false;
34073         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34074         intptr_t ret_val = GossipTimestampFilter_clone_ptr(&arg_conv);
34075         return ret_val;
34076 }
34077
34078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34079         LDKGossipTimestampFilter orig_conv;
34080         orig_conv.inner = (void*)(orig & (~1));
34081         orig_conv.is_owned = false;
34082         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34083         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
34084         uintptr_t ret_ref = 0;
34085         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34086         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34087         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34088         ret_ref = (uintptr_t)ret_var.inner;
34089         if (ret_var.is_owned) {
34090                 ret_ref |= 1;
34091         }
34092         return ret_ref;
34093 }
34094
34095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34096         if ((this_ptr & 1) != 0) return;
34097         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34098         CHECK_ACCESS(this_ptr_ptr);
34099         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
34100         FREE((void*)this_ptr);
34101         ErrorAction_free(this_ptr_conv);
34102 }
34103
34104 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
34105         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34106         *ret_copy = ErrorAction_clone(arg);
34107 uintptr_t ret_ref = (uintptr_t)ret_copy;
34108         return ret_ref;
34109 }
34110 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34111         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
34112         intptr_t ret_val = ErrorAction_clone_ptr(arg_conv);
34113         return ret_val;
34114 }
34115
34116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34117         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
34118         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34119         *ret_copy = ErrorAction_clone(orig_conv);
34120         uintptr_t ret_ref = (uintptr_t)ret_copy;
34121         return ret_ref;
34122 }
34123
34124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
34125         LDKErrorMessage msg_conv;
34126         msg_conv.inner = (void*)(msg & (~1));
34127         msg_conv.is_owned = (msg & 1) || (msg == 0);
34128         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
34129         msg_conv = ErrorMessage_clone(&msg_conv);
34130         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34131         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
34132         uintptr_t ret_ref = (uintptr_t)ret_copy;
34133         return ret_ref;
34134 }
34135
34136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
34137         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34138         *ret_copy = ErrorAction_ignore_error();
34139         uintptr_t ret_ref = (uintptr_t)ret_copy;
34140         return ret_ref;
34141 }
34142
34143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
34144         LDKLevel a_conv = LDKLevel_from_java(env, a);
34145         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34146         *ret_copy = ErrorAction_ignore_and_log(a_conv);
34147         uintptr_t ret_ref = (uintptr_t)ret_copy;
34148         return ret_ref;
34149 }
34150
34151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
34152         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34153         *ret_copy = ErrorAction_ignore_duplicate_gossip();
34154         uintptr_t ret_ref = (uintptr_t)ret_copy;
34155         return ret_ref;
34156 }
34157
34158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
34159         LDKErrorMessage msg_conv;
34160         msg_conv.inner = (void*)(msg & (~1));
34161         msg_conv.is_owned = (msg & 1) || (msg == 0);
34162         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
34163         msg_conv = ErrorMessage_clone(&msg_conv);
34164         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34165         *ret_copy = ErrorAction_send_error_message(msg_conv);
34166         uintptr_t ret_ref = (uintptr_t)ret_copy;
34167         return ret_ref;
34168 }
34169
34170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
34171         LDKWarningMessage msg_conv;
34172         msg_conv.inner = (void*)(msg & (~1));
34173         msg_conv.is_owned = (msg & 1) || (msg == 0);
34174         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
34175         msg_conv = WarningMessage_clone(&msg_conv);
34176         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
34177         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34178         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
34179         uintptr_t ret_ref = (uintptr_t)ret_copy;
34180         return ret_ref;
34181 }
34182
34183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34184         LDKLightningError this_obj_conv;
34185         this_obj_conv.inner = (void*)(this_obj & (~1));
34186         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34188         LightningError_free(this_obj_conv);
34189 }
34190
34191 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
34192         LDKLightningError this_ptr_conv;
34193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34194         this_ptr_conv.is_owned = false;
34195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34196         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
34197         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34198         Str_free(ret_str);
34199         return ret_conv;
34200 }
34201
34202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34203         LDKLightningError this_ptr_conv;
34204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34205         this_ptr_conv.is_owned = false;
34206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34207         LDKStr val_conv = java_to_owned_str(env, val);
34208         LightningError_set_err(&this_ptr_conv, val_conv);
34209 }
34210
34211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
34212         LDKLightningError this_ptr_conv;
34213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34214         this_ptr_conv.is_owned = false;
34215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34216         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34217         *ret_copy = LightningError_get_action(&this_ptr_conv);
34218         uintptr_t ret_ref = (uintptr_t)ret_copy;
34219         return ret_ref;
34220 }
34221
34222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34223         LDKLightningError this_ptr_conv;
34224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34225         this_ptr_conv.is_owned = false;
34226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34227         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34228         CHECK_ACCESS(val_ptr);
34229         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
34230         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
34231         LightningError_set_action(&this_ptr_conv, val_conv);
34232 }
34233
34234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
34235         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
34236         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
34237         CHECK_ACCESS(action_arg_ptr);
34238         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
34239         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
34240         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
34241         uintptr_t ret_ref = 0;
34242         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34243         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34245         ret_ref = (uintptr_t)ret_var.inner;
34246         if (ret_var.is_owned) {
34247                 ret_ref |= 1;
34248         }
34249         return ret_ref;
34250 }
34251
34252 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
34253         LDKLightningError ret_var = LightningError_clone(arg);
34254 uintptr_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 intptr_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34265         LDKLightningError 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         intptr_t ret_val = LightningError_clone_ptr(&arg_conv);
34270         return ret_val;
34271 }
34272
34273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34274         LDKLightningError 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         LDKLightningError ret_var = LightningError_clone(&orig_conv);
34279         uintptr_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_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34291         LDKCommitmentUpdate 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         CommitmentUpdate_free(this_obj_conv);
34296 }
34297
34298 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
34299         LDKCommitmentUpdate 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         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
34304         int64_tArray ret_arr = NULL;
34305         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
34306         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
34307         for (size_t p = 0; p < ret_var.datalen; p++) {
34308                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
34309                 uintptr_t ret_conv_15_ref = 0;
34310                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34311                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34312                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
34313                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
34314                 if (ret_conv_15_var.is_owned) {
34315                         ret_conv_15_ref |= 1;
34316                 }
34317                 ret_arr_ptr[p] = ret_conv_15_ref;
34318         }
34319         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
34320         FREE(ret_var.data);
34321         return ret_arr;
34322 }
34323
34324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
34325         LDKCommitmentUpdate this_ptr_conv;
34326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34327         this_ptr_conv.is_owned = false;
34328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34329         LDKCVec_UpdateAddHTLCZ val_constr;
34330         val_constr.datalen = (*env)->GetArrayLength(env, val);
34331         if (val_constr.datalen > 0)
34332                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
34333         else
34334                 val_constr.data = NULL;
34335         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34336         for (size_t p = 0; p < val_constr.datalen; p++) {
34337                 int64_t val_conv_15 = val_vals[p];
34338                 LDKUpdateAddHTLC val_conv_15_conv;
34339                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
34340                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
34341                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
34342                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
34343                 val_constr.data[p] = val_conv_15_conv;
34344         }
34345         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34346         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
34347 }
34348
34349 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
34350         LDKCommitmentUpdate this_ptr_conv;
34351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34352         this_ptr_conv.is_owned = false;
34353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34354         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
34355         int64_tArray ret_arr = NULL;
34356         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
34357         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
34358         for (size_t t = 0; t < ret_var.datalen; t++) {
34359                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
34360                 uintptr_t ret_conv_19_ref = 0;
34361                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34362                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34363                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
34364                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
34365                 if (ret_conv_19_var.is_owned) {
34366                         ret_conv_19_ref |= 1;
34367                 }
34368                 ret_arr_ptr[t] = ret_conv_19_ref;
34369         }
34370         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
34371         FREE(ret_var.data);
34372         return ret_arr;
34373 }
34374
34375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
34376         LDKCommitmentUpdate this_ptr_conv;
34377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34378         this_ptr_conv.is_owned = false;
34379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34380         LDKCVec_UpdateFulfillHTLCZ val_constr;
34381         val_constr.datalen = (*env)->GetArrayLength(env, val);
34382         if (val_constr.datalen > 0)
34383                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
34384         else
34385                 val_constr.data = NULL;
34386         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34387         for (size_t t = 0; t < val_constr.datalen; t++) {
34388                 int64_t val_conv_19 = val_vals[t];
34389                 LDKUpdateFulfillHTLC val_conv_19_conv;
34390                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
34391                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
34392                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
34393                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
34394                 val_constr.data[t] = val_conv_19_conv;
34395         }
34396         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34397         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
34398 }
34399
34400 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
34401         LDKCommitmentUpdate this_ptr_conv;
34402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34403         this_ptr_conv.is_owned = false;
34404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34405         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
34406         int64_tArray ret_arr = NULL;
34407         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
34408         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
34409         for (size_t q = 0; q < ret_var.datalen; q++) {
34410                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
34411                 uintptr_t ret_conv_16_ref = 0;
34412                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34413                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34414                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
34415                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
34416                 if (ret_conv_16_var.is_owned) {
34417                         ret_conv_16_ref |= 1;
34418                 }
34419                 ret_arr_ptr[q] = ret_conv_16_ref;
34420         }
34421         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
34422         FREE(ret_var.data);
34423         return ret_arr;
34424 }
34425
34426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
34427         LDKCommitmentUpdate this_ptr_conv;
34428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34429         this_ptr_conv.is_owned = false;
34430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34431         LDKCVec_UpdateFailHTLCZ val_constr;
34432         val_constr.datalen = (*env)->GetArrayLength(env, val);
34433         if (val_constr.datalen > 0)
34434                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
34435         else
34436                 val_constr.data = NULL;
34437         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34438         for (size_t q = 0; q < val_constr.datalen; q++) {
34439                 int64_t val_conv_16 = val_vals[q];
34440                 LDKUpdateFailHTLC val_conv_16_conv;
34441                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
34442                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
34443                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
34444                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
34445                 val_constr.data[q] = val_conv_16_conv;
34446         }
34447         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34448         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
34449 }
34450
34451 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
34452         LDKCommitmentUpdate this_ptr_conv;
34453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34454         this_ptr_conv.is_owned = false;
34455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34456         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
34457         int64_tArray ret_arr = NULL;
34458         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
34459         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
34460         for (size_t z = 0; z < ret_var.datalen; z++) {
34461                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
34462                 uintptr_t ret_conv_25_ref = 0;
34463                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34464                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34465                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
34466                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
34467                 if (ret_conv_25_var.is_owned) {
34468                         ret_conv_25_ref |= 1;
34469                 }
34470                 ret_arr_ptr[z] = ret_conv_25_ref;
34471         }
34472         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
34473         FREE(ret_var.data);
34474         return ret_arr;
34475 }
34476
34477 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) {
34478         LDKCommitmentUpdate this_ptr_conv;
34479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34480         this_ptr_conv.is_owned = false;
34481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34482         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
34483         val_constr.datalen = (*env)->GetArrayLength(env, val);
34484         if (val_constr.datalen > 0)
34485                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
34486         else
34487                 val_constr.data = NULL;
34488         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34489         for (size_t z = 0; z < val_constr.datalen; z++) {
34490                 int64_t val_conv_25 = val_vals[z];
34491                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
34492                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
34493                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
34494                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
34495                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
34496                 val_constr.data[z] = val_conv_25_conv;
34497         }
34498         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34499         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
34500 }
34501
34502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
34503         LDKCommitmentUpdate this_ptr_conv;
34504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34505         this_ptr_conv.is_owned = false;
34506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34507         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
34508         uintptr_t ret_ref = 0;
34509         if ((uintptr_t)ret_var.inner > 4096) {
34510                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34511                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34513                 ret_ref = (uintptr_t)ret_var.inner;
34514                 if (ret_var.is_owned) {
34515                         ret_ref |= 1;
34516                 }
34517         }
34518         return ret_ref;
34519 }
34520
34521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34522         LDKCommitmentUpdate this_ptr_conv;
34523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34524         this_ptr_conv.is_owned = false;
34525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34526         LDKUpdateFee val_conv;
34527         val_conv.inner = (void*)(val & (~1));
34528         val_conv.is_owned = (val & 1) || (val == 0);
34529         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34530         val_conv = UpdateFee_clone(&val_conv);
34531         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
34532 }
34533
34534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
34535         LDKCommitmentUpdate this_ptr_conv;
34536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34537         this_ptr_conv.is_owned = false;
34538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34539         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
34540         uintptr_t ret_ref = 0;
34541         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34542         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34543         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34544         ret_ref = (uintptr_t)ret_var.inner;
34545         if (ret_var.is_owned) {
34546                 ret_ref |= 1;
34547         }
34548         return ret_ref;
34549 }
34550
34551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34552         LDKCommitmentUpdate this_ptr_conv;
34553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34554         this_ptr_conv.is_owned = false;
34555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34556         LDKCommitmentSigned val_conv;
34557         val_conv.inner = (void*)(val & (~1));
34558         val_conv.is_owned = (val & 1) || (val == 0);
34559         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34560         val_conv = CommitmentSigned_clone(&val_conv);
34561         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
34562 }
34563
34564 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) {
34565         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
34566         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
34567         if (update_add_htlcs_arg_constr.datalen > 0)
34568                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
34569         else
34570                 update_add_htlcs_arg_constr.data = NULL;
34571         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
34572         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
34573                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
34574                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
34575                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
34576                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
34577                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
34578                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
34579                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
34580         }
34581         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
34582         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
34583         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
34584         if (update_fulfill_htlcs_arg_constr.datalen > 0)
34585                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
34586         else
34587                 update_fulfill_htlcs_arg_constr.data = NULL;
34588         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
34589         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
34590                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
34591                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
34592                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
34593                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
34594                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
34595                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
34596                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
34597         }
34598         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
34599         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
34600         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
34601         if (update_fail_htlcs_arg_constr.datalen > 0)
34602                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
34603         else
34604                 update_fail_htlcs_arg_constr.data = NULL;
34605         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
34606         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
34607                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
34608                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
34609                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
34610                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
34611                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
34612                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
34613                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
34614         }
34615         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
34616         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
34617         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
34618         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
34619                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
34620         else
34621                 update_fail_malformed_htlcs_arg_constr.data = NULL;
34622         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
34623         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
34624                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
34625                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
34626                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
34627                 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);
34628                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
34629                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
34630                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
34631         }
34632         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
34633         LDKUpdateFee update_fee_arg_conv;
34634         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
34635         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
34636         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
34637         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
34638         LDKCommitmentSigned commitment_signed_arg_conv;
34639         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
34640         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
34641         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
34642         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
34643         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);
34644         uintptr_t ret_ref = 0;
34645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34648         ret_ref = (uintptr_t)ret_var.inner;
34649         if (ret_var.is_owned) {
34650                 ret_ref |= 1;
34651         }
34652         return ret_ref;
34653 }
34654
34655 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
34656         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
34657 uintptr_t ret_ref = 0;
34658 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34659 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34660 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34661 ret_ref = (uintptr_t)ret_var.inner;
34662 if (ret_var.is_owned) {
34663         ret_ref |= 1;
34664 }
34665         return ret_ref;
34666 }
34667 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34668         LDKCommitmentUpdate arg_conv;
34669         arg_conv.inner = (void*)(arg & (~1));
34670         arg_conv.is_owned = false;
34671         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34672         intptr_t ret_val = CommitmentUpdate_clone_ptr(&arg_conv);
34673         return ret_val;
34674 }
34675
34676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34677         LDKCommitmentUpdate orig_conv;
34678         orig_conv.inner = (void*)(orig & (~1));
34679         orig_conv.is_owned = false;
34680         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34681         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
34682         uintptr_t ret_ref = 0;
34683         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34684         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34686         ret_ref = (uintptr_t)ret_var.inner;
34687         if (ret_var.is_owned) {
34688                 ret_ref |= 1;
34689         }
34690         return ret_ref;
34691 }
34692
34693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34694         if ((this_ptr & 1) != 0) return;
34695         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34696         CHECK_ACCESS(this_ptr_ptr);
34697         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
34698         FREE((void*)this_ptr);
34699         ChannelMessageHandler_free(this_ptr_conv);
34700 }
34701
34702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34703         if ((this_ptr & 1) != 0) return;
34704         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34705         CHECK_ACCESS(this_ptr_ptr);
34706         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
34707         FREE((void*)this_ptr);
34708         RoutingMessageHandler_free(this_ptr_conv);
34709 }
34710
34711 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
34712         LDKAcceptChannel obj_conv;
34713         obj_conv.inner = (void*)(obj & (~1));
34714         obj_conv.is_owned = false;
34715         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34716         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
34717         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34718         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34719         CVec_u8Z_free(ret_var);
34720         return ret_arr;
34721 }
34722
34723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34724         LDKu8slice ser_ref;
34725         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34726         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34727         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
34728         *ret_conv = AcceptChannel_read(ser_ref);
34729         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34730         return (uintptr_t)ret_conv;
34731 }
34732
34733 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
34734         LDKAnnouncementSignatures obj_conv;
34735         obj_conv.inner = (void*)(obj & (~1));
34736         obj_conv.is_owned = false;
34737         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34738         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
34739         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34740         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34741         CVec_u8Z_free(ret_var);
34742         return ret_arr;
34743 }
34744
34745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34746         LDKu8slice ser_ref;
34747         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34748         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34749         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
34750         *ret_conv = AnnouncementSignatures_read(ser_ref);
34751         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34752         return (uintptr_t)ret_conv;
34753 }
34754
34755 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
34756         LDKChannelReestablish obj_conv;
34757         obj_conv.inner = (void*)(obj & (~1));
34758         obj_conv.is_owned = false;
34759         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34760         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
34761         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34762         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34763         CVec_u8Z_free(ret_var);
34764         return ret_arr;
34765 }
34766
34767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34768         LDKu8slice ser_ref;
34769         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34770         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34771         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
34772         *ret_conv = ChannelReestablish_read(ser_ref);
34773         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34774         return (uintptr_t)ret_conv;
34775 }
34776
34777 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
34778         LDKClosingSigned obj_conv;
34779         obj_conv.inner = (void*)(obj & (~1));
34780         obj_conv.is_owned = false;
34781         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34782         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
34783         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34784         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34785         CVec_u8Z_free(ret_var);
34786         return ret_arr;
34787 }
34788
34789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34790         LDKu8slice ser_ref;
34791         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34792         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34793         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
34794         *ret_conv = ClosingSigned_read(ser_ref);
34795         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34796         return (uintptr_t)ret_conv;
34797 }
34798
34799 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
34800         LDKClosingSignedFeeRange obj_conv;
34801         obj_conv.inner = (void*)(obj & (~1));
34802         obj_conv.is_owned = false;
34803         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34804         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
34805         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34806         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34807         CVec_u8Z_free(ret_var);
34808         return ret_arr;
34809 }
34810
34811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34812         LDKu8slice ser_ref;
34813         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34814         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34815         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
34816         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
34817         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34818         return (uintptr_t)ret_conv;
34819 }
34820
34821 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
34822         LDKCommitmentSigned obj_conv;
34823         obj_conv.inner = (void*)(obj & (~1));
34824         obj_conv.is_owned = false;
34825         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34826         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
34827         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34828         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34829         CVec_u8Z_free(ret_var);
34830         return ret_arr;
34831 }
34832
34833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34834         LDKu8slice ser_ref;
34835         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34836         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34837         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
34838         *ret_conv = CommitmentSigned_read(ser_ref);
34839         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34840         return (uintptr_t)ret_conv;
34841 }
34842
34843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
34844         LDKFundingCreated obj_conv;
34845         obj_conv.inner = (void*)(obj & (~1));
34846         obj_conv.is_owned = false;
34847         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34848         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
34849         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34850         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34851         CVec_u8Z_free(ret_var);
34852         return ret_arr;
34853 }
34854
34855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34856         LDKu8slice ser_ref;
34857         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34858         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34859         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
34860         *ret_conv = FundingCreated_read(ser_ref);
34861         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34862         return (uintptr_t)ret_conv;
34863 }
34864
34865 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
34866         LDKFundingSigned obj_conv;
34867         obj_conv.inner = (void*)(obj & (~1));
34868         obj_conv.is_owned = false;
34869         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34870         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
34871         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34872         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34873         CVec_u8Z_free(ret_var);
34874         return ret_arr;
34875 }
34876
34877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34878         LDKu8slice ser_ref;
34879         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34880         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34881         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
34882         *ret_conv = FundingSigned_read(ser_ref);
34883         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34884         return (uintptr_t)ret_conv;
34885 }
34886
34887 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
34888         LDKFundingLocked obj_conv;
34889         obj_conv.inner = (void*)(obj & (~1));
34890         obj_conv.is_owned = false;
34891         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34892         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
34893         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34894         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34895         CVec_u8Z_free(ret_var);
34896         return ret_arr;
34897 }
34898
34899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34900         LDKu8slice ser_ref;
34901         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34902         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34903         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
34904         *ret_conv = FundingLocked_read(ser_ref);
34905         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34906         return (uintptr_t)ret_conv;
34907 }
34908
34909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
34910         LDKInit obj_conv;
34911         obj_conv.inner = (void*)(obj & (~1));
34912         obj_conv.is_owned = false;
34913         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34914         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
34915         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34916         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34917         CVec_u8Z_free(ret_var);
34918         return ret_arr;
34919 }
34920
34921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34922         LDKu8slice ser_ref;
34923         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34924         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34925         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
34926         *ret_conv = Init_read(ser_ref);
34927         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34928         return (uintptr_t)ret_conv;
34929 }
34930
34931 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
34932         LDKOpenChannel obj_conv;
34933         obj_conv.inner = (void*)(obj & (~1));
34934         obj_conv.is_owned = false;
34935         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34936         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
34937         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34938         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34939         CVec_u8Z_free(ret_var);
34940         return ret_arr;
34941 }
34942
34943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34944         LDKu8slice ser_ref;
34945         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34946         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34947         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
34948         *ret_conv = OpenChannel_read(ser_ref);
34949         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34950         return (uintptr_t)ret_conv;
34951 }
34952
34953 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
34954         LDKRevokeAndACK obj_conv;
34955         obj_conv.inner = (void*)(obj & (~1));
34956         obj_conv.is_owned = false;
34957         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34958         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
34959         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34960         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34961         CVec_u8Z_free(ret_var);
34962         return ret_arr;
34963 }
34964
34965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34966         LDKu8slice ser_ref;
34967         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34968         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34969         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
34970         *ret_conv = RevokeAndACK_read(ser_ref);
34971         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34972         return (uintptr_t)ret_conv;
34973 }
34974
34975 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
34976         LDKShutdown obj_conv;
34977         obj_conv.inner = (void*)(obj & (~1));
34978         obj_conv.is_owned = false;
34979         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34980         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
34981         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34982         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34983         CVec_u8Z_free(ret_var);
34984         return ret_arr;
34985 }
34986
34987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34988         LDKu8slice ser_ref;
34989         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34990         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34991         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
34992         *ret_conv = Shutdown_read(ser_ref);
34993         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34994         return (uintptr_t)ret_conv;
34995 }
34996
34997 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
34998         LDKUpdateFailHTLC obj_conv;
34999         obj_conv.inner = (void*)(obj & (~1));
35000         obj_conv.is_owned = false;
35001         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35002         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
35003         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35004         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35005         CVec_u8Z_free(ret_var);
35006         return ret_arr;
35007 }
35008
35009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35010         LDKu8slice ser_ref;
35011         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35012         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35013         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
35014         *ret_conv = UpdateFailHTLC_read(ser_ref);
35015         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35016         return (uintptr_t)ret_conv;
35017 }
35018
35019 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35020         LDKUpdateFailMalformedHTLC obj_conv;
35021         obj_conv.inner = (void*)(obj & (~1));
35022         obj_conv.is_owned = false;
35023         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35024         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
35025         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35026         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35027         CVec_u8Z_free(ret_var);
35028         return ret_arr;
35029 }
35030
35031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35032         LDKu8slice ser_ref;
35033         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35034         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35035         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
35036         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
35037         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35038         return (uintptr_t)ret_conv;
35039 }
35040
35041 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
35042         LDKUpdateFee obj_conv;
35043         obj_conv.inner = (void*)(obj & (~1));
35044         obj_conv.is_owned = false;
35045         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35046         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
35047         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35048         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35049         CVec_u8Z_free(ret_var);
35050         return ret_arr;
35051 }
35052
35053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35054         LDKu8slice ser_ref;
35055         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35056         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35057         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
35058         *ret_conv = UpdateFee_read(ser_ref);
35059         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35060         return (uintptr_t)ret_conv;
35061 }
35062
35063 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35064         LDKUpdateFulfillHTLC obj_conv;
35065         obj_conv.inner = (void*)(obj & (~1));
35066         obj_conv.is_owned = false;
35067         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35068         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
35069         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35070         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35071         CVec_u8Z_free(ret_var);
35072         return ret_arr;
35073 }
35074
35075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35076         LDKu8slice ser_ref;
35077         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35078         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35079         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
35080         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
35081         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35082         return (uintptr_t)ret_conv;
35083 }
35084
35085 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35086         LDKUpdateAddHTLC obj_conv;
35087         obj_conv.inner = (void*)(obj & (~1));
35088         obj_conv.is_owned = false;
35089         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35090         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
35091         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35092         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35093         CVec_u8Z_free(ret_var);
35094         return ret_arr;
35095 }
35096
35097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35098         LDKu8slice ser_ref;
35099         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35100         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35101         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
35102         *ret_conv = UpdateAddHTLC_read(ser_ref);
35103         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35104         return (uintptr_t)ret_conv;
35105 }
35106
35107 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
35108         LDKPing obj_conv;
35109         obj_conv.inner = (void*)(obj & (~1));
35110         obj_conv.is_owned = false;
35111         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35112         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
35113         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35114         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35115         CVec_u8Z_free(ret_var);
35116         return ret_arr;
35117 }
35118
35119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35120         LDKu8slice ser_ref;
35121         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35122         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35123         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
35124         *ret_conv = Ping_read(ser_ref);
35125         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35126         return (uintptr_t)ret_conv;
35127 }
35128
35129 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
35130         LDKPong obj_conv;
35131         obj_conv.inner = (void*)(obj & (~1));
35132         obj_conv.is_owned = false;
35133         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35134         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
35135         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35136         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35137         CVec_u8Z_free(ret_var);
35138         return ret_arr;
35139 }
35140
35141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35142         LDKu8slice ser_ref;
35143         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35144         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35145         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
35146         *ret_conv = Pong_read(ser_ref);
35147         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35148         return (uintptr_t)ret_conv;
35149 }
35150
35151 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35152         LDKUnsignedChannelAnnouncement obj_conv;
35153         obj_conv.inner = (void*)(obj & (~1));
35154         obj_conv.is_owned = false;
35155         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35156         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
35157         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35158         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35159         CVec_u8Z_free(ret_var);
35160         return ret_arr;
35161 }
35162
35163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35164         LDKu8slice ser_ref;
35165         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35166         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35167         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
35168         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
35169         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35170         return (uintptr_t)ret_conv;
35171 }
35172
35173 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35174         LDKChannelAnnouncement obj_conv;
35175         obj_conv.inner = (void*)(obj & (~1));
35176         obj_conv.is_owned = false;
35177         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35178         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
35179         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35180         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35181         CVec_u8Z_free(ret_var);
35182         return ret_arr;
35183 }
35184
35185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35186         LDKu8slice ser_ref;
35187         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35188         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35189         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
35190         *ret_conv = ChannelAnnouncement_read(ser_ref);
35191         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35192         return (uintptr_t)ret_conv;
35193 }
35194
35195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
35196         LDKUnsignedChannelUpdate obj_conv;
35197         obj_conv.inner = (void*)(obj & (~1));
35198         obj_conv.is_owned = false;
35199         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35200         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
35201         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35202         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35203         CVec_u8Z_free(ret_var);
35204         return ret_arr;
35205 }
35206
35207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35208         LDKu8slice ser_ref;
35209         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35210         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35211         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
35212         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
35213         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35214         return (uintptr_t)ret_conv;
35215 }
35216
35217 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
35218         LDKChannelUpdate obj_conv;
35219         obj_conv.inner = (void*)(obj & (~1));
35220         obj_conv.is_owned = false;
35221         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35222         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
35223         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35224         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35225         CVec_u8Z_free(ret_var);
35226         return ret_arr;
35227 }
35228
35229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35230         LDKu8slice ser_ref;
35231         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35232         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35233         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
35234         *ret_conv = ChannelUpdate_read(ser_ref);
35235         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35236         return (uintptr_t)ret_conv;
35237 }
35238
35239 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
35240         LDKErrorMessage obj_conv;
35241         obj_conv.inner = (void*)(obj & (~1));
35242         obj_conv.is_owned = false;
35243         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35244         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
35245         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35246         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35247         CVec_u8Z_free(ret_var);
35248         return ret_arr;
35249 }
35250
35251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35252         LDKu8slice ser_ref;
35253         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35254         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35255         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
35256         *ret_conv = ErrorMessage_read(ser_ref);
35257         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35258         return (uintptr_t)ret_conv;
35259 }
35260
35261 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
35262         LDKWarningMessage obj_conv;
35263         obj_conv.inner = (void*)(obj & (~1));
35264         obj_conv.is_owned = false;
35265         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35266         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
35267         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35268         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35269         CVec_u8Z_free(ret_var);
35270         return ret_arr;
35271 }
35272
35273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35274         LDKu8slice ser_ref;
35275         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35276         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35277         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
35278         *ret_conv = WarningMessage_read(ser_ref);
35279         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35280         return (uintptr_t)ret_conv;
35281 }
35282
35283 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35284         LDKUnsignedNodeAnnouncement obj_conv;
35285         obj_conv.inner = (void*)(obj & (~1));
35286         obj_conv.is_owned = false;
35287         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35288         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
35289         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35290         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35291         CVec_u8Z_free(ret_var);
35292         return ret_arr;
35293 }
35294
35295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35296         LDKu8slice ser_ref;
35297         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35298         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35299         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
35300         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
35301         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35302         return (uintptr_t)ret_conv;
35303 }
35304
35305 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35306         LDKNodeAnnouncement obj_conv;
35307         obj_conv.inner = (void*)(obj & (~1));
35308         obj_conv.is_owned = false;
35309         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35310         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
35311         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35312         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35313         CVec_u8Z_free(ret_var);
35314         return ret_arr;
35315 }
35316
35317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35318         LDKu8slice ser_ref;
35319         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35320         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35321         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
35322         *ret_conv = NodeAnnouncement_read(ser_ref);
35323         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35324         return (uintptr_t)ret_conv;
35325 }
35326
35327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35328         LDKu8slice ser_ref;
35329         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35330         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35331         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
35332         *ret_conv = QueryShortChannelIds_read(ser_ref);
35333         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35334         return (uintptr_t)ret_conv;
35335 }
35336
35337 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
35338         LDKQueryShortChannelIds obj_conv;
35339         obj_conv.inner = (void*)(obj & (~1));
35340         obj_conv.is_owned = false;
35341         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35342         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
35343         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35344         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35345         CVec_u8Z_free(ret_var);
35346         return ret_arr;
35347 }
35348
35349 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
35350         LDKReplyShortChannelIdsEnd obj_conv;
35351         obj_conv.inner = (void*)(obj & (~1));
35352         obj_conv.is_owned = false;
35353         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35354         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
35355         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35356         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35357         CVec_u8Z_free(ret_var);
35358         return ret_arr;
35359 }
35360
35361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35362         LDKu8slice ser_ref;
35363         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35364         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35365         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
35366         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
35367         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35368         return (uintptr_t)ret_conv;
35369 }
35370
35371 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
35372         LDKQueryChannelRange this_arg_conv;
35373         this_arg_conv.inner = (void*)(this_arg & (~1));
35374         this_arg_conv.is_owned = false;
35375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35376         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
35377         return ret_val;
35378 }
35379
35380 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
35381         LDKQueryChannelRange obj_conv;
35382         obj_conv.inner = (void*)(obj & (~1));
35383         obj_conv.is_owned = false;
35384         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35385         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
35386         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35387         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35388         CVec_u8Z_free(ret_var);
35389         return ret_arr;
35390 }
35391
35392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35393         LDKu8slice ser_ref;
35394         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35395         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35396         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
35397         *ret_conv = QueryChannelRange_read(ser_ref);
35398         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35399         return (uintptr_t)ret_conv;
35400 }
35401
35402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35403         LDKu8slice ser_ref;
35404         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35405         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35406         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
35407         *ret_conv = ReplyChannelRange_read(ser_ref);
35408         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35409         return (uintptr_t)ret_conv;
35410 }
35411
35412 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
35413         LDKReplyChannelRange obj_conv;
35414         obj_conv.inner = (void*)(obj & (~1));
35415         obj_conv.is_owned = false;
35416         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35417         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
35418         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35419         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35420         CVec_u8Z_free(ret_var);
35421         return ret_arr;
35422 }
35423
35424 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
35425         LDKGossipTimestampFilter obj_conv;
35426         obj_conv.inner = (void*)(obj & (~1));
35427         obj_conv.is_owned = false;
35428         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35429         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
35430         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35431         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35432         CVec_u8Z_free(ret_var);
35433         return ret_arr;
35434 }
35435
35436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35437         LDKu8slice ser_ref;
35438         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35439         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35440         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
35441         *ret_conv = GossipTimestampFilter_read(ser_ref);
35442         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35443         return (uintptr_t)ret_conv;
35444 }
35445
35446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35447         if ((this_ptr & 1) != 0) return;
35448         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35449         CHECK_ACCESS(this_ptr_ptr);
35450         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
35451         FREE((void*)this_ptr);
35452         CustomMessageHandler_free(this_ptr_conv);
35453 }
35454
35455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35456         LDKIgnoringMessageHandler this_obj_conv;
35457         this_obj_conv.inner = (void*)(this_obj & (~1));
35458         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35460         IgnoringMessageHandler_free(this_obj_conv);
35461 }
35462
35463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
35464         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
35465         uintptr_t ret_ref = 0;
35466         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35467         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35469         ret_ref = (uintptr_t)ret_var.inner;
35470         if (ret_var.is_owned) {
35471                 ret_ref |= 1;
35472         }
35473         return ret_ref;
35474 }
35475
35476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
35477         LDKIgnoringMessageHandler this_arg_conv;
35478         this_arg_conv.inner = (void*)(this_arg & (~1));
35479         this_arg_conv.is_owned = false;
35480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35481         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
35482         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
35483         return (uintptr_t)ret_ret;
35484 }
35485
35486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
35487         LDKIgnoringMessageHandler this_arg_conv;
35488         this_arg_conv.inner = (void*)(this_arg & (~1));
35489         this_arg_conv.is_owned = false;
35490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35491         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
35492         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
35493         return (uintptr_t)ret_ret;
35494 }
35495
35496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
35497         LDKIgnoringMessageHandler this_arg_conv;
35498         this_arg_conv.inner = (void*)(this_arg & (~1));
35499         this_arg_conv.is_owned = false;
35500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35501         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
35502         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
35503         return (uintptr_t)ret_ret;
35504 }
35505
35506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
35507         LDKIgnoringMessageHandler this_arg_conv;
35508         this_arg_conv.inner = (void*)(this_arg & (~1));
35509         this_arg_conv.is_owned = false;
35510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35511         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
35512         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
35513         return (uintptr_t)ret_ret;
35514 }
35515
35516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35517         LDKErroringMessageHandler this_obj_conv;
35518         this_obj_conv.inner = (void*)(this_obj & (~1));
35519         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35521         ErroringMessageHandler_free(this_obj_conv);
35522 }
35523
35524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
35525         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
35526         uintptr_t ret_ref = 0;
35527         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35528         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35530         ret_ref = (uintptr_t)ret_var.inner;
35531         if (ret_var.is_owned) {
35532                 ret_ref |= 1;
35533         }
35534         return ret_ref;
35535 }
35536
35537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
35538         LDKErroringMessageHandler this_arg_conv;
35539         this_arg_conv.inner = (void*)(this_arg & (~1));
35540         this_arg_conv.is_owned = false;
35541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35542         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
35543         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
35544         return (uintptr_t)ret_ret;
35545 }
35546
35547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
35548         LDKErroringMessageHandler this_arg_conv;
35549         this_arg_conv.inner = (void*)(this_arg & (~1));
35550         this_arg_conv.is_owned = false;
35551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35552         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
35553         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
35554         return (uintptr_t)ret_ret;
35555 }
35556
35557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35558         LDKMessageHandler this_obj_conv;
35559         this_obj_conv.inner = (void*)(this_obj & (~1));
35560         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35562         MessageHandler_free(this_obj_conv);
35563 }
35564
35565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
35566         LDKMessageHandler 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         // WARNING: This object doesn't live past this scope, needs clone!
35571         uintptr_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
35572         return ret_ret;
35573 }
35574
35575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35576         LDKMessageHandler this_ptr_conv;
35577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35578         this_ptr_conv.is_owned = false;
35579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35580         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
35581         CHECK_ACCESS(val_ptr);
35582         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
35583         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
35584                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35585                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
35586         }
35587         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
35588 }
35589
35590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
35591         LDKMessageHandler this_ptr_conv;
35592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35593         this_ptr_conv.is_owned = false;
35594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35595         // WARNING: This object doesn't live past this scope, needs clone!
35596         uintptr_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
35597         return ret_ret;
35598 }
35599
35600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35601         LDKMessageHandler this_ptr_conv;
35602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35603         this_ptr_conv.is_owned = false;
35604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35605         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
35606         CHECK_ACCESS(val_ptr);
35607         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
35608         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
35609                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35610                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
35611         }
35612         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
35613 }
35614
35615 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) {
35616         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
35617         CHECK_ACCESS(chan_handler_arg_ptr);
35618         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
35619         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
35620                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35621                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
35622         }
35623         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
35624         CHECK_ACCESS(route_handler_arg_ptr);
35625         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
35626         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
35627                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35628                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
35629         }
35630         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
35631         uintptr_t ret_ref = 0;
35632         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35633         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35635         ret_ref = (uintptr_t)ret_var.inner;
35636         if (ret_var.is_owned) {
35637                 ret_ref |= 1;
35638         }
35639         return ret_ref;
35640 }
35641
35642 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
35643         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
35644         *ret_ret = SocketDescriptor_clone(arg);
35645         return (uintptr_t)ret_ret;
35646 }
35647 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35648         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
35649         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
35650         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
35651         intptr_t ret_val = SocketDescriptor_clone_ptr(arg_conv);
35652         return ret_val;
35653 }
35654
35655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35656         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
35657         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
35658         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
35659         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
35660         *ret_ret = SocketDescriptor_clone(orig_conv);
35661         return (uintptr_t)ret_ret;
35662 }
35663
35664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35665         if ((this_ptr & 1) != 0) return;
35666         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35667         CHECK_ACCESS(this_ptr_ptr);
35668         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
35669         FREE((void*)this_ptr);
35670         SocketDescriptor_free(this_ptr_conv);
35671 }
35672
35673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35674         LDKPeerHandleError this_obj_conv;
35675         this_obj_conv.inner = (void*)(this_obj & (~1));
35676         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35678         PeerHandleError_free(this_obj_conv);
35679 }
35680
35681 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
35682         LDKPeerHandleError this_ptr_conv;
35683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35684         this_ptr_conv.is_owned = false;
35685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35686         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
35687         return ret_val;
35688 }
35689
35690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
35691         LDKPeerHandleError this_ptr_conv;
35692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35693         this_ptr_conv.is_owned = false;
35694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35695         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
35696 }
35697
35698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
35699         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
35700         uintptr_t ret_ref = 0;
35701         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35702         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35704         ret_ref = (uintptr_t)ret_var.inner;
35705         if (ret_var.is_owned) {
35706                 ret_ref |= 1;
35707         }
35708         return ret_ref;
35709 }
35710
35711 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
35712         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
35713 uintptr_t ret_ref = 0;
35714 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35715 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35716 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35717 ret_ref = (uintptr_t)ret_var.inner;
35718 if (ret_var.is_owned) {
35719         ret_ref |= 1;
35720 }
35721         return ret_ref;
35722 }
35723 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35724         LDKPeerHandleError arg_conv;
35725         arg_conv.inner = (void*)(arg & (~1));
35726         arg_conv.is_owned = false;
35727         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35728         intptr_t ret_val = PeerHandleError_clone_ptr(&arg_conv);
35729         return ret_val;
35730 }
35731
35732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35733         LDKPeerHandleError orig_conv;
35734         orig_conv.inner = (void*)(orig & (~1));
35735         orig_conv.is_owned = false;
35736         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35737         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
35738         uintptr_t ret_ref = 0;
35739         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35740         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35742         ret_ref = (uintptr_t)ret_var.inner;
35743         if (ret_var.is_owned) {
35744                 ret_ref |= 1;
35745         }
35746         return ret_ref;
35747 }
35748
35749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35750         LDKPeerManager this_obj_conv;
35751         this_obj_conv.inner = (void*)(this_obj & (~1));
35752         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35754         PeerManager_free(this_obj_conv);
35755 }
35756
35757 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) {
35758         LDKMessageHandler message_handler_conv;
35759         message_handler_conv.inner = (void*)(message_handler & (~1));
35760         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
35761         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
35762         // WARNING: we need a move here but no clone is available for LDKMessageHandler
35763         LDKSecretKey our_node_secret_ref;
35764         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
35765         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
35766         unsigned char ephemeral_random_data_arr[32];
35767         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
35768         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
35769         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
35770         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
35771         CHECK_ACCESS(logger_ptr);
35772         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
35773         if (logger_conv.free == LDKLogger_JCalls_free) {
35774                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35775                 LDKLogger_JCalls_cloned(&logger_conv);
35776         }
35777         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
35778         CHECK_ACCESS(custom_message_handler_ptr);
35779         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
35780         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
35781                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35782                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
35783         }
35784         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
35785         uintptr_t ret_ref = 0;
35786         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35787         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35788         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35789         ret_ref = (uintptr_t)ret_var.inner;
35790         if (ret_var.is_owned) {
35791                 ret_ref |= 1;
35792         }
35793         return ret_ref;
35794 }
35795
35796 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
35797         LDKPeerManager this_arg_conv;
35798         this_arg_conv.inner = (void*)(this_arg & (~1));
35799         this_arg_conv.is_owned = false;
35800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35801         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
35802         jobjectArray ret_arr = NULL;
35803         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
35804         ;
35805         for (size_t i = 0; i < ret_var.datalen; i++) {
35806                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
35807                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
35808                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
35809         }
35810         
35811         FREE(ret_var.data);
35812         return ret_arr;
35813 }
35814
35815 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) {
35816         LDKPeerManager this_arg_conv;
35817         this_arg_conv.inner = (void*)(this_arg & (~1));
35818         this_arg_conv.is_owned = false;
35819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35820         LDKPublicKey their_node_id_ref;
35821         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
35822         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
35823         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
35824         CHECK_ACCESS(descriptor_ptr);
35825         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
35826         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
35827                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35828                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
35829         }
35830         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
35831         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
35832         return (uintptr_t)ret_conv;
35833 }
35834
35835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
35836         LDKPeerManager this_arg_conv;
35837         this_arg_conv.inner = (void*)(this_arg & (~1));
35838         this_arg_conv.is_owned = false;
35839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35840         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
35841         CHECK_ACCESS(descriptor_ptr);
35842         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
35843         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
35844                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35845                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
35846         }
35847         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
35848         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
35849         return (uintptr_t)ret_conv;
35850 }
35851
35852 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) {
35853         LDKPeerManager this_arg_conv;
35854         this_arg_conv.inner = (void*)(this_arg & (~1));
35855         this_arg_conv.is_owned = false;
35856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35857         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
35858         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
35859         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
35860         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
35861         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
35862         return (uintptr_t)ret_conv;
35863 }
35864
35865 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) {
35866         LDKPeerManager this_arg_conv;
35867         this_arg_conv.inner = (void*)(this_arg & (~1));
35868         this_arg_conv.is_owned = false;
35869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35870         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
35871         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
35872         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
35873         LDKu8slice data_ref;
35874         data_ref.datalen = (*env)->GetArrayLength(env, data);
35875         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
35876         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
35877         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
35878         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
35879         return (uintptr_t)ret_conv;
35880 }
35881
35882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
35883         LDKPeerManager this_arg_conv;
35884         this_arg_conv.inner = (void*)(this_arg & (~1));
35885         this_arg_conv.is_owned = false;
35886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35887         PeerManager_process_events(&this_arg_conv);
35888 }
35889
35890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
35891         LDKPeerManager this_arg_conv;
35892         this_arg_conv.inner = (void*)(this_arg & (~1));
35893         this_arg_conv.is_owned = false;
35894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35895         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
35896         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
35897         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
35898         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
35899 }
35900
35901 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) {
35902         LDKPeerManager this_arg_conv;
35903         this_arg_conv.inner = (void*)(this_arg & (~1));
35904         this_arg_conv.is_owned = false;
35905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35906         LDKPublicKey node_id_ref;
35907         CHECK((*env)->GetArrayLength(env, node_id) == 33);
35908         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
35909         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
35910 }
35911
35912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
35913         LDKPeerManager this_arg_conv;
35914         this_arg_conv.inner = (void*)(this_arg & (~1));
35915         this_arg_conv.is_owned = false;
35916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35917         PeerManager_disconnect_all_peers(&this_arg_conv);
35918 }
35919
35920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
35921         LDKPeerManager this_arg_conv;
35922         this_arg_conv.inner = (void*)(this_arg & (~1));
35923         this_arg_conv.is_owned = false;
35924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35925         PeerManager_timer_tick_occurred(&this_arg_conv);
35926 }
35927
35928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
35929         int64_t ret_val = htlc_success_tx_weight(opt_anchors);
35930         return ret_val;
35931 }
35932
35933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
35934         int64_t ret_val = htlc_timeout_tx_weight(opt_anchors);
35935         return ret_val;
35936 }
35937
35938 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
35939         unsigned char commitment_seed_arr[32];
35940         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
35941         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
35942         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
35943         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35944         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
35945         return ret_arr;
35946 }
35947
35948 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) {
35949         LDKCVec_u8Z to_holder_script_ref;
35950         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
35951         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
35952         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
35953         LDKCVec_u8Z to_counterparty_script_ref;
35954         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
35955         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
35956         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
35957         LDKOutPoint funding_outpoint_conv;
35958         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
35959         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
35960         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
35961         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
35962         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);
35963         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35964         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35965         Transaction_free(ret_var);
35966         return ret_arr;
35967 }
35968
35969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35970         LDKCounterpartyCommitmentSecrets this_obj_conv;
35971         this_obj_conv.inner = (void*)(this_obj & (~1));
35972         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35974         CounterpartyCommitmentSecrets_free(this_obj_conv);
35975 }
35976
35977 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
35978         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
35979 uintptr_t ret_ref = 0;
35980 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35981 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35982 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35983 ret_ref = (uintptr_t)ret_var.inner;
35984 if (ret_var.is_owned) {
35985         ret_ref |= 1;
35986 }
35987         return ret_ref;
35988 }
35989 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35990         LDKCounterpartyCommitmentSecrets arg_conv;
35991         arg_conv.inner = (void*)(arg & (~1));
35992         arg_conv.is_owned = false;
35993         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35994         intptr_t ret_val = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
35995         return ret_val;
35996 }
35997
35998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35999         LDKCounterpartyCommitmentSecrets orig_conv;
36000         orig_conv.inner = (void*)(orig & (~1));
36001         orig_conv.is_owned = false;
36002         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36003         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
36004         uintptr_t ret_ref = 0;
36005         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36006         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36008         ret_ref = (uintptr_t)ret_var.inner;
36009         if (ret_var.is_owned) {
36010                 ret_ref |= 1;
36011         }
36012         return ret_ref;
36013 }
36014
36015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
36016         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
36017         uintptr_t ret_ref = 0;
36018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36021         ret_ref = (uintptr_t)ret_var.inner;
36022         if (ret_var.is_owned) {
36023                 ret_ref |= 1;
36024         }
36025         return ret_ref;
36026 }
36027
36028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
36029         LDKCounterpartyCommitmentSecrets this_arg_conv;
36030         this_arg_conv.inner = (void*)(this_arg & (~1));
36031         this_arg_conv.is_owned = false;
36032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36033         int64_t ret_val = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
36034         return ret_val;
36035 }
36036
36037 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) {
36038         LDKCounterpartyCommitmentSecrets this_arg_conv;
36039         this_arg_conv.inner = (void*)(this_arg & (~1));
36040         this_arg_conv.is_owned = false;
36041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36042         LDKThirtyTwoBytes secret_ref;
36043         CHECK((*env)->GetArrayLength(env, secret) == 32);
36044         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
36045         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
36046         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
36047         return (uintptr_t)ret_conv;
36048 }
36049
36050 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
36051         LDKCounterpartyCommitmentSecrets this_arg_conv;
36052         this_arg_conv.inner = (void*)(this_arg & (~1));
36053         this_arg_conv.is_owned = false;
36054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36055         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36056         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
36057         return ret_arr;
36058 }
36059
36060 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
36061         LDKCounterpartyCommitmentSecrets obj_conv;
36062         obj_conv.inner = (void*)(obj & (~1));
36063         obj_conv.is_owned = false;
36064         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36065         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
36066         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36067         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36068         CVec_u8Z_free(ret_var);
36069         return ret_arr;
36070 }
36071
36072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36073         LDKu8slice ser_ref;
36074         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36075         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36076         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
36077         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
36078         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36079         return (uintptr_t)ret_conv;
36080 }
36081
36082 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) {
36083         LDKPublicKey per_commitment_point_ref;
36084         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36085         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36086         unsigned char base_secret_arr[32];
36087         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
36088         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
36089         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
36090         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
36091         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
36092         return (uintptr_t)ret_conv;
36093 }
36094
36095 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) {
36096         LDKPublicKey per_commitment_point_ref;
36097         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36098         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36099         LDKPublicKey base_point_ref;
36100         CHECK((*env)->GetArrayLength(env, base_point) == 33);
36101         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
36102         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
36103         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
36104         return (uintptr_t)ret_conv;
36105 }
36106
36107 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) {
36108         unsigned char per_commitment_secret_arr[32];
36109         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
36110         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
36111         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
36112         unsigned char countersignatory_revocation_base_secret_arr[32];
36113         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
36114         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
36115         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
36116         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
36117         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
36118         return (uintptr_t)ret_conv;
36119 }
36120
36121 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) {
36122         LDKPublicKey per_commitment_point_ref;
36123         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36124         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36125         LDKPublicKey countersignatory_revocation_base_point_ref;
36126         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
36127         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
36128         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
36129         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
36130         return (uintptr_t)ret_conv;
36131 }
36132
36133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36134         LDKTxCreationKeys this_obj_conv;
36135         this_obj_conv.inner = (void*)(this_obj & (~1));
36136         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36138         TxCreationKeys_free(this_obj_conv);
36139 }
36140
36141 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36142         LDKTxCreationKeys this_ptr_conv;
36143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36144         this_ptr_conv.is_owned = false;
36145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36146         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36147         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
36148         return ret_arr;
36149 }
36150
36151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36152         LDKTxCreationKeys this_ptr_conv;
36153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36154         this_ptr_conv.is_owned = false;
36155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36156         LDKPublicKey val_ref;
36157         CHECK((*env)->GetArrayLength(env, val) == 33);
36158         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36159         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
36160 }
36161
36162 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36163         LDKTxCreationKeys this_ptr_conv;
36164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36165         this_ptr_conv.is_owned = false;
36166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36167         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36168         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
36169         return ret_arr;
36170 }
36171
36172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36173         LDKTxCreationKeys this_ptr_conv;
36174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36175         this_ptr_conv.is_owned = false;
36176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36177         LDKPublicKey val_ref;
36178         CHECK((*env)->GetArrayLength(env, val) == 33);
36179         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36180         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
36181 }
36182
36183 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36184         LDKTxCreationKeys this_ptr_conv;
36185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36186         this_ptr_conv.is_owned = false;
36187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36188         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36189         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
36190         return ret_arr;
36191 }
36192
36193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36194         LDKTxCreationKeys this_ptr_conv;
36195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36196         this_ptr_conv.is_owned = false;
36197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36198         LDKPublicKey val_ref;
36199         CHECK((*env)->GetArrayLength(env, val) == 33);
36200         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36201         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
36202 }
36203
36204 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36205         LDKTxCreationKeys this_ptr_conv;
36206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36207         this_ptr_conv.is_owned = false;
36208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36209         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36210         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
36211         return ret_arr;
36212 }
36213
36214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36215         LDKTxCreationKeys this_ptr_conv;
36216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36217         this_ptr_conv.is_owned = false;
36218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36219         LDKPublicKey val_ref;
36220         CHECK((*env)->GetArrayLength(env, val) == 33);
36221         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36222         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
36223 }
36224
36225 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36226         LDKTxCreationKeys this_ptr_conv;
36227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36228         this_ptr_conv.is_owned = false;
36229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36230         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36231         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
36232         return ret_arr;
36233 }
36234
36235 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) {
36236         LDKTxCreationKeys this_ptr_conv;
36237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36238         this_ptr_conv.is_owned = false;
36239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36240         LDKPublicKey val_ref;
36241         CHECK((*env)->GetArrayLength(env, val) == 33);
36242         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36243         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
36244 }
36245
36246 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) {
36247         LDKPublicKey per_commitment_point_arg_ref;
36248         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
36249         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
36250         LDKPublicKey revocation_key_arg_ref;
36251         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
36252         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
36253         LDKPublicKey broadcaster_htlc_key_arg_ref;
36254         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
36255         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
36256         LDKPublicKey countersignatory_htlc_key_arg_ref;
36257         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
36258         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
36259         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
36260         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
36261         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
36262         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);
36263         uintptr_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 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
36275         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
36276 uintptr_t ret_ref = 0;
36277 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36278 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36279 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36280 ret_ref = (uintptr_t)ret_var.inner;
36281 if (ret_var.is_owned) {
36282         ret_ref |= 1;
36283 }
36284         return ret_ref;
36285 }
36286 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36287         LDKTxCreationKeys arg_conv;
36288         arg_conv.inner = (void*)(arg & (~1));
36289         arg_conv.is_owned = false;
36290         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36291         intptr_t ret_val = TxCreationKeys_clone_ptr(&arg_conv);
36292         return ret_val;
36293 }
36294
36295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36296         LDKTxCreationKeys orig_conv;
36297         orig_conv.inner = (void*)(orig & (~1));
36298         orig_conv.is_owned = false;
36299         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36300         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
36301         uintptr_t ret_ref = 0;
36302         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36303         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36304         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36305         ret_ref = (uintptr_t)ret_var.inner;
36306         if (ret_var.is_owned) {
36307                 ret_ref |= 1;
36308         }
36309         return ret_ref;
36310 }
36311
36312 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
36313         LDKTxCreationKeys obj_conv;
36314         obj_conv.inner = (void*)(obj & (~1));
36315         obj_conv.is_owned = false;
36316         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36317         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
36318         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36319         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36320         CVec_u8Z_free(ret_var);
36321         return ret_arr;
36322 }
36323
36324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36325         LDKu8slice ser_ref;
36326         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36327         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36328         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
36329         *ret_conv = TxCreationKeys_read(ser_ref);
36330         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36331         return (uintptr_t)ret_conv;
36332 }
36333
36334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36335         LDKChannelPublicKeys this_obj_conv;
36336         this_obj_conv.inner = (void*)(this_obj & (~1));
36337         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36339         ChannelPublicKeys_free(this_obj_conv);
36340 }
36341
36342 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
36343         LDKChannelPublicKeys this_ptr_conv;
36344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36345         this_ptr_conv.is_owned = false;
36346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36347         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36348         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
36349         return ret_arr;
36350 }
36351
36352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36353         LDKChannelPublicKeys this_ptr_conv;
36354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36355         this_ptr_conv.is_owned = false;
36356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36357         LDKPublicKey val_ref;
36358         CHECK((*env)->GetArrayLength(env, val) == 33);
36359         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36360         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
36361 }
36362
36363 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
36364         LDKChannelPublicKeys this_ptr_conv;
36365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36366         this_ptr_conv.is_owned = false;
36367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36368         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36369         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
36370         return ret_arr;
36371 }
36372
36373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36374         LDKChannelPublicKeys this_ptr_conv;
36375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36376         this_ptr_conv.is_owned = false;
36377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36378         LDKPublicKey val_ref;
36379         CHECK((*env)->GetArrayLength(env, val) == 33);
36380         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36381         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
36382 }
36383
36384 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36385         LDKChannelPublicKeys this_ptr_conv;
36386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36387         this_ptr_conv.is_owned = false;
36388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36389         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36390         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
36391         return ret_arr;
36392 }
36393
36394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36395         LDKChannelPublicKeys this_ptr_conv;
36396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36397         this_ptr_conv.is_owned = false;
36398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36399         LDKPublicKey val_ref;
36400         CHECK((*env)->GetArrayLength(env, val) == 33);
36401         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36402         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
36403 }
36404
36405 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
36406         LDKChannelPublicKeys this_ptr_conv;
36407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36408         this_ptr_conv.is_owned = false;
36409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36410         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36411         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
36412         return ret_arr;
36413 }
36414
36415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36416         LDKChannelPublicKeys this_ptr_conv;
36417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36418         this_ptr_conv.is_owned = false;
36419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36420         LDKPublicKey val_ref;
36421         CHECK((*env)->GetArrayLength(env, val) == 33);
36422         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36423         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
36424 }
36425
36426 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
36427         LDKChannelPublicKeys this_ptr_conv;
36428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36429         this_ptr_conv.is_owned = false;
36430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36431         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36432         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
36433         return ret_arr;
36434 }
36435
36436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36437         LDKChannelPublicKeys this_ptr_conv;
36438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36439         this_ptr_conv.is_owned = false;
36440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36441         LDKPublicKey val_ref;
36442         CHECK((*env)->GetArrayLength(env, val) == 33);
36443         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36444         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
36445 }
36446
36447 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) {
36448         LDKPublicKey funding_pubkey_arg_ref;
36449         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
36450         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
36451         LDKPublicKey revocation_basepoint_arg_ref;
36452         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
36453         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
36454         LDKPublicKey payment_point_arg_ref;
36455         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
36456         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
36457         LDKPublicKey delayed_payment_basepoint_arg_ref;
36458         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
36459         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
36460         LDKPublicKey htlc_basepoint_arg_ref;
36461         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
36462         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
36463         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);
36464         uintptr_t ret_ref = 0;
36465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36468         ret_ref = (uintptr_t)ret_var.inner;
36469         if (ret_var.is_owned) {
36470                 ret_ref |= 1;
36471         }
36472         return ret_ref;
36473 }
36474
36475 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
36476         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
36477 uintptr_t ret_ref = 0;
36478 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36479 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36480 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36481 ret_ref = (uintptr_t)ret_var.inner;
36482 if (ret_var.is_owned) {
36483         ret_ref |= 1;
36484 }
36485         return ret_ref;
36486 }
36487 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36488         LDKChannelPublicKeys arg_conv;
36489         arg_conv.inner = (void*)(arg & (~1));
36490         arg_conv.is_owned = false;
36491         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36492         intptr_t ret_val = ChannelPublicKeys_clone_ptr(&arg_conv);
36493         return ret_val;
36494 }
36495
36496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36497         LDKChannelPublicKeys orig_conv;
36498         orig_conv.inner = (void*)(orig & (~1));
36499         orig_conv.is_owned = false;
36500         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36501         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
36502         uintptr_t ret_ref = 0;
36503         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36504         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36506         ret_ref = (uintptr_t)ret_var.inner;
36507         if (ret_var.is_owned) {
36508                 ret_ref |= 1;
36509         }
36510         return ret_ref;
36511 }
36512
36513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
36514         LDKChannelPublicKeys obj_conv;
36515         obj_conv.inner = (void*)(obj & (~1));
36516         obj_conv.is_owned = false;
36517         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36518         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
36519         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36520         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36521         CVec_u8Z_free(ret_var);
36522         return ret_arr;
36523 }
36524
36525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36526         LDKu8slice ser_ref;
36527         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36528         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36529         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
36530         *ret_conv = ChannelPublicKeys_read(ser_ref);
36531         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36532         return (uintptr_t)ret_conv;
36533 }
36534
36535 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) {
36536         LDKPublicKey per_commitment_point_ref;
36537         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36538         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36539         LDKPublicKey broadcaster_delayed_payment_base_ref;
36540         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
36541         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
36542         LDKPublicKey broadcaster_htlc_base_ref;
36543         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
36544         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
36545         LDKPublicKey countersignatory_revocation_base_ref;
36546         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
36547         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
36548         LDKPublicKey countersignatory_htlc_base_ref;
36549         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
36550         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
36551         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
36552         *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);
36553         return (uintptr_t)ret_conv;
36554 }
36555
36556 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) {
36557         LDKPublicKey per_commitment_point_ref;
36558         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36559         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36560         LDKChannelPublicKeys broadcaster_keys_conv;
36561         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
36562         broadcaster_keys_conv.is_owned = false;
36563         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
36564         LDKChannelPublicKeys countersignatory_keys_conv;
36565         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
36566         countersignatory_keys_conv.is_owned = false;
36567         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
36568         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
36569         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
36570         return (uintptr_t)ret_conv;
36571 }
36572
36573 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) {
36574         LDKPublicKey revocation_key_ref;
36575         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
36576         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
36577         LDKPublicKey broadcaster_delayed_payment_key_ref;
36578         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
36579         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
36580         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
36581         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36582         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36583         CVec_u8Z_free(ret_var);
36584         return ret_arr;
36585 }
36586
36587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36588         LDKHTLCOutputInCommitment this_obj_conv;
36589         this_obj_conv.inner = (void*)(this_obj & (~1));
36590         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36592         HTLCOutputInCommitment_free(this_obj_conv);
36593 }
36594
36595 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
36596         LDKHTLCOutputInCommitment this_ptr_conv;
36597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36598         this_ptr_conv.is_owned = false;
36599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36600         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
36601         return ret_val;
36602 }
36603
36604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
36605         LDKHTLCOutputInCommitment this_ptr_conv;
36606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36607         this_ptr_conv.is_owned = false;
36608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36609         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
36610 }
36611
36612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
36613         LDKHTLCOutputInCommitment this_ptr_conv;
36614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36615         this_ptr_conv.is_owned = false;
36616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36617         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
36618         return ret_val;
36619 }
36620
36621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36622         LDKHTLCOutputInCommitment this_ptr_conv;
36623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36624         this_ptr_conv.is_owned = false;
36625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36626         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
36627 }
36628
36629 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
36630         LDKHTLCOutputInCommitment this_ptr_conv;
36631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36632         this_ptr_conv.is_owned = false;
36633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36634         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
36635         return ret_val;
36636 }
36637
36638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36639         LDKHTLCOutputInCommitment this_ptr_conv;
36640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36641         this_ptr_conv.is_owned = false;
36642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36643         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
36644 }
36645
36646 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36647         LDKHTLCOutputInCommitment this_ptr_conv;
36648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36649         this_ptr_conv.is_owned = false;
36650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36651         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36652         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
36653         return ret_arr;
36654 }
36655
36656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36657         LDKHTLCOutputInCommitment this_ptr_conv;
36658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36659         this_ptr_conv.is_owned = false;
36660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36661         LDKThirtyTwoBytes val_ref;
36662         CHECK((*env)->GetArrayLength(env, val) == 32);
36663         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36664         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
36665 }
36666
36667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
36668         LDKHTLCOutputInCommitment this_ptr_conv;
36669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36670         this_ptr_conv.is_owned = false;
36671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36672         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
36673         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
36674         uintptr_t ret_ref = (uintptr_t)ret_copy;
36675         return ret_ref;
36676 }
36677
36678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36679         LDKHTLCOutputInCommitment this_ptr_conv;
36680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36681         this_ptr_conv.is_owned = false;
36682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36683         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36684         CHECK_ACCESS(val_ptr);
36685         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
36686         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
36687         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
36688 }
36689
36690 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) {
36691         LDKThirtyTwoBytes payment_hash_arg_ref;
36692         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
36693         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
36694         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
36695         CHECK_ACCESS(transaction_output_index_arg_ptr);
36696         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
36697         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
36698         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
36699         uintptr_t ret_ref = 0;
36700         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36701         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36703         ret_ref = (uintptr_t)ret_var.inner;
36704         if (ret_var.is_owned) {
36705                 ret_ref |= 1;
36706         }
36707         return ret_ref;
36708 }
36709
36710 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
36711         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
36712 uintptr_t ret_ref = 0;
36713 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36714 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36715 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36716 ret_ref = (uintptr_t)ret_var.inner;
36717 if (ret_var.is_owned) {
36718         ret_ref |= 1;
36719 }
36720         return ret_ref;
36721 }
36722 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36723         LDKHTLCOutputInCommitment arg_conv;
36724         arg_conv.inner = (void*)(arg & (~1));
36725         arg_conv.is_owned = false;
36726         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36727         intptr_t ret_val = HTLCOutputInCommitment_clone_ptr(&arg_conv);
36728         return ret_val;
36729 }
36730
36731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36732         LDKHTLCOutputInCommitment orig_conv;
36733         orig_conv.inner = (void*)(orig & (~1));
36734         orig_conv.is_owned = false;
36735         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36736         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
36737         uintptr_t ret_ref = 0;
36738         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36739         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36741         ret_ref = (uintptr_t)ret_var.inner;
36742         if (ret_var.is_owned) {
36743                 ret_ref |= 1;
36744         }
36745         return ret_ref;
36746 }
36747
36748 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
36749         LDKHTLCOutputInCommitment obj_conv;
36750         obj_conv.inner = (void*)(obj & (~1));
36751         obj_conv.is_owned = false;
36752         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36753         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
36754         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36755         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36756         CVec_u8Z_free(ret_var);
36757         return ret_arr;
36758 }
36759
36760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36761         LDKu8slice ser_ref;
36762         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36763         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36764         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
36765         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
36766         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36767         return (uintptr_t)ret_conv;
36768 }
36769
36770 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) {
36771         LDKHTLCOutputInCommitment htlc_conv;
36772         htlc_conv.inner = (void*)(htlc & (~1));
36773         htlc_conv.is_owned = false;
36774         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
36775         LDKTxCreationKeys keys_conv;
36776         keys_conv.inner = (void*)(keys & (~1));
36777         keys_conv.is_owned = false;
36778         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
36779         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
36780         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36781         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36782         CVec_u8Z_free(ret_var);
36783         return ret_arr;
36784 }
36785
36786 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
36787         LDKPublicKey broadcaster_ref;
36788         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
36789         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
36790         LDKPublicKey countersignatory_ref;
36791         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
36792         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
36793         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
36794         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36795         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36796         CVec_u8Z_free(ret_var);
36797         return ret_arr;
36798 }
36799
36800 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) {
36801         unsigned char commitment_txid_arr[32];
36802         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
36803         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
36804         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
36805         LDKHTLCOutputInCommitment htlc_conv;
36806         htlc_conv.inner = (void*)(htlc & (~1));
36807         htlc_conv.is_owned = false;
36808         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
36809         LDKPublicKey broadcaster_delayed_payment_key_ref;
36810         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
36811         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
36812         LDKPublicKey revocation_key_ref;
36813         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
36814         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
36815         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);
36816         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36817         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36818         Transaction_free(ret_var);
36819         return ret_arr;
36820 }
36821
36822 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
36823         LDKPublicKey funding_pubkey_ref;
36824         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
36825         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
36826         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
36827         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36828         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36829         CVec_u8Z_free(ret_var);
36830         return ret_arr;
36831 }
36832
36833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36834         LDKChannelTransactionParameters this_obj_conv;
36835         this_obj_conv.inner = (void*)(this_obj & (~1));
36836         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36838         ChannelTransactionParameters_free(this_obj_conv);
36839 }
36840
36841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
36842         LDKChannelTransactionParameters this_ptr_conv;
36843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36844         this_ptr_conv.is_owned = false;
36845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36846         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
36847         uintptr_t ret_ref = 0;
36848         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36849         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36850         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36851         ret_ref = (uintptr_t)ret_var.inner;
36852         if (ret_var.is_owned) {
36853                 ret_ref |= 1;
36854         }
36855         return ret_ref;
36856 }
36857
36858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36859         LDKChannelTransactionParameters this_ptr_conv;
36860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36861         this_ptr_conv.is_owned = false;
36862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36863         LDKChannelPublicKeys val_conv;
36864         val_conv.inner = (void*)(val & (~1));
36865         val_conv.is_owned = (val & 1) || (val == 0);
36866         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36867         val_conv = ChannelPublicKeys_clone(&val_conv);
36868         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
36869 }
36870
36871 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
36872         LDKChannelTransactionParameters this_ptr_conv;
36873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36874         this_ptr_conv.is_owned = false;
36875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36876         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
36877         return ret_val;
36878 }
36879
36880 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) {
36881         LDKChannelTransactionParameters this_ptr_conv;
36882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36883         this_ptr_conv.is_owned = false;
36884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36885         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
36886 }
36887
36888 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
36889         LDKChannelTransactionParameters 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         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
36894         return ret_val;
36895 }
36896
36897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
36898         LDKChannelTransactionParameters this_ptr_conv;
36899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36900         this_ptr_conv.is_owned = false;
36901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36902         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
36903 }
36904
36905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
36906         LDKChannelTransactionParameters this_ptr_conv;
36907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36908         this_ptr_conv.is_owned = false;
36909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36910         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
36911         uintptr_t ret_ref = 0;
36912         if ((uintptr_t)ret_var.inner > 4096) {
36913                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36914                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36916                 ret_ref = (uintptr_t)ret_var.inner;
36917                 if (ret_var.is_owned) {
36918                         ret_ref |= 1;
36919                 }
36920         }
36921         return ret_ref;
36922 }
36923
36924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36925         LDKChannelTransactionParameters this_ptr_conv;
36926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36927         this_ptr_conv.is_owned = false;
36928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36929         LDKCounterpartyChannelTransactionParameters val_conv;
36930         val_conv.inner = (void*)(val & (~1));
36931         val_conv.is_owned = (val & 1) || (val == 0);
36932         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36933         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
36934         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
36935 }
36936
36937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
36938         LDKChannelTransactionParameters this_ptr_conv;
36939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36940         this_ptr_conv.is_owned = false;
36941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36942         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
36943         uintptr_t ret_ref = 0;
36944         if ((uintptr_t)ret_var.inner > 4096) {
36945                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36946                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36948                 ret_ref = (uintptr_t)ret_var.inner;
36949                 if (ret_var.is_owned) {
36950                         ret_ref |= 1;
36951                 }
36952         }
36953         return ret_ref;
36954 }
36955
36956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36957         LDKChannelTransactionParameters this_ptr_conv;
36958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36959         this_ptr_conv.is_owned = false;
36960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36961         LDKOutPoint val_conv;
36962         val_conv.inner = (void*)(val & (~1));
36963         val_conv.is_owned = (val & 1) || (val == 0);
36964         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36965         val_conv = OutPoint_clone(&val_conv);
36966         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
36967 }
36968
36969 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
36970         LDKChannelTransactionParameters this_ptr_conv;
36971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36972         this_ptr_conv.is_owned = false;
36973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36974         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
36975         return ret_conv;
36976 }
36977
36978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
36979         LDKChannelTransactionParameters this_ptr_conv;
36980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36981         this_ptr_conv.is_owned = false;
36982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36983         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
36984         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
36985 }
36986
36987 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) {
36988         LDKChannelPublicKeys holder_pubkeys_arg_conv;
36989         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
36990         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
36991         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
36992         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
36993         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
36994         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
36995         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
36996         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
36997         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
36998         LDKOutPoint funding_outpoint_arg_conv;
36999         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
37000         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
37001         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
37002         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
37003         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
37004         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);
37005         uintptr_t ret_ref = 0;
37006         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37007         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37009         ret_ref = (uintptr_t)ret_var.inner;
37010         if (ret_var.is_owned) {
37011                 ret_ref |= 1;
37012         }
37013         return ret_ref;
37014 }
37015
37016 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
37017         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
37018 uintptr_t ret_ref = 0;
37019 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37020 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37021 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37022 ret_ref = (uintptr_t)ret_var.inner;
37023 if (ret_var.is_owned) {
37024         ret_ref |= 1;
37025 }
37026         return ret_ref;
37027 }
37028 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37029         LDKChannelTransactionParameters arg_conv;
37030         arg_conv.inner = (void*)(arg & (~1));
37031         arg_conv.is_owned = false;
37032         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37033         intptr_t ret_val = ChannelTransactionParameters_clone_ptr(&arg_conv);
37034         return ret_val;
37035 }
37036
37037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37038         LDKChannelTransactionParameters orig_conv;
37039         orig_conv.inner = (void*)(orig & (~1));
37040         orig_conv.is_owned = false;
37041         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37042         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
37043         uintptr_t ret_ref = 0;
37044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37047         ret_ref = (uintptr_t)ret_var.inner;
37048         if (ret_var.is_owned) {
37049                 ret_ref |= 1;
37050         }
37051         return ret_ref;
37052 }
37053
37054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37055         LDKCounterpartyChannelTransactionParameters this_obj_conv;
37056         this_obj_conv.inner = (void*)(this_obj & (~1));
37057         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37059         CounterpartyChannelTransactionParameters_free(this_obj_conv);
37060 }
37061
37062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
37063         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37065         this_ptr_conv.is_owned = false;
37066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37067         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
37068         uintptr_t ret_ref = 0;
37069         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37070         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37072         ret_ref = (uintptr_t)ret_var.inner;
37073         if (ret_var.is_owned) {
37074                 ret_ref |= 1;
37075         }
37076         return ret_ref;
37077 }
37078
37079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37080         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37082         this_ptr_conv.is_owned = false;
37083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37084         LDKChannelPublicKeys val_conv;
37085         val_conv.inner = (void*)(val & (~1));
37086         val_conv.is_owned = (val & 1) || (val == 0);
37087         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37088         val_conv = ChannelPublicKeys_clone(&val_conv);
37089         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
37090 }
37091
37092 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
37093         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37095         this_ptr_conv.is_owned = false;
37096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37097         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
37098         return ret_val;
37099 }
37100
37101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
37102         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37104         this_ptr_conv.is_owned = false;
37105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37106         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
37107 }
37108
37109 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) {
37110         LDKChannelPublicKeys pubkeys_arg_conv;
37111         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
37112         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
37113         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
37114         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
37115         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
37116         uintptr_t ret_ref = 0;
37117         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37118         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37120         ret_ref = (uintptr_t)ret_var.inner;
37121         if (ret_var.is_owned) {
37122                 ret_ref |= 1;
37123         }
37124         return ret_ref;
37125 }
37126
37127 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
37128         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
37129 uintptr_t ret_ref = 0;
37130 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37131 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37132 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37133 ret_ref = (uintptr_t)ret_var.inner;
37134 if (ret_var.is_owned) {
37135         ret_ref |= 1;
37136 }
37137         return ret_ref;
37138 }
37139 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37140         LDKCounterpartyChannelTransactionParameters arg_conv;
37141         arg_conv.inner = (void*)(arg & (~1));
37142         arg_conv.is_owned = false;
37143         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37144         intptr_t ret_val = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
37145         return ret_val;
37146 }
37147
37148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37149         LDKCounterpartyChannelTransactionParameters orig_conv;
37150         orig_conv.inner = (void*)(orig & (~1));
37151         orig_conv.is_owned = false;
37152         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37153         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
37154         uintptr_t ret_ref = 0;
37155         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37156         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37158         ret_ref = (uintptr_t)ret_var.inner;
37159         if (ret_var.is_owned) {
37160                 ret_ref |= 1;
37161         }
37162         return ret_ref;
37163 }
37164
37165 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
37166         LDKChannelTransactionParameters this_arg_conv;
37167         this_arg_conv.inner = (void*)(this_arg & (~1));
37168         this_arg_conv.is_owned = false;
37169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37170         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
37171         return ret_val;
37172 }
37173
37174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
37175         LDKChannelTransactionParameters this_arg_conv;
37176         this_arg_conv.inner = (void*)(this_arg & (~1));
37177         this_arg_conv.is_owned = false;
37178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37179         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
37180         uintptr_t ret_ref = 0;
37181         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37182         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37184         ret_ref = (uintptr_t)ret_var.inner;
37185         if (ret_var.is_owned) {
37186                 ret_ref |= 1;
37187         }
37188         return ret_ref;
37189 }
37190
37191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
37192         LDKChannelTransactionParameters this_arg_conv;
37193         this_arg_conv.inner = (void*)(this_arg & (~1));
37194         this_arg_conv.is_owned = false;
37195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37196         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
37197         uintptr_t ret_ref = 0;
37198         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37199         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37201         ret_ref = (uintptr_t)ret_var.inner;
37202         if (ret_var.is_owned) {
37203                 ret_ref |= 1;
37204         }
37205         return ret_ref;
37206 }
37207
37208 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
37209         LDKCounterpartyChannelTransactionParameters obj_conv;
37210         obj_conv.inner = (void*)(obj & (~1));
37211         obj_conv.is_owned = false;
37212         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37213         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
37214         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37215         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37216         CVec_u8Z_free(ret_var);
37217         return ret_arr;
37218 }
37219
37220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37221         LDKu8slice ser_ref;
37222         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37223         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37224         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
37225         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
37226         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37227         return (uintptr_t)ret_conv;
37228 }
37229
37230 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
37231         LDKChannelTransactionParameters obj_conv;
37232         obj_conv.inner = (void*)(obj & (~1));
37233         obj_conv.is_owned = false;
37234         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37235         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
37236         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37237         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37238         CVec_u8Z_free(ret_var);
37239         return ret_arr;
37240 }
37241
37242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37243         LDKu8slice ser_ref;
37244         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37245         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37246         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
37247         *ret_conv = ChannelTransactionParameters_read(ser_ref);
37248         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37249         return (uintptr_t)ret_conv;
37250 }
37251
37252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37253         LDKDirectedChannelTransactionParameters this_obj_conv;
37254         this_obj_conv.inner = (void*)(this_obj & (~1));
37255         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37257         DirectedChannelTransactionParameters_free(this_obj_conv);
37258 }
37259
37260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
37261         LDKDirectedChannelTransactionParameters this_arg_conv;
37262         this_arg_conv.inner = (void*)(this_arg & (~1));
37263         this_arg_conv.is_owned = false;
37264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37265         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
37266         uintptr_t ret_ref = 0;
37267         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37268         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37270         ret_ref = (uintptr_t)ret_var.inner;
37271         if (ret_var.is_owned) {
37272                 ret_ref |= 1;
37273         }
37274         return ret_ref;
37275 }
37276
37277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
37278         LDKDirectedChannelTransactionParameters this_arg_conv;
37279         this_arg_conv.inner = (void*)(this_arg & (~1));
37280         this_arg_conv.is_owned = false;
37281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37282         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
37283         uintptr_t ret_ref = 0;
37284         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37285         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37287         ret_ref = (uintptr_t)ret_var.inner;
37288         if (ret_var.is_owned) {
37289                 ret_ref |= 1;
37290         }
37291         return ret_ref;
37292 }
37293
37294 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
37295         LDKDirectedChannelTransactionParameters this_arg_conv;
37296         this_arg_conv.inner = (void*)(this_arg & (~1));
37297         this_arg_conv.is_owned = false;
37298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37299         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
37300         return ret_val;
37301 }
37302
37303 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
37304         LDKDirectedChannelTransactionParameters this_arg_conv;
37305         this_arg_conv.inner = (void*)(this_arg & (~1));
37306         this_arg_conv.is_owned = false;
37307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37308         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
37309         return ret_val;
37310 }
37311
37312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
37313         LDKDirectedChannelTransactionParameters this_arg_conv;
37314         this_arg_conv.inner = (void*)(this_arg & (~1));
37315         this_arg_conv.is_owned = false;
37316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37317         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
37318         uintptr_t ret_ref = 0;
37319         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37320         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37322         ret_ref = (uintptr_t)ret_var.inner;
37323         if (ret_var.is_owned) {
37324                 ret_ref |= 1;
37325         }
37326         return ret_ref;
37327 }
37328
37329 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
37330         LDKDirectedChannelTransactionParameters this_arg_conv;
37331         this_arg_conv.inner = (void*)(this_arg & (~1));
37332         this_arg_conv.is_owned = false;
37333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37334         jboolean ret_val = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
37335         return ret_val;
37336 }
37337
37338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37339         LDKHolderCommitmentTransaction this_obj_conv;
37340         this_obj_conv.inner = (void*)(this_obj & (~1));
37341         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37343         HolderCommitmentTransaction_free(this_obj_conv);
37344 }
37345
37346 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
37347         LDKHolderCommitmentTransaction this_ptr_conv;
37348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37349         this_ptr_conv.is_owned = false;
37350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37351         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37352         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
37353         return ret_arr;
37354 }
37355
37356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37357         LDKHolderCommitmentTransaction this_ptr_conv;
37358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37359         this_ptr_conv.is_owned = false;
37360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37361         LDKSignature val_ref;
37362         CHECK((*env)->GetArrayLength(env, val) == 64);
37363         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37364         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
37365 }
37366
37367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
37368         LDKHolderCommitmentTransaction this_ptr_conv;
37369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37370         this_ptr_conv.is_owned = false;
37371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37372         LDKCVec_SignatureZ val_constr;
37373         val_constr.datalen = (*env)->GetArrayLength(env, val);
37374         if (val_constr.datalen > 0)
37375                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
37376         else
37377                 val_constr.data = NULL;
37378         for (size_t i = 0; i < val_constr.datalen; i++) {
37379                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
37380                 LDKSignature val_conv_8_ref;
37381                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
37382                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
37383                 val_constr.data[i] = val_conv_8_ref;
37384         }
37385         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
37386 }
37387
37388 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
37389         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
37390 uintptr_t ret_ref = 0;
37391 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37392 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37393 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37394 ret_ref = (uintptr_t)ret_var.inner;
37395 if (ret_var.is_owned) {
37396         ret_ref |= 1;
37397 }
37398         return ret_ref;
37399 }
37400 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37401         LDKHolderCommitmentTransaction arg_conv;
37402         arg_conv.inner = (void*)(arg & (~1));
37403         arg_conv.is_owned = false;
37404         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37405         intptr_t ret_val = HolderCommitmentTransaction_clone_ptr(&arg_conv);
37406         return ret_val;
37407 }
37408
37409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37410         LDKHolderCommitmentTransaction orig_conv;
37411         orig_conv.inner = (void*)(orig & (~1));
37412         orig_conv.is_owned = false;
37413         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37414         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
37415         uintptr_t ret_ref = 0;
37416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37419         ret_ref = (uintptr_t)ret_var.inner;
37420         if (ret_var.is_owned) {
37421                 ret_ref |= 1;
37422         }
37423         return ret_ref;
37424 }
37425
37426 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
37427         LDKHolderCommitmentTransaction obj_conv;
37428         obj_conv.inner = (void*)(obj & (~1));
37429         obj_conv.is_owned = false;
37430         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37431         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
37432         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37433         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37434         CVec_u8Z_free(ret_var);
37435         return ret_arr;
37436 }
37437
37438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37439         LDKu8slice ser_ref;
37440         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37441         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37442         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
37443         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
37444         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37445         return (uintptr_t)ret_conv;
37446 }
37447
37448 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) {
37449         LDKCommitmentTransaction commitment_tx_conv;
37450         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
37451         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
37452         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
37453         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
37454         LDKSignature counterparty_sig_ref;
37455         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
37456         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
37457         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
37458         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
37459         if (counterparty_htlc_sigs_constr.datalen > 0)
37460                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
37461         else
37462                 counterparty_htlc_sigs_constr.data = NULL;
37463         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
37464                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
37465                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
37466                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
37467                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
37468                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
37469         }
37470         LDKPublicKey holder_funding_key_ref;
37471         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
37472         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
37473         LDKPublicKey counterparty_funding_key_ref;
37474         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
37475         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
37476         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
37477         uintptr_t ret_ref = 0;
37478         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37479         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37481         ret_ref = (uintptr_t)ret_var.inner;
37482         if (ret_var.is_owned) {
37483                 ret_ref |= 1;
37484         }
37485         return ret_ref;
37486 }
37487
37488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37489         LDKBuiltCommitmentTransaction this_obj_conv;
37490         this_obj_conv.inner = (void*)(this_obj & (~1));
37491         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37493         BuiltCommitmentTransaction_free(this_obj_conv);
37494 }
37495
37496 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
37497         LDKBuiltCommitmentTransaction this_ptr_conv;
37498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37499         this_ptr_conv.is_owned = false;
37500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37501         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
37502         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37503         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37504         Transaction_free(ret_var);
37505         return ret_arr;
37506 }
37507
37508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37509         LDKBuiltCommitmentTransaction this_ptr_conv;
37510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37511         this_ptr_conv.is_owned = false;
37512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37513         LDKTransaction val_ref;
37514         val_ref.datalen = (*env)->GetArrayLength(env, val);
37515         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
37516         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
37517         val_ref.data_is_owned = true;
37518         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
37519 }
37520
37521 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
37522         LDKBuiltCommitmentTransaction this_ptr_conv;
37523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37524         this_ptr_conv.is_owned = false;
37525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37526         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37527         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
37528         return ret_arr;
37529 }
37530
37531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37532         LDKBuiltCommitmentTransaction this_ptr_conv;
37533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37534         this_ptr_conv.is_owned = false;
37535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37536         LDKThirtyTwoBytes val_ref;
37537         CHECK((*env)->GetArrayLength(env, val) == 32);
37538         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37539         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
37540 }
37541
37542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
37543         LDKTransaction transaction_arg_ref;
37544         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
37545         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
37546         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
37547         transaction_arg_ref.data_is_owned = true;
37548         LDKThirtyTwoBytes txid_arg_ref;
37549         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
37550         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
37551         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
37552         uintptr_t ret_ref = 0;
37553         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37554         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37556         ret_ref = (uintptr_t)ret_var.inner;
37557         if (ret_var.is_owned) {
37558                 ret_ref |= 1;
37559         }
37560         return ret_ref;
37561 }
37562
37563 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
37564         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
37565 uintptr_t ret_ref = 0;
37566 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37567 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37568 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37569 ret_ref = (uintptr_t)ret_var.inner;
37570 if (ret_var.is_owned) {
37571         ret_ref |= 1;
37572 }
37573         return ret_ref;
37574 }
37575 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37576         LDKBuiltCommitmentTransaction arg_conv;
37577         arg_conv.inner = (void*)(arg & (~1));
37578         arg_conv.is_owned = false;
37579         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37580         intptr_t ret_val = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
37581         return ret_val;
37582 }
37583
37584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37585         LDKBuiltCommitmentTransaction orig_conv;
37586         orig_conv.inner = (void*)(orig & (~1));
37587         orig_conv.is_owned = false;
37588         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37589         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
37590         uintptr_t ret_ref = 0;
37591         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37592         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37594         ret_ref = (uintptr_t)ret_var.inner;
37595         if (ret_var.is_owned) {
37596                 ret_ref |= 1;
37597         }
37598         return ret_ref;
37599 }
37600
37601 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
37602         LDKBuiltCommitmentTransaction obj_conv;
37603         obj_conv.inner = (void*)(obj & (~1));
37604         obj_conv.is_owned = false;
37605         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37606         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
37607         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37608         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37609         CVec_u8Z_free(ret_var);
37610         return ret_arr;
37611 }
37612
37613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37614         LDKu8slice ser_ref;
37615         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37616         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37617         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
37618         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
37619         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37620         return (uintptr_t)ret_conv;
37621 }
37622
37623 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) {
37624         LDKBuiltCommitmentTransaction this_arg_conv;
37625         this_arg_conv.inner = (void*)(this_arg & (~1));
37626         this_arg_conv.is_owned = false;
37627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37628         LDKu8slice funding_redeemscript_ref;
37629         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
37630         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
37631         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37632         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
37633         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
37634         return ret_arr;
37635 }
37636
37637 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) {
37638         LDKBuiltCommitmentTransaction this_arg_conv;
37639         this_arg_conv.inner = (void*)(this_arg & (~1));
37640         this_arg_conv.is_owned = false;
37641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37642         unsigned char funding_key_arr[32];
37643         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
37644         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
37645         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
37646         LDKu8slice funding_redeemscript_ref;
37647         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
37648         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
37649         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37650         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
37651         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
37652         return ret_arr;
37653 }
37654
37655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37656         LDKClosingTransaction this_obj_conv;
37657         this_obj_conv.inner = (void*)(this_obj & (~1));
37658         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37660         ClosingTransaction_free(this_obj_conv);
37661 }
37662
37663 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
37664         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
37665 uintptr_t ret_ref = 0;
37666 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37667 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37668 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37669 ret_ref = (uintptr_t)ret_var.inner;
37670 if (ret_var.is_owned) {
37671         ret_ref |= 1;
37672 }
37673         return ret_ref;
37674 }
37675 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37676         LDKClosingTransaction arg_conv;
37677         arg_conv.inner = (void*)(arg & (~1));
37678         arg_conv.is_owned = false;
37679         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37680         intptr_t ret_val = ClosingTransaction_clone_ptr(&arg_conv);
37681         return ret_val;
37682 }
37683
37684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37685         LDKClosingTransaction orig_conv;
37686         orig_conv.inner = (void*)(orig & (~1));
37687         orig_conv.is_owned = false;
37688         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37689         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
37690         uintptr_t ret_ref = 0;
37691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37694         ret_ref = (uintptr_t)ret_var.inner;
37695         if (ret_var.is_owned) {
37696                 ret_ref |= 1;
37697         }
37698         return ret_ref;
37699 }
37700
37701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
37702         LDKClosingTransaction o_conv;
37703         o_conv.inner = (void*)(o & (~1));
37704         o_conv.is_owned = false;
37705         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37706         int64_t ret_val = ClosingTransaction_hash(&o_conv);
37707         return ret_val;
37708 }
37709
37710 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) {
37711         LDKCVec_u8Z to_holder_script_ref;
37712         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
37713         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
37714         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
37715         LDKCVec_u8Z to_counterparty_script_ref;
37716         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
37717         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
37718         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
37719         LDKOutPoint funding_outpoint_conv;
37720         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
37721         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
37722         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
37723         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
37724         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
37725         uintptr_t ret_ref = 0;
37726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37729         ret_ref = (uintptr_t)ret_var.inner;
37730         if (ret_var.is_owned) {
37731                 ret_ref |= 1;
37732         }
37733         return ret_ref;
37734 }
37735
37736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
37737         LDKClosingTransaction this_arg_conv;
37738         this_arg_conv.inner = (void*)(this_arg & (~1));
37739         this_arg_conv.is_owned = false;
37740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37741         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
37742         uintptr_t ret_ref = 0;
37743         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37744         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37746         ret_ref = (uintptr_t)ret_var.inner;
37747         if (ret_var.is_owned) {
37748                 ret_ref |= 1;
37749         }
37750         return ret_ref;
37751 }
37752
37753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
37754         LDKClosingTransaction this_arg_conv;
37755         this_arg_conv.inner = (void*)(this_arg & (~1));
37756         this_arg_conv.is_owned = false;
37757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37758         LDKOutPoint funding_outpoint_conv;
37759         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
37760         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
37761         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
37762         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
37763         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
37764         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
37765         return (uintptr_t)ret_conv;
37766 }
37767
37768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
37769         LDKClosingTransaction this_arg_conv;
37770         this_arg_conv.inner = (void*)(this_arg & (~1));
37771         this_arg_conv.is_owned = false;
37772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37773         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
37774         return ret_val;
37775 }
37776
37777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
37778         LDKClosingTransaction this_arg_conv;
37779         this_arg_conv.inner = (void*)(this_arg & (~1));
37780         this_arg_conv.is_owned = false;
37781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37782         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
37783         return ret_val;
37784 }
37785
37786 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
37787         LDKClosingTransaction this_arg_conv;
37788         this_arg_conv.inner = (void*)(this_arg & (~1));
37789         this_arg_conv.is_owned = false;
37790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37791         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
37792         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37793         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37794         return ret_arr;
37795 }
37796
37797 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
37798         LDKClosingTransaction this_arg_conv;
37799         this_arg_conv.inner = (void*)(this_arg & (~1));
37800         this_arg_conv.is_owned = false;
37801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37802         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
37803         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37804         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37805         return ret_arr;
37806 }
37807
37808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37809         LDKTrustedClosingTransaction this_obj_conv;
37810         this_obj_conv.inner = (void*)(this_obj & (~1));
37811         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37813         TrustedClosingTransaction_free(this_obj_conv);
37814 }
37815
37816 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
37817         LDKTrustedClosingTransaction this_arg_conv;
37818         this_arg_conv.inner = (void*)(this_arg & (~1));
37819         this_arg_conv.is_owned = false;
37820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37821         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
37822         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37823         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37824         Transaction_free(ret_var);
37825         return ret_arr;
37826 }
37827
37828 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) {
37829         LDKTrustedClosingTransaction this_arg_conv;
37830         this_arg_conv.inner = (void*)(this_arg & (~1));
37831         this_arg_conv.is_owned = false;
37832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37833         LDKu8slice funding_redeemscript_ref;
37834         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
37835         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
37836         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37837         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
37838         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
37839         return ret_arr;
37840 }
37841
37842 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) {
37843         LDKTrustedClosingTransaction this_arg_conv;
37844         this_arg_conv.inner = (void*)(this_arg & (~1));
37845         this_arg_conv.is_owned = false;
37846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37847         unsigned char funding_key_arr[32];
37848         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
37849         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
37850         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
37851         LDKu8slice funding_redeemscript_ref;
37852         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
37853         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
37854         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37855         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
37856         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
37857         return ret_arr;
37858 }
37859
37860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37861         LDKCommitmentTransaction this_obj_conv;
37862         this_obj_conv.inner = (void*)(this_obj & (~1));
37863         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37865         CommitmentTransaction_free(this_obj_conv);
37866 }
37867
37868 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
37869         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
37870 uintptr_t ret_ref = 0;
37871 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37872 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37873 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37874 ret_ref = (uintptr_t)ret_var.inner;
37875 if (ret_var.is_owned) {
37876         ret_ref |= 1;
37877 }
37878         return ret_ref;
37879 }
37880 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37881         LDKCommitmentTransaction arg_conv;
37882         arg_conv.inner = (void*)(arg & (~1));
37883         arg_conv.is_owned = false;
37884         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37885         intptr_t ret_val = CommitmentTransaction_clone_ptr(&arg_conv);
37886         return ret_val;
37887 }
37888
37889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37890         LDKCommitmentTransaction orig_conv;
37891         orig_conv.inner = (void*)(orig & (~1));
37892         orig_conv.is_owned = false;
37893         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37894         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
37895         uintptr_t ret_ref = 0;
37896         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37897         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37899         ret_ref = (uintptr_t)ret_var.inner;
37900         if (ret_var.is_owned) {
37901                 ret_ref |= 1;
37902         }
37903         return ret_ref;
37904 }
37905
37906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
37907         LDKCommitmentTransaction obj_conv;
37908         obj_conv.inner = (void*)(obj & (~1));
37909         obj_conv.is_owned = false;
37910         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37911         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
37912         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37913         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37914         CVec_u8Z_free(ret_var);
37915         return ret_arr;
37916 }
37917
37918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37919         LDKu8slice ser_ref;
37920         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37921         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37922         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
37923         *ret_conv = CommitmentTransaction_read(ser_ref);
37924         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37925         return (uintptr_t)ret_conv;
37926 }
37927
37928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
37929         LDKCommitmentTransaction this_arg_conv;
37930         this_arg_conv.inner = (void*)(this_arg & (~1));
37931         this_arg_conv.is_owned = false;
37932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37933         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
37934         return ret_val;
37935 }
37936
37937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
37938         LDKCommitmentTransaction this_arg_conv;
37939         this_arg_conv.inner = (void*)(this_arg & (~1));
37940         this_arg_conv.is_owned = false;
37941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37942         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
37943         return ret_val;
37944 }
37945
37946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
37947         LDKCommitmentTransaction this_arg_conv;
37948         this_arg_conv.inner = (void*)(this_arg & (~1));
37949         this_arg_conv.is_owned = false;
37950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37951         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
37952         return ret_val;
37953 }
37954
37955 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
37956         LDKCommitmentTransaction this_arg_conv;
37957         this_arg_conv.inner = (void*)(this_arg & (~1));
37958         this_arg_conv.is_owned = false;
37959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37960         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
37961         return ret_val;
37962 }
37963
37964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
37965         LDKCommitmentTransaction this_arg_conv;
37966         this_arg_conv.inner = (void*)(this_arg & (~1));
37967         this_arg_conv.is_owned = false;
37968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37969         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
37970         uintptr_t ret_ref = 0;
37971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37974         ret_ref = (uintptr_t)ret_var.inner;
37975         if (ret_var.is_owned) {
37976                 ret_ref |= 1;
37977         }
37978         return ret_ref;
37979 }
37980
37981 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) {
37982         LDKCommitmentTransaction this_arg_conv;
37983         this_arg_conv.inner = (void*)(this_arg & (~1));
37984         this_arg_conv.is_owned = false;
37985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37986         LDKDirectedChannelTransactionParameters channel_parameters_conv;
37987         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
37988         channel_parameters_conv.is_owned = false;
37989         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
37990         LDKChannelPublicKeys broadcaster_keys_conv;
37991         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
37992         broadcaster_keys_conv.is_owned = false;
37993         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
37994         LDKChannelPublicKeys countersignatory_keys_conv;
37995         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
37996         countersignatory_keys_conv.is_owned = false;
37997         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
37998         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
37999         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
38000         return (uintptr_t)ret_conv;
38001 }
38002
38003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38004         LDKTrustedCommitmentTransaction this_obj_conv;
38005         this_obj_conv.inner = (void*)(this_obj & (~1));
38006         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38008         TrustedCommitmentTransaction_free(this_obj_conv);
38009 }
38010
38011 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
38012         LDKTrustedCommitmentTransaction this_arg_conv;
38013         this_arg_conv.inner = (void*)(this_arg & (~1));
38014         this_arg_conv.is_owned = false;
38015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38016         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38017         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
38018         return ret_arr;
38019 }
38020
38021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
38022         LDKTrustedCommitmentTransaction this_arg_conv;
38023         this_arg_conv.inner = (void*)(this_arg & (~1));
38024         this_arg_conv.is_owned = false;
38025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38026         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
38027         uintptr_t ret_ref = 0;
38028         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38029         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38031         ret_ref = (uintptr_t)ret_var.inner;
38032         if (ret_var.is_owned) {
38033                 ret_ref |= 1;
38034         }
38035         return ret_ref;
38036 }
38037
38038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
38039         LDKTrustedCommitmentTransaction this_arg_conv;
38040         this_arg_conv.inner = (void*)(this_arg & (~1));
38041         this_arg_conv.is_owned = false;
38042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38043         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
38044         uintptr_t ret_ref = 0;
38045         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38046         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38048         ret_ref = (uintptr_t)ret_var.inner;
38049         if (ret_var.is_owned) {
38050                 ret_ref |= 1;
38051         }
38052         return ret_ref;
38053 }
38054
38055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
38056         LDKTrustedCommitmentTransaction this_arg_conv;
38057         this_arg_conv.inner = (void*)(this_arg & (~1));
38058         this_arg_conv.is_owned = false;
38059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38060         jboolean ret_val = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
38061         return ret_val;
38062 }
38063
38064 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) {
38065         LDKTrustedCommitmentTransaction this_arg_conv;
38066         this_arg_conv.inner = (void*)(this_arg & (~1));
38067         this_arg_conv.is_owned = false;
38068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38069         unsigned char htlc_base_key_arr[32];
38070         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
38071         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
38072         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
38073         LDKDirectedChannelTransactionParameters channel_parameters_conv;
38074         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
38075         channel_parameters_conv.is_owned = false;
38076         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
38077         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
38078         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
38079         return (uintptr_t)ret_conv;
38080 }
38081
38082 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) {
38083         LDKPublicKey broadcaster_payment_basepoint_ref;
38084         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
38085         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
38086         LDKPublicKey countersignatory_payment_basepoint_ref;
38087         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
38088         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
38089         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
38090         return ret_val;
38091 }
38092
38093 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38094         LDKInitFeatures a_conv;
38095         a_conv.inner = (void*)(a & (~1));
38096         a_conv.is_owned = false;
38097         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38098         LDKInitFeatures b_conv;
38099         b_conv.inner = (void*)(b & (~1));
38100         b_conv.is_owned = false;
38101         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38102         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
38103         return ret_val;
38104 }
38105
38106 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38107         LDKNodeFeatures a_conv;
38108         a_conv.inner = (void*)(a & (~1));
38109         a_conv.is_owned = false;
38110         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38111         LDKNodeFeatures b_conv;
38112         b_conv.inner = (void*)(b & (~1));
38113         b_conv.is_owned = false;
38114         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38115         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
38116         return ret_val;
38117 }
38118
38119 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38120         LDKChannelFeatures a_conv;
38121         a_conv.inner = (void*)(a & (~1));
38122         a_conv.is_owned = false;
38123         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38124         LDKChannelFeatures b_conv;
38125         b_conv.inner = (void*)(b & (~1));
38126         b_conv.is_owned = false;
38127         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38128         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
38129         return ret_val;
38130 }
38131
38132 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38133         LDKInvoiceFeatures a_conv;
38134         a_conv.inner = (void*)(a & (~1));
38135         a_conv.is_owned = false;
38136         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38137         LDKInvoiceFeatures b_conv;
38138         b_conv.inner = (void*)(b & (~1));
38139         b_conv.is_owned = false;
38140         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38141         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
38142         return ret_val;
38143 }
38144
38145 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38146         LDKChannelTypeFeatures a_conv;
38147         a_conv.inner = (void*)(a & (~1));
38148         a_conv.is_owned = false;
38149         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38150         LDKChannelTypeFeatures b_conv;
38151         b_conv.inner = (void*)(b & (~1));
38152         b_conv.is_owned = false;
38153         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38154         jboolean ret_val = ChannelTypeFeatures_eq(&a_conv, &b_conv);
38155         return ret_val;
38156 }
38157
38158 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
38159         LDKInitFeatures ret_var = InitFeatures_clone(arg);
38160 uintptr_t ret_ref = 0;
38161 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38162 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38163 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38164 ret_ref = (uintptr_t)ret_var.inner;
38165 if (ret_var.is_owned) {
38166         ret_ref |= 1;
38167 }
38168         return ret_ref;
38169 }
38170 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38171         LDKInitFeatures arg_conv;
38172         arg_conv.inner = (void*)(arg & (~1));
38173         arg_conv.is_owned = false;
38174         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38175         intptr_t ret_val = InitFeatures_clone_ptr(&arg_conv);
38176         return ret_val;
38177 }
38178
38179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38180         LDKInitFeatures orig_conv;
38181         orig_conv.inner = (void*)(orig & (~1));
38182         orig_conv.is_owned = false;
38183         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38184         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
38185         uintptr_t ret_ref = 0;
38186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38189         ret_ref = (uintptr_t)ret_var.inner;
38190         if (ret_var.is_owned) {
38191                 ret_ref |= 1;
38192         }
38193         return ret_ref;
38194 }
38195
38196 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
38197         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
38198 uintptr_t ret_ref = 0;
38199 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38200 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38201 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38202 ret_ref = (uintptr_t)ret_var.inner;
38203 if (ret_var.is_owned) {
38204         ret_ref |= 1;
38205 }
38206         return ret_ref;
38207 }
38208 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38209         LDKNodeFeatures arg_conv;
38210         arg_conv.inner = (void*)(arg & (~1));
38211         arg_conv.is_owned = false;
38212         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38213         intptr_t ret_val = NodeFeatures_clone_ptr(&arg_conv);
38214         return ret_val;
38215 }
38216
38217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38218         LDKNodeFeatures orig_conv;
38219         orig_conv.inner = (void*)(orig & (~1));
38220         orig_conv.is_owned = false;
38221         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38222         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
38223         uintptr_t ret_ref = 0;
38224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38227         ret_ref = (uintptr_t)ret_var.inner;
38228         if (ret_var.is_owned) {
38229                 ret_ref |= 1;
38230         }
38231         return ret_ref;
38232 }
38233
38234 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
38235         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
38236 uintptr_t ret_ref = 0;
38237 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38238 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38239 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38240 ret_ref = (uintptr_t)ret_var.inner;
38241 if (ret_var.is_owned) {
38242         ret_ref |= 1;
38243 }
38244         return ret_ref;
38245 }
38246 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38247         LDKChannelFeatures arg_conv;
38248         arg_conv.inner = (void*)(arg & (~1));
38249         arg_conv.is_owned = false;
38250         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38251         intptr_t ret_val = ChannelFeatures_clone_ptr(&arg_conv);
38252         return ret_val;
38253 }
38254
38255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38256         LDKChannelFeatures orig_conv;
38257         orig_conv.inner = (void*)(orig & (~1));
38258         orig_conv.is_owned = false;
38259         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38260         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
38261         uintptr_t ret_ref = 0;
38262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38265         ret_ref = (uintptr_t)ret_var.inner;
38266         if (ret_var.is_owned) {
38267                 ret_ref |= 1;
38268         }
38269         return ret_ref;
38270 }
38271
38272 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
38273         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
38274 uintptr_t ret_ref = 0;
38275 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38276 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38277 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38278 ret_ref = (uintptr_t)ret_var.inner;
38279 if (ret_var.is_owned) {
38280         ret_ref |= 1;
38281 }
38282         return ret_ref;
38283 }
38284 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38285         LDKInvoiceFeatures arg_conv;
38286         arg_conv.inner = (void*)(arg & (~1));
38287         arg_conv.is_owned = false;
38288         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38289         intptr_t ret_val = InvoiceFeatures_clone_ptr(&arg_conv);
38290         return ret_val;
38291 }
38292
38293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38294         LDKInvoiceFeatures orig_conv;
38295         orig_conv.inner = (void*)(orig & (~1));
38296         orig_conv.is_owned = false;
38297         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38298         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
38299         uintptr_t ret_ref = 0;
38300         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38301         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38303         ret_ref = (uintptr_t)ret_var.inner;
38304         if (ret_var.is_owned) {
38305                 ret_ref |= 1;
38306         }
38307         return ret_ref;
38308 }
38309
38310 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
38311         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
38312 uintptr_t ret_ref = 0;
38313 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38314 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38315 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38316 ret_ref = (uintptr_t)ret_var.inner;
38317 if (ret_var.is_owned) {
38318         ret_ref |= 1;
38319 }
38320         return ret_ref;
38321 }
38322 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38323         LDKChannelTypeFeatures arg_conv;
38324         arg_conv.inner = (void*)(arg & (~1));
38325         arg_conv.is_owned = false;
38326         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38327         intptr_t ret_val = ChannelTypeFeatures_clone_ptr(&arg_conv);
38328         return ret_val;
38329 }
38330
38331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38332         LDKChannelTypeFeatures orig_conv;
38333         orig_conv.inner = (void*)(orig & (~1));
38334         orig_conv.is_owned = false;
38335         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38336         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
38337         uintptr_t ret_ref = 0;
38338         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38339         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38341         ret_ref = (uintptr_t)ret_var.inner;
38342         if (ret_var.is_owned) {
38343                 ret_ref |= 1;
38344         }
38345         return ret_ref;
38346 }
38347
38348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38349         LDKInitFeatures this_obj_conv;
38350         this_obj_conv.inner = (void*)(this_obj & (~1));
38351         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38353         InitFeatures_free(this_obj_conv);
38354 }
38355
38356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38357         LDKNodeFeatures this_obj_conv;
38358         this_obj_conv.inner = (void*)(this_obj & (~1));
38359         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38361         NodeFeatures_free(this_obj_conv);
38362 }
38363
38364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38365         LDKChannelFeatures this_obj_conv;
38366         this_obj_conv.inner = (void*)(this_obj & (~1));
38367         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38369         ChannelFeatures_free(this_obj_conv);
38370 }
38371
38372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38373         LDKInvoiceFeatures this_obj_conv;
38374         this_obj_conv.inner = (void*)(this_obj & (~1));
38375         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38377         InvoiceFeatures_free(this_obj_conv);
38378 }
38379
38380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38381         LDKChannelTypeFeatures this_obj_conv;
38382         this_obj_conv.inner = (void*)(this_obj & (~1));
38383         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38385         ChannelTypeFeatures_free(this_obj_conv);
38386 }
38387
38388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
38389         LDKInitFeatures ret_var = InitFeatures_empty();
38390         uintptr_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
38401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
38402         LDKInitFeatures ret_var = InitFeatures_known();
38403         uintptr_t ret_ref = 0;
38404         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38405         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38407         ret_ref = (uintptr_t)ret_var.inner;
38408         if (ret_var.is_owned) {
38409                 ret_ref |= 1;
38410         }
38411         return ret_ref;
38412 }
38413
38414 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
38415         LDKInitFeatures this_arg_conv;
38416         this_arg_conv.inner = (void*)(this_arg & (~1));
38417         this_arg_conv.is_owned = false;
38418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38419         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
38420         return ret_val;
38421 }
38422
38423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
38424         LDKNodeFeatures ret_var = NodeFeatures_empty();
38425         uintptr_t ret_ref = 0;
38426         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38427         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38429         ret_ref = (uintptr_t)ret_var.inner;
38430         if (ret_var.is_owned) {
38431                 ret_ref |= 1;
38432         }
38433         return ret_ref;
38434 }
38435
38436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
38437         LDKNodeFeatures ret_var = NodeFeatures_known();
38438         uintptr_t ret_ref = 0;
38439         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38440         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38442         ret_ref = (uintptr_t)ret_var.inner;
38443         if (ret_var.is_owned) {
38444                 ret_ref |= 1;
38445         }
38446         return ret_ref;
38447 }
38448
38449 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
38450         LDKNodeFeatures this_arg_conv;
38451         this_arg_conv.inner = (void*)(this_arg & (~1));
38452         this_arg_conv.is_owned = false;
38453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38454         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
38455         return ret_val;
38456 }
38457
38458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
38459         LDKChannelFeatures ret_var = ChannelFeatures_empty();
38460         uintptr_t ret_ref = 0;
38461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38464         ret_ref = (uintptr_t)ret_var.inner;
38465         if (ret_var.is_owned) {
38466                 ret_ref |= 1;
38467         }
38468         return ret_ref;
38469 }
38470
38471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
38472         LDKChannelFeatures ret_var = ChannelFeatures_known();
38473         uintptr_t ret_ref = 0;
38474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38477         ret_ref = (uintptr_t)ret_var.inner;
38478         if (ret_var.is_owned) {
38479                 ret_ref |= 1;
38480         }
38481         return ret_ref;
38482 }
38483
38484 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
38485         LDKChannelFeatures this_arg_conv;
38486         this_arg_conv.inner = (void*)(this_arg & (~1));
38487         this_arg_conv.is_owned = false;
38488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38489         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
38490         return ret_val;
38491 }
38492
38493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
38494         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
38495         uintptr_t ret_ref = 0;
38496         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38497         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38499         ret_ref = (uintptr_t)ret_var.inner;
38500         if (ret_var.is_owned) {
38501                 ret_ref |= 1;
38502         }
38503         return ret_ref;
38504 }
38505
38506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
38507         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
38508         uintptr_t ret_ref = 0;
38509         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38510         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38512         ret_ref = (uintptr_t)ret_var.inner;
38513         if (ret_var.is_owned) {
38514                 ret_ref |= 1;
38515         }
38516         return ret_ref;
38517 }
38518
38519 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
38520         LDKInvoiceFeatures this_arg_conv;
38521         this_arg_conv.inner = (void*)(this_arg & (~1));
38522         this_arg_conv.is_owned = false;
38523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38524         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
38525         return ret_val;
38526 }
38527
38528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
38529         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
38530         uintptr_t ret_ref = 0;
38531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38534         ret_ref = (uintptr_t)ret_var.inner;
38535         if (ret_var.is_owned) {
38536                 ret_ref |= 1;
38537         }
38538         return ret_ref;
38539 }
38540
38541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1known(JNIEnv *env, jclass clz) {
38542         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
38543         uintptr_t ret_ref = 0;
38544         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38545         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38547         ret_ref = (uintptr_t)ret_var.inner;
38548         if (ret_var.is_owned) {
38549                 ret_ref |= 1;
38550         }
38551         return ret_ref;
38552 }
38553
38554 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
38555         LDKChannelTypeFeatures this_arg_conv;
38556         this_arg_conv.inner = (void*)(this_arg & (~1));
38557         this_arg_conv.is_owned = false;
38558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38559         jboolean ret_val = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
38560         return ret_val;
38561 }
38562
38563 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
38564         LDKInitFeatures obj_conv;
38565         obj_conv.inner = (void*)(obj & (~1));
38566         obj_conv.is_owned = false;
38567         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38568         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
38569         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38570         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38571         CVec_u8Z_free(ret_var);
38572         return ret_arr;
38573 }
38574
38575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38576         LDKu8slice ser_ref;
38577         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38578         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38579         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
38580         *ret_conv = InitFeatures_read(ser_ref);
38581         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38582         return (uintptr_t)ret_conv;
38583 }
38584
38585 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
38586         LDKChannelFeatures obj_conv;
38587         obj_conv.inner = (void*)(obj & (~1));
38588         obj_conv.is_owned = false;
38589         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38590         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
38591         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38592         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38593         CVec_u8Z_free(ret_var);
38594         return ret_arr;
38595 }
38596
38597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38598         LDKu8slice ser_ref;
38599         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38600         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38601         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
38602         *ret_conv = ChannelFeatures_read(ser_ref);
38603         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38604         return (uintptr_t)ret_conv;
38605 }
38606
38607 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
38608         LDKNodeFeatures obj_conv;
38609         obj_conv.inner = (void*)(obj & (~1));
38610         obj_conv.is_owned = false;
38611         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38612         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
38613         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38614         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38615         CVec_u8Z_free(ret_var);
38616         return ret_arr;
38617 }
38618
38619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38620         LDKu8slice ser_ref;
38621         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38622         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38623         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
38624         *ret_conv = NodeFeatures_read(ser_ref);
38625         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38626         return (uintptr_t)ret_conv;
38627 }
38628
38629 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
38630         LDKInvoiceFeatures obj_conv;
38631         obj_conv.inner = (void*)(obj & (~1));
38632         obj_conv.is_owned = false;
38633         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38634         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
38635         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38636         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38637         CVec_u8Z_free(ret_var);
38638         return ret_arr;
38639 }
38640
38641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38642         LDKu8slice ser_ref;
38643         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38644         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38645         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
38646         *ret_conv = InvoiceFeatures_read(ser_ref);
38647         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38648         return (uintptr_t)ret_conv;
38649 }
38650
38651 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
38652         LDKChannelTypeFeatures obj_conv;
38653         obj_conv.inner = (void*)(obj & (~1));
38654         obj_conv.is_owned = false;
38655         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38656         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
38657         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38658         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38659         CVec_u8Z_free(ret_var);
38660         return ret_arr;
38661 }
38662
38663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38664         LDKu8slice ser_ref;
38665         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38666         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38667         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
38668         *ret_conv = ChannelTypeFeatures_read(ser_ref);
38669         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38670         return (uintptr_t)ret_conv;
38671 }
38672
38673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38674         LDKShutdownScript this_obj_conv;
38675         this_obj_conv.inner = (void*)(this_obj & (~1));
38676         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38678         ShutdownScript_free(this_obj_conv);
38679 }
38680
38681 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
38682         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
38683 uintptr_t ret_ref = 0;
38684 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38685 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38686 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38687 ret_ref = (uintptr_t)ret_var.inner;
38688 if (ret_var.is_owned) {
38689         ret_ref |= 1;
38690 }
38691         return ret_ref;
38692 }
38693 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38694         LDKShutdownScript arg_conv;
38695         arg_conv.inner = (void*)(arg & (~1));
38696         arg_conv.is_owned = false;
38697         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38698         intptr_t ret_val = ShutdownScript_clone_ptr(&arg_conv);
38699         return ret_val;
38700 }
38701
38702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38703         LDKShutdownScript orig_conv;
38704         orig_conv.inner = (void*)(orig & (~1));
38705         orig_conv.is_owned = false;
38706         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38707         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
38708         uintptr_t ret_ref = 0;
38709         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38710         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38712         ret_ref = (uintptr_t)ret_var.inner;
38713         if (ret_var.is_owned) {
38714                 ret_ref |= 1;
38715         }
38716         return ret_ref;
38717 }
38718
38719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38720         LDKInvalidShutdownScript this_obj_conv;
38721         this_obj_conv.inner = (void*)(this_obj & (~1));
38722         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38724         InvalidShutdownScript_free(this_obj_conv);
38725 }
38726
38727 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
38728         LDKInvalidShutdownScript this_ptr_conv;
38729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38730         this_ptr_conv.is_owned = false;
38731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38732         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
38733         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38734         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38735         return ret_arr;
38736 }
38737
38738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38739         LDKInvalidShutdownScript this_ptr_conv;
38740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38741         this_ptr_conv.is_owned = false;
38742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38743         LDKCVec_u8Z val_ref;
38744         val_ref.datalen = (*env)->GetArrayLength(env, val);
38745         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
38746         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
38747         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
38748 }
38749
38750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
38751         LDKCVec_u8Z script_arg_ref;
38752         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
38753         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
38754         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
38755         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
38756         uintptr_t ret_ref = 0;
38757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38760         ret_ref = (uintptr_t)ret_var.inner;
38761         if (ret_var.is_owned) {
38762                 ret_ref |= 1;
38763         }
38764         return ret_ref;
38765 }
38766
38767 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
38768         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
38769 uintptr_t ret_ref = 0;
38770 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38771 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38772 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38773 ret_ref = (uintptr_t)ret_var.inner;
38774 if (ret_var.is_owned) {
38775         ret_ref |= 1;
38776 }
38777         return ret_ref;
38778 }
38779 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38780         LDKInvalidShutdownScript arg_conv;
38781         arg_conv.inner = (void*)(arg & (~1));
38782         arg_conv.is_owned = false;
38783         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38784         intptr_t ret_val = InvalidShutdownScript_clone_ptr(&arg_conv);
38785         return ret_val;
38786 }
38787
38788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38789         LDKInvalidShutdownScript orig_conv;
38790         orig_conv.inner = (void*)(orig & (~1));
38791         orig_conv.is_owned = false;
38792         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38793         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
38794         uintptr_t ret_ref = 0;
38795         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38796         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38798         ret_ref = (uintptr_t)ret_var.inner;
38799         if (ret_var.is_owned) {
38800                 ret_ref |= 1;
38801         }
38802         return ret_ref;
38803 }
38804
38805 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
38806         LDKShutdownScript obj_conv;
38807         obj_conv.inner = (void*)(obj & (~1));
38808         obj_conv.is_owned = false;
38809         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38810         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
38811         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38812         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38813         CVec_u8Z_free(ret_var);
38814         return ret_arr;
38815 }
38816
38817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38818         LDKu8slice ser_ref;
38819         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38820         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38821         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
38822         *ret_conv = ShutdownScript_read(ser_ref);
38823         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38824         return (uintptr_t)ret_conv;
38825 }
38826
38827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
38828         unsigned char pubkey_hash_arr[20];
38829         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
38830         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
38831         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
38832         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
38833         uintptr_t ret_ref = 0;
38834         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38835         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38837         ret_ref = (uintptr_t)ret_var.inner;
38838         if (ret_var.is_owned) {
38839                 ret_ref |= 1;
38840         }
38841         return ret_ref;
38842 }
38843
38844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
38845         unsigned char script_hash_arr[32];
38846         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
38847         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
38848         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
38849         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
38850         uintptr_t ret_ref = 0;
38851         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38852         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38854         ret_ref = (uintptr_t)ret_var.inner;
38855         if (ret_var.is_owned) {
38856                 ret_ref |= 1;
38857         }
38858         return ret_ref;
38859 }
38860
38861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
38862         LDKu8slice program_ref;
38863         program_ref.datalen = (*env)->GetArrayLength(env, program);
38864         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
38865         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
38866         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
38867         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
38868         return (uintptr_t)ret_conv;
38869 }
38870
38871 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
38872         LDKShutdownScript this_arg_conv;
38873         this_arg_conv.inner = (void*)(this_arg & (~1));
38874         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
38875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38876         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
38877         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
38878         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38879         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38880         CVec_u8Z_free(ret_var);
38881         return ret_arr;
38882 }
38883
38884 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
38885         LDKShutdownScript this_arg_conv;
38886         this_arg_conv.inner = (void*)(this_arg & (~1));
38887         this_arg_conv.is_owned = false;
38888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38889         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38890         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
38891         return ret_arr;
38892 }
38893
38894 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
38895         LDKShutdownScript this_arg_conv;
38896         this_arg_conv.inner = (void*)(this_arg & (~1));
38897         this_arg_conv.is_owned = false;
38898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38899         LDKInitFeatures features_conv;
38900         features_conv.inner = (void*)(features & (~1));
38901         features_conv.is_owned = false;
38902         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
38903         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
38904         return ret_val;
38905 }
38906
38907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38908         if ((this_ptr & 1) != 0) return;
38909         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38910         CHECK_ACCESS(this_ptr_ptr);
38911         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
38912         FREE((void*)this_ptr);
38913         CustomMessageReader_free(this_ptr_conv);
38914 }
38915
38916 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
38917         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
38918         *ret_ret = Type_clone(arg);
38919         return (uintptr_t)ret_ret;
38920 }
38921 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38922         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
38923         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
38924         LDKType* arg_conv = (LDKType*)arg_ptr;
38925         intptr_t ret_val = Type_clone_ptr(arg_conv);
38926         return ret_val;
38927 }
38928
38929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38930         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
38931         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
38932         LDKType* orig_conv = (LDKType*)orig_ptr;
38933         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
38934         *ret_ret = Type_clone(orig_conv);
38935         return (uintptr_t)ret_ret;
38936 }
38937
38938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38939         if ((this_ptr & 1) != 0) return;
38940         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38941         CHECK_ACCESS(this_ptr_ptr);
38942         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
38943         FREE((void*)this_ptr);
38944         Type_free(this_ptr_conv);
38945 }
38946
38947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38948         LDKNodeId this_obj_conv;
38949         this_obj_conv.inner = (void*)(this_obj & (~1));
38950         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38952         NodeId_free(this_obj_conv);
38953 }
38954
38955 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
38956         LDKNodeId ret_var = NodeId_clone(arg);
38957 uintptr_t ret_ref = 0;
38958 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38959 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38960 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38961 ret_ref = (uintptr_t)ret_var.inner;
38962 if (ret_var.is_owned) {
38963         ret_ref |= 1;
38964 }
38965         return ret_ref;
38966 }
38967 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38968         LDKNodeId arg_conv;
38969         arg_conv.inner = (void*)(arg & (~1));
38970         arg_conv.is_owned = false;
38971         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38972         intptr_t ret_val = NodeId_clone_ptr(&arg_conv);
38973         return ret_val;
38974 }
38975
38976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38977         LDKNodeId orig_conv;
38978         orig_conv.inner = (void*)(orig & (~1));
38979         orig_conv.is_owned = false;
38980         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38981         LDKNodeId ret_var = NodeId_clone(&orig_conv);
38982         uintptr_t ret_ref = 0;
38983         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38984         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38986         ret_ref = (uintptr_t)ret_var.inner;
38987         if (ret_var.is_owned) {
38988                 ret_ref |= 1;
38989         }
38990         return ret_ref;
38991 }
38992
38993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
38994         LDKPublicKey pubkey_ref;
38995         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
38996         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
38997         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
38998         uintptr_t ret_ref = 0;
38999         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39000         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39001         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39002         ret_ref = (uintptr_t)ret_var.inner;
39003         if (ret_var.is_owned) {
39004                 ret_ref |= 1;
39005         }
39006         return ret_ref;
39007 }
39008
39009 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
39010         LDKNodeId this_arg_conv;
39011         this_arg_conv.inner = (void*)(this_arg & (~1));
39012         this_arg_conv.is_owned = false;
39013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39014         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
39015         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39016         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39017         return ret_arr;
39018 }
39019
39020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
39021         LDKNodeId o_conv;
39022         o_conv.inner = (void*)(o & (~1));
39023         o_conv.is_owned = false;
39024         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39025         int64_t ret_val = NodeId_hash(&o_conv);
39026         return ret_val;
39027 }
39028
39029 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
39030         LDKNodeId obj_conv;
39031         obj_conv.inner = (void*)(obj & (~1));
39032         obj_conv.is_owned = false;
39033         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39034         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
39035         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39036         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39037         CVec_u8Z_free(ret_var);
39038         return ret_arr;
39039 }
39040
39041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39042         LDKu8slice ser_ref;
39043         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39044         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39045         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
39046         *ret_conv = NodeId_read(ser_ref);
39047         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39048         return (uintptr_t)ret_conv;
39049 }
39050
39051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39052         LDKNetworkGraph this_obj_conv;
39053         this_obj_conv.inner = (void*)(this_obj & (~1));
39054         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39056         NetworkGraph_free(this_obj_conv);
39057 }
39058
39059 static inline uintptr_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
39060         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
39061 uintptr_t ret_ref = 0;
39062 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39063 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39064 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39065 ret_ref = (uintptr_t)ret_var.inner;
39066 if (ret_var.is_owned) {
39067         ret_ref |= 1;
39068 }
39069         return ret_ref;
39070 }
39071 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39072         LDKNetworkGraph arg_conv;
39073         arg_conv.inner = (void*)(arg & (~1));
39074         arg_conv.is_owned = false;
39075         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39076         intptr_t ret_val = NetworkGraph_clone_ptr(&arg_conv);
39077         return ret_val;
39078 }
39079
39080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39081         LDKNetworkGraph orig_conv;
39082         orig_conv.inner = (void*)(orig & (~1));
39083         orig_conv.is_owned = false;
39084         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39085         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
39086         uintptr_t ret_ref = 0;
39087         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39088         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39090         ret_ref = (uintptr_t)ret_var.inner;
39091         if (ret_var.is_owned) {
39092                 ret_ref |= 1;
39093         }
39094         return ret_ref;
39095 }
39096
39097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39098         LDKReadOnlyNetworkGraph this_obj_conv;
39099         this_obj_conv.inner = (void*)(this_obj & (~1));
39100         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39102         ReadOnlyNetworkGraph_free(this_obj_conv);
39103 }
39104
39105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39106         if ((this_ptr & 1) != 0) return;
39107         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39108         CHECK_ACCESS(this_ptr_ptr);
39109         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
39110         FREE((void*)this_ptr);
39111         NetworkUpdate_free(this_ptr_conv);
39112 }
39113
39114 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
39115         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39116         *ret_copy = NetworkUpdate_clone(arg);
39117 uintptr_t ret_ref = (uintptr_t)ret_copy;
39118         return ret_ref;
39119 }
39120 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39121         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
39122         intptr_t ret_val = NetworkUpdate_clone_ptr(arg_conv);
39123         return ret_val;
39124 }
39125
39126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39127         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
39128         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39129         *ret_copy = NetworkUpdate_clone(orig_conv);
39130         uintptr_t ret_ref = (uintptr_t)ret_copy;
39131         return ret_ref;
39132 }
39133
39134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
39135         LDKChannelUpdate msg_conv;
39136         msg_conv.inner = (void*)(msg & (~1));
39137         msg_conv.is_owned = (msg & 1) || (msg == 0);
39138         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39139         msg_conv = ChannelUpdate_clone(&msg_conv);
39140         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39141         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
39142         uintptr_t ret_ref = (uintptr_t)ret_copy;
39143         return ret_ref;
39144 }
39145
39146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
39147         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39148         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
39149         uintptr_t ret_ref = (uintptr_t)ret_copy;
39150         return ret_ref;
39151 }
39152
39153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
39154         LDKPublicKey node_id_ref;
39155         CHECK((*env)->GetArrayLength(env, node_id) == 33);
39156         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
39157         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39158         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
39159         uintptr_t ret_ref = (uintptr_t)ret_copy;
39160         return ret_ref;
39161 }
39162
39163 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
39164         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
39165         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
39166         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39167         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39168         CVec_u8Z_free(ret_var);
39169         return ret_arr;
39170 }
39171
39172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39173         LDKu8slice ser_ref;
39174         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39175         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39176         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
39177         *ret_conv = NetworkUpdate_read(ser_ref);
39178         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39179         return (uintptr_t)ret_conv;
39180 }
39181
39182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39183         LDKNetGraphMsgHandler this_arg_conv;
39184         this_arg_conv.inner = (void*)(this_arg & (~1));
39185         this_arg_conv.is_owned = false;
39186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39187         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
39188         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
39189         return (uintptr_t)ret_ret;
39190 }
39191
39192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39193         LDKNetGraphMsgHandler this_obj_conv;
39194         this_obj_conv.inner = (void*)(this_obj & (~1));
39195         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39197         NetGraphMsgHandler_free(this_obj_conv);
39198 }
39199
39200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t chain_access, int64_t logger) {
39201         LDKNetworkGraph network_graph_conv;
39202         network_graph_conv.inner = (void*)(network_graph & (~1));
39203         network_graph_conv.is_owned = false;
39204         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
39205         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39206         CHECK_ACCESS(chain_access_ptr);
39207         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39208         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39209         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39210                 // Manually implement clone for Java trait instances
39211                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39212                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39213                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39214                 }
39215         }
39216         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
39217         CHECK_ACCESS(logger_ptr);
39218         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
39219         if (logger_conv.free == LDKLogger_JCalls_free) {
39220                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39221                 LDKLogger_JCalls_cloned(&logger_conv);
39222         }
39223         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
39224         uintptr_t ret_ref = 0;
39225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39228         ret_ref = (uintptr_t)ret_var.inner;
39229         if (ret_var.is_owned) {
39230                 ret_ref |= 1;
39231         }
39232         return ret_ref;
39233 }
39234
39235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
39236         LDKNetGraphMsgHandler this_arg_conv;
39237         this_arg_conv.inner = (void*)(this_arg & (~1));
39238         this_arg_conv.is_owned = false;
39239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39240         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39241         CHECK_ACCESS(chain_access_ptr);
39242         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39243         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39244         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39245                 // Manually implement clone for Java trait instances
39246                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39247                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39248                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39249                 }
39250         }
39251         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
39252 }
39253
39254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39255         LDKNetGraphMsgHandler this_arg_conv;
39256         this_arg_conv.inner = (void*)(this_arg & (~1));
39257         this_arg_conv.is_owned = false;
39258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39259         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
39260         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
39261         return (uintptr_t)ret_ret;
39262 }
39263
39264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
39265         LDKNetGraphMsgHandler this_arg_conv;
39266         this_arg_conv.inner = (void*)(this_arg & (~1));
39267         this_arg_conv.is_owned = false;
39268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39269         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
39270         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
39271         return (uintptr_t)ret_ret;
39272 }
39273
39274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39275         LDKChannelUpdateInfo this_obj_conv;
39276         this_obj_conv.inner = (void*)(this_obj & (~1));
39277         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39279         ChannelUpdateInfo_free(this_obj_conv);
39280 }
39281
39282 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
39283         LDKChannelUpdateInfo this_ptr_conv;
39284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39285         this_ptr_conv.is_owned = false;
39286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39287         int32_t ret_val = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
39288         return ret_val;
39289 }
39290
39291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39292         LDKChannelUpdateInfo this_ptr_conv;
39293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39294         this_ptr_conv.is_owned = false;
39295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39296         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
39297 }
39298
39299 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
39300         LDKChannelUpdateInfo this_ptr_conv;
39301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39302         this_ptr_conv.is_owned = false;
39303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39304         jboolean ret_val = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
39305         return ret_val;
39306 }
39307
39308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39309         LDKChannelUpdateInfo this_ptr_conv;
39310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39311         this_ptr_conv.is_owned = false;
39312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39313         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
39314 }
39315
39316 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
39317         LDKChannelUpdateInfo this_ptr_conv;
39318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39319         this_ptr_conv.is_owned = false;
39320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39321         int16_t ret_val = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
39322         return ret_val;
39323 }
39324
39325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
39326         LDKChannelUpdateInfo this_ptr_conv;
39327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39328         this_ptr_conv.is_owned = false;
39329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39330         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
39331 }
39332
39333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39334         LDKChannelUpdateInfo this_ptr_conv;
39335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39336         this_ptr_conv.is_owned = false;
39337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39338         int64_t ret_val = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
39339         return ret_val;
39340 }
39341
39342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39343         LDKChannelUpdateInfo this_ptr_conv;
39344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39345         this_ptr_conv.is_owned = false;
39346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39347         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
39348 }
39349
39350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39351         LDKChannelUpdateInfo 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_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
39356         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
39357         uintptr_t ret_ref = (uintptr_t)ret_copy;
39358         return ret_ref;
39359 }
39360
39361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39362         LDKChannelUpdateInfo 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_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
39369         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
39370         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
39371 }
39372
39373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
39374         LDKChannelUpdateInfo this_ptr_conv;
39375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39376         this_ptr_conv.is_owned = false;
39377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39378         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
39379         uintptr_t ret_ref = 0;
39380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39383         ret_ref = (uintptr_t)ret_var.inner;
39384         if (ret_var.is_owned) {
39385                 ret_ref |= 1;
39386         }
39387         return ret_ref;
39388 }
39389
39390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39391         LDKChannelUpdateInfo this_ptr_conv;
39392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39393         this_ptr_conv.is_owned = false;
39394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39395         LDKRoutingFees val_conv;
39396         val_conv.inner = (void*)(val & (~1));
39397         val_conv.is_owned = (val & 1) || (val == 0);
39398         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39399         val_conv = RoutingFees_clone(&val_conv);
39400         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
39401 }
39402
39403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
39404         LDKChannelUpdateInfo this_ptr_conv;
39405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39406         this_ptr_conv.is_owned = false;
39407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39408         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
39409         uintptr_t ret_ref = 0;
39410         if ((uintptr_t)ret_var.inner > 4096) {
39411                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39412                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39414                 ret_ref = (uintptr_t)ret_var.inner;
39415                 if (ret_var.is_owned) {
39416                         ret_ref |= 1;
39417                 }
39418         }
39419         return ret_ref;
39420 }
39421
39422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39423         LDKChannelUpdateInfo this_ptr_conv;
39424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39425         this_ptr_conv.is_owned = false;
39426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39427         LDKChannelUpdate val_conv;
39428         val_conv.inner = (void*)(val & (~1));
39429         val_conv.is_owned = (val & 1) || (val == 0);
39430         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39431         val_conv = ChannelUpdate_clone(&val_conv);
39432         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
39433 }
39434
39435 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) {
39436         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
39437         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
39438         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
39439         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
39440         LDKRoutingFees fees_arg_conv;
39441         fees_arg_conv.inner = (void*)(fees_arg & (~1));
39442         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
39443         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
39444         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
39445         LDKChannelUpdate last_update_message_arg_conv;
39446         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
39447         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
39448         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
39449         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
39450         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg_conv, fees_arg_conv, last_update_message_arg_conv);
39451         uintptr_t ret_ref = 0;
39452         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39453         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39455         ret_ref = (uintptr_t)ret_var.inner;
39456         if (ret_var.is_owned) {
39457                 ret_ref |= 1;
39458         }
39459         return ret_ref;
39460 }
39461
39462 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
39463         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
39464 uintptr_t ret_ref = 0;
39465 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39466 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39467 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39468 ret_ref = (uintptr_t)ret_var.inner;
39469 if (ret_var.is_owned) {
39470         ret_ref |= 1;
39471 }
39472         return ret_ref;
39473 }
39474 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39475         LDKChannelUpdateInfo arg_conv;
39476         arg_conv.inner = (void*)(arg & (~1));
39477         arg_conv.is_owned = false;
39478         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39479         intptr_t ret_val = ChannelUpdateInfo_clone_ptr(&arg_conv);
39480         return ret_val;
39481 }
39482
39483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39484         LDKChannelUpdateInfo orig_conv;
39485         orig_conv.inner = (void*)(orig & (~1));
39486         orig_conv.is_owned = false;
39487         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39488         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
39489         uintptr_t ret_ref = 0;
39490         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39491         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39493         ret_ref = (uintptr_t)ret_var.inner;
39494         if (ret_var.is_owned) {
39495                 ret_ref |= 1;
39496         }
39497         return ret_ref;
39498 }
39499
39500 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
39501         LDKChannelUpdateInfo obj_conv;
39502         obj_conv.inner = (void*)(obj & (~1));
39503         obj_conv.is_owned = false;
39504         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39505         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
39506         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39507         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39508         CVec_u8Z_free(ret_var);
39509         return ret_arr;
39510 }
39511
39512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39513         LDKu8slice ser_ref;
39514         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39515         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39516         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
39517         *ret_conv = ChannelUpdateInfo_read(ser_ref);
39518         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39519         return (uintptr_t)ret_conv;
39520 }
39521
39522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39523         LDKChannelInfo this_obj_conv;
39524         this_obj_conv.inner = (void*)(this_obj & (~1));
39525         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39527         ChannelInfo_free(this_obj_conv);
39528 }
39529
39530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
39531         LDKChannelInfo this_ptr_conv;
39532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39533         this_ptr_conv.is_owned = false;
39534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39535         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
39536         uintptr_t ret_ref = 0;
39537         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39538         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39540         ret_ref = (uintptr_t)ret_var.inner;
39541         if (ret_var.is_owned) {
39542                 ret_ref |= 1;
39543         }
39544         return ret_ref;
39545 }
39546
39547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39548         LDKChannelInfo this_ptr_conv;
39549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39550         this_ptr_conv.is_owned = false;
39551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39552         LDKChannelFeatures val_conv;
39553         val_conv.inner = (void*)(val & (~1));
39554         val_conv.is_owned = (val & 1) || (val == 0);
39555         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39556         val_conv = ChannelFeatures_clone(&val_conv);
39557         ChannelInfo_set_features(&this_ptr_conv, val_conv);
39558 }
39559
39560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
39561         LDKChannelInfo this_ptr_conv;
39562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39563         this_ptr_conv.is_owned = false;
39564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39565         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
39566         uintptr_t ret_ref = 0;
39567         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39568         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39570         ret_ref = (uintptr_t)ret_var.inner;
39571         if (ret_var.is_owned) {
39572                 ret_ref |= 1;
39573         }
39574         return ret_ref;
39575 }
39576
39577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39578         LDKChannelInfo this_ptr_conv;
39579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39580         this_ptr_conv.is_owned = false;
39581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39582         LDKNodeId val_conv;
39583         val_conv.inner = (void*)(val & (~1));
39584         val_conv.is_owned = (val & 1) || (val == 0);
39585         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39586         val_conv = NodeId_clone(&val_conv);
39587         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
39588 }
39589
39590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
39591         LDKChannelInfo this_ptr_conv;
39592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39593         this_ptr_conv.is_owned = false;
39594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39595         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
39596         uintptr_t ret_ref = 0;
39597         if ((uintptr_t)ret_var.inner > 4096) {
39598                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39599                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39601                 ret_ref = (uintptr_t)ret_var.inner;
39602                 if (ret_var.is_owned) {
39603                         ret_ref |= 1;
39604                 }
39605         }
39606         return ret_ref;
39607 }
39608
39609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39610         LDKChannelInfo this_ptr_conv;
39611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39612         this_ptr_conv.is_owned = false;
39613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39614         LDKChannelUpdateInfo val_conv;
39615         val_conv.inner = (void*)(val & (~1));
39616         val_conv.is_owned = (val & 1) || (val == 0);
39617         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39618         val_conv = ChannelUpdateInfo_clone(&val_conv);
39619         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
39620 }
39621
39622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
39623         LDKChannelInfo this_ptr_conv;
39624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39625         this_ptr_conv.is_owned = false;
39626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39627         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
39628         uintptr_t ret_ref = 0;
39629         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39630         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39632         ret_ref = (uintptr_t)ret_var.inner;
39633         if (ret_var.is_owned) {
39634                 ret_ref |= 1;
39635         }
39636         return ret_ref;
39637 }
39638
39639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39640         LDKChannelInfo 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         LDKNodeId 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 = NodeId_clone(&val_conv);
39649         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
39650 }
39651
39652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
39653         LDKChannelInfo 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         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
39658         uintptr_t ret_ref = 0;
39659         if ((uintptr_t)ret_var.inner > 4096) {
39660                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39661                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39663                 ret_ref = (uintptr_t)ret_var.inner;
39664                 if (ret_var.is_owned) {
39665                         ret_ref |= 1;
39666                 }
39667         }
39668         return ret_ref;
39669 }
39670
39671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39672         LDKChannelInfo this_ptr_conv;
39673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39674         this_ptr_conv.is_owned = false;
39675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39676         LDKChannelUpdateInfo val_conv;
39677         val_conv.inner = (void*)(val & (~1));
39678         val_conv.is_owned = (val & 1) || (val == 0);
39679         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39680         val_conv = ChannelUpdateInfo_clone(&val_conv);
39681         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
39682 }
39683
39684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
39685         LDKChannelInfo this_ptr_conv;
39686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39687         this_ptr_conv.is_owned = false;
39688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39689         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
39690         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
39691         uintptr_t ret_ref = (uintptr_t)ret_copy;
39692         return ret_ref;
39693 }
39694
39695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39696         LDKChannelInfo this_ptr_conv;
39697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39698         this_ptr_conv.is_owned = false;
39699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39700         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
39701         CHECK_ACCESS(val_ptr);
39702         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
39703         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
39704         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
39705 }
39706
39707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
39708         LDKChannelInfo this_ptr_conv;
39709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39710         this_ptr_conv.is_owned = false;
39711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39712         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
39713         uintptr_t ret_ref = 0;
39714         if ((uintptr_t)ret_var.inner > 4096) {
39715                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39716                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39718                 ret_ref = (uintptr_t)ret_var.inner;
39719                 if (ret_var.is_owned) {
39720                         ret_ref |= 1;
39721                 }
39722         }
39723         return ret_ref;
39724 }
39725
39726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39727         LDKChannelInfo this_ptr_conv;
39728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39729         this_ptr_conv.is_owned = false;
39730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39731         LDKChannelAnnouncement val_conv;
39732         val_conv.inner = (void*)(val & (~1));
39733         val_conv.is_owned = (val & 1) || (val == 0);
39734         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39735         val_conv = ChannelAnnouncement_clone(&val_conv);
39736         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
39737 }
39738
39739 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
39740         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
39741 uintptr_t ret_ref = 0;
39742 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39743 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39744 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39745 ret_ref = (uintptr_t)ret_var.inner;
39746 if (ret_var.is_owned) {
39747         ret_ref |= 1;
39748 }
39749         return ret_ref;
39750 }
39751 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39752         LDKChannelInfo arg_conv;
39753         arg_conv.inner = (void*)(arg & (~1));
39754         arg_conv.is_owned = false;
39755         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39756         intptr_t ret_val = ChannelInfo_clone_ptr(&arg_conv);
39757         return ret_val;
39758 }
39759
39760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39761         LDKChannelInfo orig_conv;
39762         orig_conv.inner = (void*)(orig & (~1));
39763         orig_conv.is_owned = false;
39764         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39765         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
39766         uintptr_t ret_ref = 0;
39767         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39768         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39770         ret_ref = (uintptr_t)ret_var.inner;
39771         if (ret_var.is_owned) {
39772                 ret_ref |= 1;
39773         }
39774         return ret_ref;
39775 }
39776
39777 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
39778         LDKChannelInfo obj_conv;
39779         obj_conv.inner = (void*)(obj & (~1));
39780         obj_conv.is_owned = false;
39781         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39782         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
39783         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39784         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39785         CVec_u8Z_free(ret_var);
39786         return ret_arr;
39787 }
39788
39789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39790         LDKu8slice ser_ref;
39791         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39792         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39793         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
39794         *ret_conv = ChannelInfo_read(ser_ref);
39795         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39796         return (uintptr_t)ret_conv;
39797 }
39798
39799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39800         LDKDirectedChannelInfo this_obj_conv;
39801         this_obj_conv.inner = (void*)(this_obj & (~1));
39802         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39804         DirectedChannelInfo_free(this_obj_conv);
39805 }
39806
39807 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
39808         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
39809 uintptr_t ret_ref = 0;
39810 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39811 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39812 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39813 ret_ref = (uintptr_t)ret_var.inner;
39814 if (ret_var.is_owned) {
39815         ret_ref |= 1;
39816 }
39817         return ret_ref;
39818 }
39819 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39820         LDKDirectedChannelInfo arg_conv;
39821         arg_conv.inner = (void*)(arg & (~1));
39822         arg_conv.is_owned = false;
39823         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39824         intptr_t ret_val = DirectedChannelInfo_clone_ptr(&arg_conv);
39825         return ret_val;
39826 }
39827
39828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39829         LDKDirectedChannelInfo orig_conv;
39830         orig_conv.inner = (void*)(orig & (~1));
39831         orig_conv.is_owned = false;
39832         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39833         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
39834         uintptr_t ret_ref = 0;
39835         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39836         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39838         ret_ref = (uintptr_t)ret_var.inner;
39839         if (ret_var.is_owned) {
39840                 ret_ref |= 1;
39841         }
39842         return ret_ref;
39843 }
39844
39845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
39846         LDKDirectedChannelInfo this_arg_conv;
39847         this_arg_conv.inner = (void*)(this_arg & (~1));
39848         this_arg_conv.is_owned = false;
39849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39850         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
39851         uintptr_t ret_ref = 0;
39852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39855         ret_ref = (uintptr_t)ret_var.inner;
39856         if (ret_var.is_owned) {
39857                 ret_ref |= 1;
39858         }
39859         return ret_ref;
39860 }
39861
39862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1direction(JNIEnv *env, jclass clz, int64_t this_arg) {
39863         LDKDirectedChannelInfo this_arg_conv;
39864         this_arg_conv.inner = (void*)(this_arg & (~1));
39865         this_arg_conv.is_owned = false;
39866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39867         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
39868         uintptr_t ret_ref = 0;
39869         if ((uintptr_t)ret_var.inner > 4096) {
39870                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39871                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39873                 ret_ref = (uintptr_t)ret_var.inner;
39874                 if (ret_var.is_owned) {
39875                         ret_ref |= 1;
39876                 }
39877         }
39878         return ret_ref;
39879 }
39880
39881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
39882         LDKDirectedChannelInfo this_arg_conv;
39883         this_arg_conv.inner = (void*)(this_arg & (~1));
39884         this_arg_conv.is_owned = false;
39885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39886         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39887         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
39888         uintptr_t ret_ref = (uintptr_t)ret_copy;
39889         return ret_ref;
39890 }
39891
39892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39893         if ((this_ptr & 1) != 0) return;
39894         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39895         CHECK_ACCESS(this_ptr_ptr);
39896         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
39897         FREE((void*)this_ptr);
39898         EffectiveCapacity_free(this_ptr_conv);
39899 }
39900
39901 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
39902         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39903         *ret_copy = EffectiveCapacity_clone(arg);
39904 uintptr_t ret_ref = (uintptr_t)ret_copy;
39905         return ret_ref;
39906 }
39907 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39908         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
39909         intptr_t ret_val = EffectiveCapacity_clone_ptr(arg_conv);
39910         return ret_val;
39911 }
39912
39913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39914         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
39915         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39916         *ret_copy = EffectiveCapacity_clone(orig_conv);
39917         uintptr_t ret_ref = (uintptr_t)ret_copy;
39918         return ret_ref;
39919 }
39920
39921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
39922         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39923         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
39924         uintptr_t ret_ref = (uintptr_t)ret_copy;
39925         return ret_ref;
39926 }
39927
39928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
39929         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39930         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
39931         uintptr_t ret_ref = (uintptr_t)ret_copy;
39932         return ret_ref;
39933 }
39934
39935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat) {
39936         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39937         *ret_copy = EffectiveCapacity_total(capacity_msat);
39938         uintptr_t ret_ref = (uintptr_t)ret_copy;
39939         return ret_ref;
39940 }
39941
39942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
39943         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39944         *ret_copy = EffectiveCapacity_infinite();
39945         uintptr_t ret_ref = (uintptr_t)ret_copy;
39946         return ret_ref;
39947 }
39948
39949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
39950         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39951         *ret_copy = EffectiveCapacity_unknown();
39952         uintptr_t ret_ref = (uintptr_t)ret_copy;
39953         return ret_ref;
39954 }
39955
39956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
39957         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
39958         int64_t ret_val = EffectiveCapacity_as_msat(this_arg_conv);
39959         return ret_val;
39960 }
39961
39962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39963         LDKRoutingFees this_obj_conv;
39964         this_obj_conv.inner = (void*)(this_obj & (~1));
39965         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39967         RoutingFees_free(this_obj_conv);
39968 }
39969
39970 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39971         LDKRoutingFees this_ptr_conv;
39972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39973         this_ptr_conv.is_owned = false;
39974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39975         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
39976         return ret_val;
39977 }
39978
39979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39980         LDKRoutingFees this_ptr_conv;
39981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39982         this_ptr_conv.is_owned = false;
39983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39984         RoutingFees_set_base_msat(&this_ptr_conv, val);
39985 }
39986
39987 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
39988         LDKRoutingFees this_ptr_conv;
39989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39990         this_ptr_conv.is_owned = false;
39991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39992         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
39993         return ret_val;
39994 }
39995
39996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39997         LDKRoutingFees this_ptr_conv;
39998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39999         this_ptr_conv.is_owned = false;
40000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40001         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
40002 }
40003
40004 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) {
40005         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
40006         uintptr_t ret_ref = 0;
40007         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40008         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40010         ret_ref = (uintptr_t)ret_var.inner;
40011         if (ret_var.is_owned) {
40012                 ret_ref |= 1;
40013         }
40014         return ret_ref;
40015 }
40016
40017 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40018         LDKRoutingFees a_conv;
40019         a_conv.inner = (void*)(a & (~1));
40020         a_conv.is_owned = false;
40021         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40022         LDKRoutingFees b_conv;
40023         b_conv.inner = (void*)(b & (~1));
40024         b_conv.is_owned = false;
40025         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40026         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
40027         return ret_val;
40028 }
40029
40030 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
40031         LDKRoutingFees ret_var = RoutingFees_clone(arg);
40032 uintptr_t ret_ref = 0;
40033 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40034 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40035 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40036 ret_ref = (uintptr_t)ret_var.inner;
40037 if (ret_var.is_owned) {
40038         ret_ref |= 1;
40039 }
40040         return ret_ref;
40041 }
40042 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40043         LDKRoutingFees arg_conv;
40044         arg_conv.inner = (void*)(arg & (~1));
40045         arg_conv.is_owned = false;
40046         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40047         intptr_t ret_val = RoutingFees_clone_ptr(&arg_conv);
40048         return ret_val;
40049 }
40050
40051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40052         LDKRoutingFees orig_conv;
40053         orig_conv.inner = (void*)(orig & (~1));
40054         orig_conv.is_owned = false;
40055         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40056         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
40057         uintptr_t ret_ref = 0;
40058         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40059         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40060         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40061         ret_ref = (uintptr_t)ret_var.inner;
40062         if (ret_var.is_owned) {
40063                 ret_ref |= 1;
40064         }
40065         return ret_ref;
40066 }
40067
40068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
40069         LDKRoutingFees o_conv;
40070         o_conv.inner = (void*)(o & (~1));
40071         o_conv.is_owned = false;
40072         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40073         int64_t ret_val = RoutingFees_hash(&o_conv);
40074         return ret_val;
40075 }
40076
40077 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
40078         LDKRoutingFees obj_conv;
40079         obj_conv.inner = (void*)(obj & (~1));
40080         obj_conv.is_owned = false;
40081         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40082         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
40083         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40084         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40085         CVec_u8Z_free(ret_var);
40086         return ret_arr;
40087 }
40088
40089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40090         LDKu8slice ser_ref;
40091         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40092         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40093         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
40094         *ret_conv = RoutingFees_read(ser_ref);
40095         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40096         return (uintptr_t)ret_conv;
40097 }
40098
40099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40100         LDKNodeAnnouncementInfo this_obj_conv;
40101         this_obj_conv.inner = (void*)(this_obj & (~1));
40102         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40104         NodeAnnouncementInfo_free(this_obj_conv);
40105 }
40106
40107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
40108         LDKNodeAnnouncementInfo this_ptr_conv;
40109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40110         this_ptr_conv.is_owned = false;
40111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40112         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
40113         uintptr_t ret_ref = 0;
40114         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40115         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40117         ret_ref = (uintptr_t)ret_var.inner;
40118         if (ret_var.is_owned) {
40119                 ret_ref |= 1;
40120         }
40121         return ret_ref;
40122 }
40123
40124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40125         LDKNodeAnnouncementInfo this_ptr_conv;
40126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40127         this_ptr_conv.is_owned = false;
40128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40129         LDKNodeFeatures val_conv;
40130         val_conv.inner = (void*)(val & (~1));
40131         val_conv.is_owned = (val & 1) || (val == 0);
40132         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40133         val_conv = NodeFeatures_clone(&val_conv);
40134         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
40135 }
40136
40137 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
40138         LDKNodeAnnouncementInfo this_ptr_conv;
40139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40140         this_ptr_conv.is_owned = false;
40141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40142         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
40143         return ret_val;
40144 }
40145
40146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40147         LDKNodeAnnouncementInfo this_ptr_conv;
40148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40149         this_ptr_conv.is_owned = false;
40150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40151         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
40152 }
40153
40154 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
40155         LDKNodeAnnouncementInfo this_ptr_conv;
40156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40157         this_ptr_conv.is_owned = false;
40158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40159         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
40160         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
40161         return ret_arr;
40162 }
40163
40164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40165         LDKNodeAnnouncementInfo this_ptr_conv;
40166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40167         this_ptr_conv.is_owned = false;
40168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40169         LDKThreeBytes val_ref;
40170         CHECK((*env)->GetArrayLength(env, val) == 3);
40171         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
40172         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
40173 }
40174
40175 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
40176         LDKNodeAnnouncementInfo this_ptr_conv;
40177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40178         this_ptr_conv.is_owned = false;
40179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40180         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40181         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
40182         return ret_arr;
40183 }
40184
40185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40186         LDKNodeAnnouncementInfo this_ptr_conv;
40187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40188         this_ptr_conv.is_owned = false;
40189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40190         LDKThirtyTwoBytes val_ref;
40191         CHECK((*env)->GetArrayLength(env, val) == 32);
40192         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
40193         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
40194 }
40195
40196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40197         LDKNodeAnnouncementInfo this_ptr_conv;
40198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40199         this_ptr_conv.is_owned = false;
40200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40201         LDKCVec_NetAddressZ val_constr;
40202         val_constr.datalen = (*env)->GetArrayLength(env, val);
40203         if (val_constr.datalen > 0)
40204                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40205         else
40206                 val_constr.data = NULL;
40207         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40208         for (size_t m = 0; m < val_constr.datalen; m++) {
40209                 int64_t val_conv_12 = val_vals[m];
40210                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
40211                 CHECK_ACCESS(val_conv_12_ptr);
40212                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
40213                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
40214                 val_constr.data[m] = val_conv_12_conv;
40215         }
40216         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40217         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
40218 }
40219
40220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
40221         LDKNodeAnnouncementInfo this_ptr_conv;
40222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40223         this_ptr_conv.is_owned = false;
40224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40225         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
40226         uintptr_t ret_ref = 0;
40227         if ((uintptr_t)ret_var.inner > 4096) {
40228                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40229                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40231                 ret_ref = (uintptr_t)ret_var.inner;
40232                 if (ret_var.is_owned) {
40233                         ret_ref |= 1;
40234                 }
40235         }
40236         return ret_ref;
40237 }
40238
40239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40240         LDKNodeAnnouncementInfo this_ptr_conv;
40241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40242         this_ptr_conv.is_owned = false;
40243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40244         LDKNodeAnnouncement val_conv;
40245         val_conv.inner = (void*)(val & (~1));
40246         val_conv.is_owned = (val & 1) || (val == 0);
40247         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40248         val_conv = NodeAnnouncement_clone(&val_conv);
40249         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
40250 }
40251
40252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int8_tArray alias_arg, int64_tArray addresses_arg, int64_t announcement_message_arg) {
40253         LDKNodeFeatures features_arg_conv;
40254         features_arg_conv.inner = (void*)(features_arg & (~1));
40255         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
40256         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
40257         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
40258         LDKThreeBytes rgb_arg_ref;
40259         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
40260         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
40261         LDKThirtyTwoBytes alias_arg_ref;
40262         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
40263         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
40264         LDKCVec_NetAddressZ addresses_arg_constr;
40265         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
40266         if (addresses_arg_constr.datalen > 0)
40267                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40268         else
40269                 addresses_arg_constr.data = NULL;
40270         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
40271         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
40272                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
40273                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
40274                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
40275                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
40276                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
40277         }
40278         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
40279         LDKNodeAnnouncement announcement_message_arg_conv;
40280         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
40281         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
40282         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
40283         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
40284         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
40285         uintptr_t ret_ref = 0;
40286         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40287         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40289         ret_ref = (uintptr_t)ret_var.inner;
40290         if (ret_var.is_owned) {
40291                 ret_ref |= 1;
40292         }
40293         return ret_ref;
40294 }
40295
40296 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
40297         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
40298 uintptr_t ret_ref = 0;
40299 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40300 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40301 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40302 ret_ref = (uintptr_t)ret_var.inner;
40303 if (ret_var.is_owned) {
40304         ret_ref |= 1;
40305 }
40306         return ret_ref;
40307 }
40308 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40309         LDKNodeAnnouncementInfo arg_conv;
40310         arg_conv.inner = (void*)(arg & (~1));
40311         arg_conv.is_owned = false;
40312         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40313         intptr_t ret_val = NodeAnnouncementInfo_clone_ptr(&arg_conv);
40314         return ret_val;
40315 }
40316
40317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40318         LDKNodeAnnouncementInfo orig_conv;
40319         orig_conv.inner = (void*)(orig & (~1));
40320         orig_conv.is_owned = false;
40321         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40322         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
40323         uintptr_t ret_ref = 0;
40324         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40325         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40327         ret_ref = (uintptr_t)ret_var.inner;
40328         if (ret_var.is_owned) {
40329                 ret_ref |= 1;
40330         }
40331         return ret_ref;
40332 }
40333
40334 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
40335         LDKNodeAnnouncementInfo obj_conv;
40336         obj_conv.inner = (void*)(obj & (~1));
40337         obj_conv.is_owned = false;
40338         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40339         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
40340         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40341         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40342         CVec_u8Z_free(ret_var);
40343         return ret_arr;
40344 }
40345
40346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40347         LDKu8slice ser_ref;
40348         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40349         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40350         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
40351         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
40352         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40353         return (uintptr_t)ret_conv;
40354 }
40355
40356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40357         LDKNodeInfo this_obj_conv;
40358         this_obj_conv.inner = (void*)(this_obj & (~1));
40359         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40361         NodeInfo_free(this_obj_conv);
40362 }
40363
40364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40365         LDKNodeInfo this_ptr_conv;
40366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40367         this_ptr_conv.is_owned = false;
40368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40369         LDKCVec_u64Z val_constr;
40370         val_constr.datalen = (*env)->GetArrayLength(env, val);
40371         if (val_constr.datalen > 0)
40372                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
40373         else
40374                 val_constr.data = NULL;
40375         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40376         for (size_t g = 0; g < val_constr.datalen; g++) {
40377                 int64_t val_conv_6 = val_vals[g];
40378                 val_constr.data[g] = val_conv_6;
40379         }
40380         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40381         NodeInfo_set_channels(&this_ptr_conv, val_constr);
40382 }
40383
40384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
40385         LDKNodeInfo this_ptr_conv;
40386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40387         this_ptr_conv.is_owned = false;
40388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40389         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
40390         uintptr_t ret_ref = 0;
40391         if ((uintptr_t)ret_var.inner > 4096) {
40392                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40393                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40395                 ret_ref = (uintptr_t)ret_var.inner;
40396                 if (ret_var.is_owned) {
40397                         ret_ref |= 1;
40398                 }
40399         }
40400         return ret_ref;
40401 }
40402
40403 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) {
40404         LDKNodeInfo this_ptr_conv;
40405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40406         this_ptr_conv.is_owned = false;
40407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40408         LDKRoutingFees val_conv;
40409         val_conv.inner = (void*)(val & (~1));
40410         val_conv.is_owned = (val & 1) || (val == 0);
40411         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40412         val_conv = RoutingFees_clone(&val_conv);
40413         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
40414 }
40415
40416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
40417         LDKNodeInfo this_ptr_conv;
40418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40419         this_ptr_conv.is_owned = false;
40420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40421         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
40422         uintptr_t ret_ref = 0;
40423         if ((uintptr_t)ret_var.inner > 4096) {
40424                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40425                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40427                 ret_ref = (uintptr_t)ret_var.inner;
40428                 if (ret_var.is_owned) {
40429                         ret_ref |= 1;
40430                 }
40431         }
40432         return ret_ref;
40433 }
40434
40435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40436         LDKNodeInfo this_ptr_conv;
40437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40438         this_ptr_conv.is_owned = false;
40439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40440         LDKNodeAnnouncementInfo val_conv;
40441         val_conv.inner = (void*)(val & (~1));
40442         val_conv.is_owned = (val & 1) || (val == 0);
40443         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40444         val_conv = NodeAnnouncementInfo_clone(&val_conv);
40445         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
40446 }
40447
40448 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) {
40449         LDKCVec_u64Z channels_arg_constr;
40450         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
40451         if (channels_arg_constr.datalen > 0)
40452                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
40453         else
40454                 channels_arg_constr.data = NULL;
40455         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
40456         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
40457                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
40458                 channels_arg_constr.data[g] = channels_arg_conv_6;
40459         }
40460         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
40461         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
40462         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
40463         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
40464         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
40465         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
40466         LDKNodeAnnouncementInfo announcement_info_arg_conv;
40467         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
40468         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
40469         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
40470         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
40471         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
40472         uintptr_t ret_ref = 0;
40473         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40474         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40476         ret_ref = (uintptr_t)ret_var.inner;
40477         if (ret_var.is_owned) {
40478                 ret_ref |= 1;
40479         }
40480         return ret_ref;
40481 }
40482
40483 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
40484         LDKNodeInfo ret_var = NodeInfo_clone(arg);
40485 uintptr_t ret_ref = 0;
40486 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40487 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40488 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40489 ret_ref = (uintptr_t)ret_var.inner;
40490 if (ret_var.is_owned) {
40491         ret_ref |= 1;
40492 }
40493         return ret_ref;
40494 }
40495 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40496         LDKNodeInfo arg_conv;
40497         arg_conv.inner = (void*)(arg & (~1));
40498         arg_conv.is_owned = false;
40499         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40500         intptr_t ret_val = NodeInfo_clone_ptr(&arg_conv);
40501         return ret_val;
40502 }
40503
40504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40505         LDKNodeInfo orig_conv;
40506         orig_conv.inner = (void*)(orig & (~1));
40507         orig_conv.is_owned = false;
40508         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40509         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
40510         uintptr_t ret_ref = 0;
40511         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40512         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40514         ret_ref = (uintptr_t)ret_var.inner;
40515         if (ret_var.is_owned) {
40516                 ret_ref |= 1;
40517         }
40518         return ret_ref;
40519 }
40520
40521 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
40522         LDKNodeInfo obj_conv;
40523         obj_conv.inner = (void*)(obj & (~1));
40524         obj_conv.is_owned = false;
40525         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40526         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
40527         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40528         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40529         CVec_u8Z_free(ret_var);
40530         return ret_arr;
40531 }
40532
40533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40534         LDKu8slice ser_ref;
40535         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40536         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40537         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
40538         *ret_conv = NodeInfo_read(ser_ref);
40539         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40540         return (uintptr_t)ret_conv;
40541 }
40542
40543 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
40544         LDKNetworkGraph obj_conv;
40545         obj_conv.inner = (void*)(obj & (~1));
40546         obj_conv.is_owned = false;
40547         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40548         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
40549         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40550         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40551         CVec_u8Z_free(ret_var);
40552         return ret_arr;
40553 }
40554
40555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40556         LDKu8slice ser_ref;
40557         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40558         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40559         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
40560         *ret_conv = NetworkGraph_read(ser_ref);
40561         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40562         return (uintptr_t)ret_conv;
40563 }
40564
40565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
40566         LDKThirtyTwoBytes genesis_hash_ref;
40567         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
40568         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
40569         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
40570         uintptr_t ret_ref = 0;
40571         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40572         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40573         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40574         ret_ref = (uintptr_t)ret_var.inner;
40575         if (ret_var.is_owned) {
40576                 ret_ref |= 1;
40577         }
40578         return ret_ref;
40579 }
40580
40581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
40582         LDKNetworkGraph this_arg_conv;
40583         this_arg_conv.inner = (void*)(this_arg & (~1));
40584         this_arg_conv.is_owned = false;
40585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40586         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
40587         uintptr_t ret_ref = 0;
40588         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40589         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40591         ret_ref = (uintptr_t)ret_var.inner;
40592         if (ret_var.is_owned) {
40593                 ret_ref |= 1;
40594         }
40595         return ret_ref;
40596 }
40597
40598 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) {
40599         LDKNetworkGraph this_arg_conv;
40600         this_arg_conv.inner = (void*)(this_arg & (~1));
40601         this_arg_conv.is_owned = false;
40602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40603         LDKNodeAnnouncement msg_conv;
40604         msg_conv.inner = (void*)(msg & (~1));
40605         msg_conv.is_owned = false;
40606         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40607         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40608         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
40609         return (uintptr_t)ret_conv;
40610 }
40611
40612 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) {
40613         LDKNetworkGraph this_arg_conv;
40614         this_arg_conv.inner = (void*)(this_arg & (~1));
40615         this_arg_conv.is_owned = false;
40616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40617         LDKUnsignedNodeAnnouncement msg_conv;
40618         msg_conv.inner = (void*)(msg & (~1));
40619         msg_conv.is_owned = false;
40620         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40621         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40622         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
40623         return (uintptr_t)ret_conv;
40624 }
40625
40626 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) {
40627         LDKNetworkGraph this_arg_conv;
40628         this_arg_conv.inner = (void*)(this_arg & (~1));
40629         this_arg_conv.is_owned = false;
40630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40631         LDKChannelAnnouncement msg_conv;
40632         msg_conv.inner = (void*)(msg & (~1));
40633         msg_conv.is_owned = false;
40634         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40635         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
40636         CHECK_ACCESS(chain_access_ptr);
40637         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
40638         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
40639         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
40640                 // Manually implement clone for Java trait instances
40641                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
40642                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40643                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
40644                 }
40645         }
40646         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40647         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
40648         return (uintptr_t)ret_conv;
40649 }
40650
40651 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) {
40652         LDKNetworkGraph this_arg_conv;
40653         this_arg_conv.inner = (void*)(this_arg & (~1));
40654         this_arg_conv.is_owned = false;
40655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40656         LDKUnsignedChannelAnnouncement msg_conv;
40657         msg_conv.inner = (void*)(msg & (~1));
40658         msg_conv.is_owned = false;
40659         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40660         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
40661         CHECK_ACCESS(chain_access_ptr);
40662         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
40663         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
40664         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
40665                 // Manually implement clone for Java trait instances
40666                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
40667                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40668                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
40669                 }
40670         }
40671         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40672         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
40673         return (uintptr_t)ret_conv;
40674 }
40675
40676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1close_1channel_1from_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
40677         LDKNetworkGraph this_arg_conv;
40678         this_arg_conv.inner = (void*)(this_arg & (~1));
40679         this_arg_conv.is_owned = false;
40680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40681         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
40682 }
40683
40684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1fail_1node(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
40685         LDKNetworkGraph this_arg_conv;
40686         this_arg_conv.inner = (void*)(this_arg & (~1));
40687         this_arg_conv.is_owned = false;
40688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40689         LDKPublicKey _node_id_ref;
40690         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
40691         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
40692         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
40693 }
40694
40695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
40696         LDKNetworkGraph this_arg_conv;
40697         this_arg_conv.inner = (void*)(this_arg & (~1));
40698         this_arg_conv.is_owned = false;
40699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40700         NetworkGraph_remove_stale_channels(&this_arg_conv);
40701 }
40702
40703 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) {
40704         LDKNetworkGraph this_arg_conv;
40705         this_arg_conv.inner = (void*)(this_arg & (~1));
40706         this_arg_conv.is_owned = false;
40707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40708         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
40709 }
40710
40711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
40712         LDKNetworkGraph this_arg_conv;
40713         this_arg_conv.inner = (void*)(this_arg & (~1));
40714         this_arg_conv.is_owned = false;
40715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40716         LDKChannelUpdate msg_conv;
40717         msg_conv.inner = (void*)(msg & (~1));
40718         msg_conv.is_owned = false;
40719         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40720         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40721         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
40722         return (uintptr_t)ret_conv;
40723 }
40724
40725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
40726         LDKNetworkGraph this_arg_conv;
40727         this_arg_conv.inner = (void*)(this_arg & (~1));
40728         this_arg_conv.is_owned = false;
40729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40730         LDKUnsignedChannelUpdate msg_conv;
40731         msg_conv.inner = (void*)(msg & (~1));
40732         msg_conv.is_owned = false;
40733         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40734         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40735         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
40736         return (uintptr_t)ret_conv;
40737 }
40738
40739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
40740         LDKReadOnlyNetworkGraph this_arg_conv;
40741         this_arg_conv.inner = (void*)(this_arg & (~1));
40742         this_arg_conv.is_owned = false;
40743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40744         LDKPublicKey pubkey_ref;
40745         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
40746         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
40747         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
40748         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
40749         uintptr_t ret_ref = (uintptr_t)ret_copy;
40750         return ret_ref;
40751 }
40752
40753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40754         LDKRouteHop this_obj_conv;
40755         this_obj_conv.inner = (void*)(this_obj & (~1));
40756         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40758         RouteHop_free(this_obj_conv);
40759 }
40760
40761 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
40762         LDKRouteHop this_ptr_conv;
40763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40764         this_ptr_conv.is_owned = false;
40765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40766         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
40767         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
40768         return ret_arr;
40769 }
40770
40771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40772         LDKRouteHop this_ptr_conv;
40773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40774         this_ptr_conv.is_owned = false;
40775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40776         LDKPublicKey val_ref;
40777         CHECK((*env)->GetArrayLength(env, val) == 33);
40778         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
40779         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
40780 }
40781
40782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
40783         LDKRouteHop this_ptr_conv;
40784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40785         this_ptr_conv.is_owned = false;
40786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40787         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
40788         uintptr_t ret_ref = 0;
40789         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40790         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40792         ret_ref = (uintptr_t)ret_var.inner;
40793         if (ret_var.is_owned) {
40794                 ret_ref |= 1;
40795         }
40796         return ret_ref;
40797 }
40798
40799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40800         LDKRouteHop this_ptr_conv;
40801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40802         this_ptr_conv.is_owned = false;
40803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40804         LDKNodeFeatures val_conv;
40805         val_conv.inner = (void*)(val & (~1));
40806         val_conv.is_owned = (val & 1) || (val == 0);
40807         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40808         val_conv = NodeFeatures_clone(&val_conv);
40809         RouteHop_set_node_features(&this_ptr_conv, val_conv);
40810 }
40811
40812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
40813         LDKRouteHop this_ptr_conv;
40814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40815         this_ptr_conv.is_owned = false;
40816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40817         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
40818         return ret_val;
40819 }
40820
40821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40822         LDKRouteHop this_ptr_conv;
40823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40824         this_ptr_conv.is_owned = false;
40825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40826         RouteHop_set_short_channel_id(&this_ptr_conv, val);
40827 }
40828
40829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
40830         LDKRouteHop this_ptr_conv;
40831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40832         this_ptr_conv.is_owned = false;
40833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40834         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
40835         uintptr_t ret_ref = 0;
40836         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40837         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40839         ret_ref = (uintptr_t)ret_var.inner;
40840         if (ret_var.is_owned) {
40841                 ret_ref |= 1;
40842         }
40843         return ret_ref;
40844 }
40845
40846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40847         LDKRouteHop this_ptr_conv;
40848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40849         this_ptr_conv.is_owned = false;
40850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40851         LDKChannelFeatures val_conv;
40852         val_conv.inner = (void*)(val & (~1));
40853         val_conv.is_owned = (val & 1) || (val == 0);
40854         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40855         val_conv = ChannelFeatures_clone(&val_conv);
40856         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
40857 }
40858
40859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
40860         LDKRouteHop this_ptr_conv;
40861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40862         this_ptr_conv.is_owned = false;
40863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40864         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
40865         return ret_val;
40866 }
40867
40868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40869         LDKRouteHop this_ptr_conv;
40870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40871         this_ptr_conv.is_owned = false;
40872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40873         RouteHop_set_fee_msat(&this_ptr_conv, val);
40874 }
40875
40876 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
40877         LDKRouteHop this_ptr_conv;
40878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40879         this_ptr_conv.is_owned = false;
40880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40881         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
40882         return ret_val;
40883 }
40884
40885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40886         LDKRouteHop this_ptr_conv;
40887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40888         this_ptr_conv.is_owned = false;
40889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40890         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
40891 }
40892
40893 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) {
40894         LDKPublicKey pubkey_arg_ref;
40895         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
40896         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
40897         LDKNodeFeatures node_features_arg_conv;
40898         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
40899         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
40900         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
40901         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
40902         LDKChannelFeatures channel_features_arg_conv;
40903         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
40904         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
40905         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
40906         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
40907         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);
40908         uintptr_t ret_ref = 0;
40909         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40910         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40912         ret_ref = (uintptr_t)ret_var.inner;
40913         if (ret_var.is_owned) {
40914                 ret_ref |= 1;
40915         }
40916         return ret_ref;
40917 }
40918
40919 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
40920         LDKRouteHop ret_var = RouteHop_clone(arg);
40921 uintptr_t ret_ref = 0;
40922 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40923 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40924 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40925 ret_ref = (uintptr_t)ret_var.inner;
40926 if (ret_var.is_owned) {
40927         ret_ref |= 1;
40928 }
40929         return ret_ref;
40930 }
40931 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40932         LDKRouteHop arg_conv;
40933         arg_conv.inner = (void*)(arg & (~1));
40934         arg_conv.is_owned = false;
40935         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40936         intptr_t ret_val = RouteHop_clone_ptr(&arg_conv);
40937         return ret_val;
40938 }
40939
40940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40941         LDKRouteHop orig_conv;
40942         orig_conv.inner = (void*)(orig & (~1));
40943         orig_conv.is_owned = false;
40944         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40945         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
40946         uintptr_t ret_ref = 0;
40947         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40948         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40950         ret_ref = (uintptr_t)ret_var.inner;
40951         if (ret_var.is_owned) {
40952                 ret_ref |= 1;
40953         }
40954         return ret_ref;
40955 }
40956
40957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
40958         LDKRouteHop o_conv;
40959         o_conv.inner = (void*)(o & (~1));
40960         o_conv.is_owned = false;
40961         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40962         int64_t ret_val = RouteHop_hash(&o_conv);
40963         return ret_val;
40964 }
40965
40966 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40967         LDKRouteHop a_conv;
40968         a_conv.inner = (void*)(a & (~1));
40969         a_conv.is_owned = false;
40970         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40971         LDKRouteHop b_conv;
40972         b_conv.inner = (void*)(b & (~1));
40973         b_conv.is_owned = false;
40974         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40975         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
40976         return ret_val;
40977 }
40978
40979 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
40980         LDKRouteHop obj_conv;
40981         obj_conv.inner = (void*)(obj & (~1));
40982         obj_conv.is_owned = false;
40983         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40984         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
40985         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40986         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40987         CVec_u8Z_free(ret_var);
40988         return ret_arr;
40989 }
40990
40991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40992         LDKu8slice ser_ref;
40993         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40994         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40995         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
40996         *ret_conv = RouteHop_read(ser_ref);
40997         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40998         return (uintptr_t)ret_conv;
40999 }
41000
41001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41002         LDKRoute this_obj_conv;
41003         this_obj_conv.inner = (void*)(this_obj & (~1));
41004         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41006         Route_free(this_obj_conv);
41007 }
41008
41009 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
41010         LDKRoute this_ptr_conv;
41011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41012         this_ptr_conv.is_owned = false;
41013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41014         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
41015         jobjectArray ret_arr = NULL;
41016         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
41017         ;
41018         for (size_t m = 0; m < ret_var.datalen; m++) {
41019                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
41020                 int64_tArray ret_conv_12_arr = NULL;
41021                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
41022                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
41023                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
41024                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
41025                         uintptr_t ret_conv_12_conv_10_ref = 0;
41026                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41027                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41028                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
41029                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
41030                         if (ret_conv_12_conv_10_var.is_owned) {
41031                                 ret_conv_12_conv_10_ref |= 1;
41032                         }
41033                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
41034                 }
41035                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
41036                 FREE(ret_conv_12_var.data);
41037                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
41038         }
41039         
41040         FREE(ret_var.data);
41041         return ret_arr;
41042 }
41043
41044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
41045         LDKRoute this_ptr_conv;
41046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41047         this_ptr_conv.is_owned = false;
41048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41049         LDKCVec_CVec_RouteHopZZ val_constr;
41050         val_constr.datalen = (*env)->GetArrayLength(env, val);
41051         if (val_constr.datalen > 0)
41052                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41053         else
41054                 val_constr.data = NULL;
41055         for (size_t m = 0; m < val_constr.datalen; m++) {
41056                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
41057                 LDKCVec_RouteHopZ val_conv_12_constr;
41058                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
41059                 if (val_conv_12_constr.datalen > 0)
41060                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41061                 else
41062                         val_conv_12_constr.data = NULL;
41063                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
41064                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
41065                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
41066                         LDKRouteHop val_conv_12_conv_10_conv;
41067                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
41068                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
41069                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
41070                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
41071                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
41072                 }
41073                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
41074                 val_constr.data[m] = val_conv_12_constr;
41075         }
41076         Route_set_paths(&this_ptr_conv, val_constr);
41077 }
41078
41079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
41080         LDKRoute this_ptr_conv;
41081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41082         this_ptr_conv.is_owned = false;
41083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41084         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
41085         uintptr_t ret_ref = 0;
41086         if ((uintptr_t)ret_var.inner > 4096) {
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         }
41095         return ret_ref;
41096 }
41097
41098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41099         LDKRoute this_ptr_conv;
41100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41101         this_ptr_conv.is_owned = false;
41102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41103         LDKPaymentParameters val_conv;
41104         val_conv.inner = (void*)(val & (~1));
41105         val_conv.is_owned = (val & 1) || (val == 0);
41106         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41107         val_conv = PaymentParameters_clone(&val_conv);
41108         Route_set_payment_params(&this_ptr_conv, val_conv);
41109 }
41110
41111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
41112         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
41113         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
41114         if (paths_arg_constr.datalen > 0)
41115                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41116         else
41117                 paths_arg_constr.data = NULL;
41118         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
41119                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
41120                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
41121                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
41122                 if (paths_arg_conv_12_constr.datalen > 0)
41123                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41124                 else
41125                         paths_arg_conv_12_constr.data = NULL;
41126                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
41127                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
41128                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
41129                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
41130                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
41131                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
41132                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
41133                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
41134                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
41135                 }
41136                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
41137                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
41138         }
41139         LDKPaymentParameters payment_params_arg_conv;
41140         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
41141         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
41142         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
41143         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
41144         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
41145         uintptr_t ret_ref = 0;
41146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41149         ret_ref = (uintptr_t)ret_var.inner;
41150         if (ret_var.is_owned) {
41151                 ret_ref |= 1;
41152         }
41153         return ret_ref;
41154 }
41155
41156 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
41157         LDKRoute ret_var = Route_clone(arg);
41158 uintptr_t ret_ref = 0;
41159 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41160 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41161 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41162 ret_ref = (uintptr_t)ret_var.inner;
41163 if (ret_var.is_owned) {
41164         ret_ref |= 1;
41165 }
41166         return ret_ref;
41167 }
41168 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41169         LDKRoute arg_conv;
41170         arg_conv.inner = (void*)(arg & (~1));
41171         arg_conv.is_owned = false;
41172         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41173         intptr_t ret_val = Route_clone_ptr(&arg_conv);
41174         return ret_val;
41175 }
41176
41177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41178         LDKRoute orig_conv;
41179         orig_conv.inner = (void*)(orig & (~1));
41180         orig_conv.is_owned = false;
41181         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41182         LDKRoute ret_var = Route_clone(&orig_conv);
41183         uintptr_t ret_ref = 0;
41184         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41185         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41186         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41187         ret_ref = (uintptr_t)ret_var.inner;
41188         if (ret_var.is_owned) {
41189                 ret_ref |= 1;
41190         }
41191         return ret_ref;
41192 }
41193
41194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
41195         LDKRoute o_conv;
41196         o_conv.inner = (void*)(o & (~1));
41197         o_conv.is_owned = false;
41198         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41199         int64_t ret_val = Route_hash(&o_conv);
41200         return ret_val;
41201 }
41202
41203 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41204         LDKRoute a_conv;
41205         a_conv.inner = (void*)(a & (~1));
41206         a_conv.is_owned = false;
41207         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41208         LDKRoute b_conv;
41209         b_conv.inner = (void*)(b & (~1));
41210         b_conv.is_owned = false;
41211         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41212         jboolean ret_val = Route_eq(&a_conv, &b_conv);
41213         return ret_val;
41214 }
41215
41216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
41217         LDKRoute this_arg_conv;
41218         this_arg_conv.inner = (void*)(this_arg & (~1));
41219         this_arg_conv.is_owned = false;
41220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41221         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
41222         return ret_val;
41223 }
41224
41225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
41226         LDKRoute this_arg_conv;
41227         this_arg_conv.inner = (void*)(this_arg & (~1));
41228         this_arg_conv.is_owned = false;
41229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41230         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
41231         return ret_val;
41232 }
41233
41234 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
41235         LDKRoute obj_conv;
41236         obj_conv.inner = (void*)(obj & (~1));
41237         obj_conv.is_owned = false;
41238         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41239         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
41240         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41241         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41242         CVec_u8Z_free(ret_var);
41243         return ret_arr;
41244 }
41245
41246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41247         LDKu8slice ser_ref;
41248         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41249         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41250         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
41251         *ret_conv = Route_read(ser_ref);
41252         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41253         return (uintptr_t)ret_conv;
41254 }
41255
41256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41257         LDKRouteParameters this_obj_conv;
41258         this_obj_conv.inner = (void*)(this_obj & (~1));
41259         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41261         RouteParameters_free(this_obj_conv);
41262 }
41263
41264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
41265         LDKRouteParameters this_ptr_conv;
41266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41267         this_ptr_conv.is_owned = false;
41268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41269         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
41270         uintptr_t ret_ref = 0;
41271         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41272         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41273         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41274         ret_ref = (uintptr_t)ret_var.inner;
41275         if (ret_var.is_owned) {
41276                 ret_ref |= 1;
41277         }
41278         return ret_ref;
41279 }
41280
41281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41282         LDKRouteParameters this_ptr_conv;
41283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41284         this_ptr_conv.is_owned = false;
41285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41286         LDKPaymentParameters val_conv;
41287         val_conv.inner = (void*)(val & (~1));
41288         val_conv.is_owned = (val & 1) || (val == 0);
41289         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41290         val_conv = PaymentParameters_clone(&val_conv);
41291         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
41292 }
41293
41294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
41295         LDKRouteParameters this_ptr_conv;
41296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41297         this_ptr_conv.is_owned = false;
41298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41299         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
41300         return ret_val;
41301 }
41302
41303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41304         LDKRouteParameters this_ptr_conv;
41305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41306         this_ptr_conv.is_owned = false;
41307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41308         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
41309 }
41310
41311 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
41312         LDKRouteParameters this_ptr_conv;
41313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41314         this_ptr_conv.is_owned = false;
41315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41316         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
41317         return ret_val;
41318 }
41319
41320 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) {
41321         LDKRouteParameters this_ptr_conv;
41322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41323         this_ptr_conv.is_owned = false;
41324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41325         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
41326 }
41327
41328 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) {
41329         LDKPaymentParameters payment_params_arg_conv;
41330         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
41331         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
41332         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
41333         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
41334         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
41335         uintptr_t ret_ref = 0;
41336         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41337         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41339         ret_ref = (uintptr_t)ret_var.inner;
41340         if (ret_var.is_owned) {
41341                 ret_ref |= 1;
41342         }
41343         return ret_ref;
41344 }
41345
41346 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
41347         LDKRouteParameters ret_var = RouteParameters_clone(arg);
41348 uintptr_t ret_ref = 0;
41349 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41350 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41351 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41352 ret_ref = (uintptr_t)ret_var.inner;
41353 if (ret_var.is_owned) {
41354         ret_ref |= 1;
41355 }
41356         return ret_ref;
41357 }
41358 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41359         LDKRouteParameters arg_conv;
41360         arg_conv.inner = (void*)(arg & (~1));
41361         arg_conv.is_owned = false;
41362         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41363         intptr_t ret_val = RouteParameters_clone_ptr(&arg_conv);
41364         return ret_val;
41365 }
41366
41367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41368         LDKRouteParameters orig_conv;
41369         orig_conv.inner = (void*)(orig & (~1));
41370         orig_conv.is_owned = false;
41371         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41372         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
41373         uintptr_t ret_ref = 0;
41374         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41375         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41377         ret_ref = (uintptr_t)ret_var.inner;
41378         if (ret_var.is_owned) {
41379                 ret_ref |= 1;
41380         }
41381         return ret_ref;
41382 }
41383
41384 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
41385         LDKRouteParameters obj_conv;
41386         obj_conv.inner = (void*)(obj & (~1));
41387         obj_conv.is_owned = false;
41388         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41389         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
41390         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41391         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41392         CVec_u8Z_free(ret_var);
41393         return ret_arr;
41394 }
41395
41396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41397         LDKu8slice ser_ref;
41398         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41399         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41400         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
41401         *ret_conv = RouteParameters_read(ser_ref);
41402         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41403         return (uintptr_t)ret_conv;
41404 }
41405
41406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41407         LDKPaymentParameters this_obj_conv;
41408         this_obj_conv.inner = (void*)(this_obj & (~1));
41409         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41411         PaymentParameters_free(this_obj_conv);
41412 }
41413
41414 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
41415         LDKPaymentParameters this_ptr_conv;
41416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41417         this_ptr_conv.is_owned = false;
41418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41419         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41420         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
41421         return ret_arr;
41422 }
41423
41424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41425         LDKPaymentParameters this_ptr_conv;
41426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41427         this_ptr_conv.is_owned = false;
41428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41429         LDKPublicKey val_ref;
41430         CHECK((*env)->GetArrayLength(env, val) == 33);
41431         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41432         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
41433 }
41434
41435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
41436         LDKPaymentParameters this_ptr_conv;
41437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41438         this_ptr_conv.is_owned = false;
41439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41440         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
41441         uintptr_t ret_ref = 0;
41442         if ((uintptr_t)ret_var.inner > 4096) {
41443                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41444                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41446                 ret_ref = (uintptr_t)ret_var.inner;
41447                 if (ret_var.is_owned) {
41448                         ret_ref |= 1;
41449                 }
41450         }
41451         return ret_ref;
41452 }
41453
41454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41455         LDKPaymentParameters this_ptr_conv;
41456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41457         this_ptr_conv.is_owned = false;
41458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41459         LDKInvoiceFeatures val_conv;
41460         val_conv.inner = (void*)(val & (~1));
41461         val_conv.is_owned = (val & 1) || (val == 0);
41462         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41463         val_conv = InvoiceFeatures_clone(&val_conv);
41464         PaymentParameters_set_features(&this_ptr_conv, val_conv);
41465 }
41466
41467 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
41468         LDKPaymentParameters this_ptr_conv;
41469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41470         this_ptr_conv.is_owned = false;
41471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41472         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
41473         int64_tArray ret_arr = NULL;
41474         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
41475         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
41476         for (size_t l = 0; l < ret_var.datalen; l++) {
41477                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
41478                 uintptr_t ret_conv_11_ref = 0;
41479                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41480                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41481                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
41482                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
41483                 if (ret_conv_11_var.is_owned) {
41484                         ret_conv_11_ref |= 1;
41485                 }
41486                 ret_arr_ptr[l] = ret_conv_11_ref;
41487         }
41488         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
41489         FREE(ret_var.data);
41490         return ret_arr;
41491 }
41492
41493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
41494         LDKPaymentParameters this_ptr_conv;
41495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41496         this_ptr_conv.is_owned = false;
41497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41498         LDKCVec_RouteHintZ val_constr;
41499         val_constr.datalen = (*env)->GetArrayLength(env, val);
41500         if (val_constr.datalen > 0)
41501                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
41502         else
41503                 val_constr.data = NULL;
41504         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
41505         for (size_t l = 0; l < val_constr.datalen; l++) {
41506                 int64_t val_conv_11 = val_vals[l];
41507                 LDKRouteHint val_conv_11_conv;
41508                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
41509                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
41510                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
41511                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
41512                 val_constr.data[l] = val_conv_11_conv;
41513         }
41514         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
41515         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
41516 }
41517
41518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
41519         LDKPaymentParameters this_ptr_conv;
41520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41521         this_ptr_conv.is_owned = false;
41522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41523         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41524         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
41525         uintptr_t ret_ref = (uintptr_t)ret_copy;
41526         return ret_ref;
41527 }
41528
41529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41530         LDKPaymentParameters this_ptr_conv;
41531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41532         this_ptr_conv.is_owned = false;
41533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41534         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
41535         CHECK_ACCESS(val_ptr);
41536         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
41537         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
41538         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
41539 }
41540
41541 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
41542         LDKPaymentParameters this_ptr_conv;
41543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41544         this_ptr_conv.is_owned = false;
41545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41546         int32_t ret_val = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
41547         return ret_val;
41548 }
41549
41550 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) {
41551         LDKPaymentParameters this_ptr_conv;
41552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41553         this_ptr_conv.is_owned = false;
41554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41555         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
41556 }
41557
41558 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) {
41559         LDKPublicKey payee_pubkey_arg_ref;
41560         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
41561         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
41562         LDKInvoiceFeatures features_arg_conv;
41563         features_arg_conv.inner = (void*)(features_arg & (~1));
41564         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
41565         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
41566         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
41567         LDKCVec_RouteHintZ route_hints_arg_constr;
41568         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
41569         if (route_hints_arg_constr.datalen > 0)
41570                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
41571         else
41572                 route_hints_arg_constr.data = NULL;
41573         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
41574         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
41575                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
41576                 LDKRouteHint route_hints_arg_conv_11_conv;
41577                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
41578                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
41579                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
41580                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
41581                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
41582         }
41583         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
41584         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
41585         CHECK_ACCESS(expiry_time_arg_ptr);
41586         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
41587         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
41588         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);
41589         uintptr_t ret_ref = 0;
41590         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41591         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41593         ret_ref = (uintptr_t)ret_var.inner;
41594         if (ret_var.is_owned) {
41595                 ret_ref |= 1;
41596         }
41597         return ret_ref;
41598 }
41599
41600 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
41601         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
41602 uintptr_t ret_ref = 0;
41603 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41604 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41605 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41606 ret_ref = (uintptr_t)ret_var.inner;
41607 if (ret_var.is_owned) {
41608         ret_ref |= 1;
41609 }
41610         return ret_ref;
41611 }
41612 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41613         LDKPaymentParameters arg_conv;
41614         arg_conv.inner = (void*)(arg & (~1));
41615         arg_conv.is_owned = false;
41616         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41617         intptr_t ret_val = PaymentParameters_clone_ptr(&arg_conv);
41618         return ret_val;
41619 }
41620
41621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41622         LDKPaymentParameters orig_conv;
41623         orig_conv.inner = (void*)(orig & (~1));
41624         orig_conv.is_owned = false;
41625         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41626         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
41627         uintptr_t ret_ref = 0;
41628         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41629         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41631         ret_ref = (uintptr_t)ret_var.inner;
41632         if (ret_var.is_owned) {
41633                 ret_ref |= 1;
41634         }
41635         return ret_ref;
41636 }
41637
41638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
41639         LDKPaymentParameters o_conv;
41640         o_conv.inner = (void*)(o & (~1));
41641         o_conv.is_owned = false;
41642         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41643         int64_t ret_val = PaymentParameters_hash(&o_conv);
41644         return ret_val;
41645 }
41646
41647 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41648         LDKPaymentParameters a_conv;
41649         a_conv.inner = (void*)(a & (~1));
41650         a_conv.is_owned = false;
41651         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41652         LDKPaymentParameters b_conv;
41653         b_conv.inner = (void*)(b & (~1));
41654         b_conv.is_owned = false;
41655         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41656         jboolean ret_val = PaymentParameters_eq(&a_conv, &b_conv);
41657         return ret_val;
41658 }
41659
41660 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
41661         LDKPaymentParameters obj_conv;
41662         obj_conv.inner = (void*)(obj & (~1));
41663         obj_conv.is_owned = false;
41664         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41665         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
41666         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41667         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41668         CVec_u8Z_free(ret_var);
41669         return ret_arr;
41670 }
41671
41672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41673         LDKu8slice ser_ref;
41674         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41675         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41676         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
41677         *ret_conv = PaymentParameters_read(ser_ref);
41678         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41679         return (uintptr_t)ret_conv;
41680 }
41681
41682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
41683         LDKPublicKey payee_pubkey_ref;
41684         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
41685         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
41686         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
41687         uintptr_t ret_ref = 0;
41688         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41689         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41691         ret_ref = (uintptr_t)ret_var.inner;
41692         if (ret_var.is_owned) {
41693                 ret_ref |= 1;
41694         }
41695         return ret_ref;
41696 }
41697
41698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
41699         LDKPublicKey payee_pubkey_ref;
41700         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
41701         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
41702         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
41703         uintptr_t ret_ref = 0;
41704         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41705         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41707         ret_ref = (uintptr_t)ret_var.inner;
41708         if (ret_var.is_owned) {
41709                 ret_ref |= 1;
41710         }
41711         return ret_ref;
41712 }
41713
41714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41715         LDKRouteHint this_obj_conv;
41716         this_obj_conv.inner = (void*)(this_obj & (~1));
41717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41719         RouteHint_free(this_obj_conv);
41720 }
41721
41722 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
41723         LDKRouteHint this_ptr_conv;
41724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41725         this_ptr_conv.is_owned = false;
41726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41727         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
41728         int64_tArray ret_arr = NULL;
41729         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
41730         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
41731         for (size_t o = 0; o < ret_var.datalen; o++) {
41732                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
41733                 uintptr_t ret_conv_14_ref = 0;
41734                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41735                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41736                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
41737                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
41738                 if (ret_conv_14_var.is_owned) {
41739                         ret_conv_14_ref |= 1;
41740                 }
41741                 ret_arr_ptr[o] = ret_conv_14_ref;
41742         }
41743         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
41744         FREE(ret_var.data);
41745         return ret_arr;
41746 }
41747
41748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
41749         LDKRouteHint this_ptr_conv;
41750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41751         this_ptr_conv.is_owned = false;
41752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41753         LDKCVec_RouteHintHopZ val_constr;
41754         val_constr.datalen = (*env)->GetArrayLength(env, val);
41755         if (val_constr.datalen > 0)
41756                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
41757         else
41758                 val_constr.data = NULL;
41759         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
41760         for (size_t o = 0; o < val_constr.datalen; o++) {
41761                 int64_t val_conv_14 = val_vals[o];
41762                 LDKRouteHintHop val_conv_14_conv;
41763                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
41764                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
41765                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
41766                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
41767                 val_constr.data[o] = val_conv_14_conv;
41768         }
41769         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
41770         RouteHint_set_a(&this_ptr_conv, val_constr);
41771 }
41772
41773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
41774         LDKCVec_RouteHintHopZ a_arg_constr;
41775         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
41776         if (a_arg_constr.datalen > 0)
41777                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
41778         else
41779                 a_arg_constr.data = NULL;
41780         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
41781         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
41782                 int64_t a_arg_conv_14 = a_arg_vals[o];
41783                 LDKRouteHintHop a_arg_conv_14_conv;
41784                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
41785                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
41786                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
41787                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
41788                 a_arg_constr.data[o] = a_arg_conv_14_conv;
41789         }
41790         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
41791         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
41792         uintptr_t ret_ref = 0;
41793         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41794         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41796         ret_ref = (uintptr_t)ret_var.inner;
41797         if (ret_var.is_owned) {
41798                 ret_ref |= 1;
41799         }
41800         return ret_ref;
41801 }
41802
41803 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
41804         LDKRouteHint ret_var = RouteHint_clone(arg);
41805 uintptr_t ret_ref = 0;
41806 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41807 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41808 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41809 ret_ref = (uintptr_t)ret_var.inner;
41810 if (ret_var.is_owned) {
41811         ret_ref |= 1;
41812 }
41813         return ret_ref;
41814 }
41815 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41816         LDKRouteHint arg_conv;
41817         arg_conv.inner = (void*)(arg & (~1));
41818         arg_conv.is_owned = false;
41819         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41820         intptr_t ret_val = RouteHint_clone_ptr(&arg_conv);
41821         return ret_val;
41822 }
41823
41824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41825         LDKRouteHint orig_conv;
41826         orig_conv.inner = (void*)(orig & (~1));
41827         orig_conv.is_owned = false;
41828         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41829         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
41830         uintptr_t ret_ref = 0;
41831         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41832         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41834         ret_ref = (uintptr_t)ret_var.inner;
41835         if (ret_var.is_owned) {
41836                 ret_ref |= 1;
41837         }
41838         return ret_ref;
41839 }
41840
41841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
41842         LDKRouteHint o_conv;
41843         o_conv.inner = (void*)(o & (~1));
41844         o_conv.is_owned = false;
41845         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41846         int64_t ret_val = RouteHint_hash(&o_conv);
41847         return ret_val;
41848 }
41849
41850 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41851         LDKRouteHint a_conv;
41852         a_conv.inner = (void*)(a & (~1));
41853         a_conv.is_owned = false;
41854         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41855         LDKRouteHint b_conv;
41856         b_conv.inner = (void*)(b & (~1));
41857         b_conv.is_owned = false;
41858         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41859         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
41860         return ret_val;
41861 }
41862
41863 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
41864         LDKRouteHint obj_conv;
41865         obj_conv.inner = (void*)(obj & (~1));
41866         obj_conv.is_owned = false;
41867         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41868         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
41869         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41870         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41871         CVec_u8Z_free(ret_var);
41872         return ret_arr;
41873 }
41874
41875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41876         LDKu8slice ser_ref;
41877         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41878         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41879         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
41880         *ret_conv = RouteHint_read(ser_ref);
41881         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41882         return (uintptr_t)ret_conv;
41883 }
41884
41885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41886         LDKRouteHintHop this_obj_conv;
41887         this_obj_conv.inner = (void*)(this_obj & (~1));
41888         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41890         RouteHintHop_free(this_obj_conv);
41891 }
41892
41893 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
41894         LDKRouteHintHop this_ptr_conv;
41895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41896         this_ptr_conv.is_owned = false;
41897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41898         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41899         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
41900         return ret_arr;
41901 }
41902
41903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41904         LDKRouteHintHop this_ptr_conv;
41905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41906         this_ptr_conv.is_owned = false;
41907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41908         LDKPublicKey val_ref;
41909         CHECK((*env)->GetArrayLength(env, val) == 33);
41910         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41911         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
41912 }
41913
41914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
41915         LDKRouteHintHop this_ptr_conv;
41916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41917         this_ptr_conv.is_owned = false;
41918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41919         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
41920         return ret_val;
41921 }
41922
41923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41924         LDKRouteHintHop this_ptr_conv;
41925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41926         this_ptr_conv.is_owned = false;
41927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41928         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
41929 }
41930
41931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
41932         LDKRouteHintHop this_ptr_conv;
41933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41934         this_ptr_conv.is_owned = false;
41935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41936         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
41937         uintptr_t ret_ref = 0;
41938         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41939         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41941         ret_ref = (uintptr_t)ret_var.inner;
41942         if (ret_var.is_owned) {
41943                 ret_ref |= 1;
41944         }
41945         return ret_ref;
41946 }
41947
41948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41949         LDKRouteHintHop this_ptr_conv;
41950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41951         this_ptr_conv.is_owned = false;
41952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41953         LDKRoutingFees val_conv;
41954         val_conv.inner = (void*)(val & (~1));
41955         val_conv.is_owned = (val & 1) || (val == 0);
41956         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41957         val_conv = RoutingFees_clone(&val_conv);
41958         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
41959 }
41960
41961 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
41962         LDKRouteHintHop this_ptr_conv;
41963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41964         this_ptr_conv.is_owned = false;
41965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41966         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
41967         return ret_val;
41968 }
41969
41970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
41971         LDKRouteHintHop this_ptr_conv;
41972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41973         this_ptr_conv.is_owned = false;
41974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41975         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
41976 }
41977
41978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
41979         LDKRouteHintHop this_ptr_conv;
41980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41981         this_ptr_conv.is_owned = false;
41982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41983         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41984         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
41985         uintptr_t ret_ref = (uintptr_t)ret_copy;
41986         return ret_ref;
41987 }
41988
41989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41990         LDKRouteHintHop this_ptr_conv;
41991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41992         this_ptr_conv.is_owned = false;
41993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41994         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
41995         CHECK_ACCESS(val_ptr);
41996         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
41997         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
41998         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
41999 }
42000
42001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42002         LDKRouteHintHop this_ptr_conv;
42003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42004         this_ptr_conv.is_owned = false;
42005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42006         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42007         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
42008         uintptr_t ret_ref = (uintptr_t)ret_copy;
42009         return ret_ref;
42010 }
42011
42012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42013         LDKRouteHintHop this_ptr_conv;
42014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42015         this_ptr_conv.is_owned = false;
42016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42017         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42018         CHECK_ACCESS(val_ptr);
42019         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42020         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42021         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
42022 }
42023
42024 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) {
42025         LDKPublicKey src_node_id_arg_ref;
42026         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
42027         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
42028         LDKRoutingFees fees_arg_conv;
42029         fees_arg_conv.inner = (void*)(fees_arg & (~1));
42030         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
42031         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
42032         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
42033         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
42034         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
42035         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
42036         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
42037         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
42038         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
42039         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
42040         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
42041         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);
42042         uintptr_t ret_ref = 0;
42043         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42044         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42046         ret_ref = (uintptr_t)ret_var.inner;
42047         if (ret_var.is_owned) {
42048                 ret_ref |= 1;
42049         }
42050         return ret_ref;
42051 }
42052
42053 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
42054         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
42055 uintptr_t ret_ref = 0;
42056 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42057 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42058 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42059 ret_ref = (uintptr_t)ret_var.inner;
42060 if (ret_var.is_owned) {
42061         ret_ref |= 1;
42062 }
42063         return ret_ref;
42064 }
42065 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42066         LDKRouteHintHop arg_conv;
42067         arg_conv.inner = (void*)(arg & (~1));
42068         arg_conv.is_owned = false;
42069         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42070         intptr_t ret_val = RouteHintHop_clone_ptr(&arg_conv);
42071         return ret_val;
42072 }
42073
42074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42075         LDKRouteHintHop orig_conv;
42076         orig_conv.inner = (void*)(orig & (~1));
42077         orig_conv.is_owned = false;
42078         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42079         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
42080         uintptr_t ret_ref = 0;
42081         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42082         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42084         ret_ref = (uintptr_t)ret_var.inner;
42085         if (ret_var.is_owned) {
42086                 ret_ref |= 1;
42087         }
42088         return ret_ref;
42089 }
42090
42091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
42092         LDKRouteHintHop o_conv;
42093         o_conv.inner = (void*)(o & (~1));
42094         o_conv.is_owned = false;
42095         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42096         int64_t ret_val = RouteHintHop_hash(&o_conv);
42097         return ret_val;
42098 }
42099
42100 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42101         LDKRouteHintHop a_conv;
42102         a_conv.inner = (void*)(a & (~1));
42103         a_conv.is_owned = false;
42104         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42105         LDKRouteHintHop b_conv;
42106         b_conv.inner = (void*)(b & (~1));
42107         b_conv.is_owned = false;
42108         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42109         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
42110         return ret_val;
42111 }
42112
42113 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
42114         LDKRouteHintHop obj_conv;
42115         obj_conv.inner = (void*)(obj & (~1));
42116         obj_conv.is_owned = false;
42117         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42118         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
42119         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42120         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42121         CVec_u8Z_free(ret_var);
42122         return ret_arr;
42123 }
42124
42125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42126         LDKu8slice ser_ref;
42127         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42128         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42129         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
42130         *ret_conv = RouteHintHop_read(ser_ref);
42131         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42132         return (uintptr_t)ret_conv;
42133 }
42134
42135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_find_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t route_params, int64_t network, int64_tArray first_hops, int64_t logger, int64_t scorer) {
42136         LDKPublicKey our_node_pubkey_ref;
42137         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
42138         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
42139         LDKRouteParameters route_params_conv;
42140         route_params_conv.inner = (void*)(route_params & (~1));
42141         route_params_conv.is_owned = false;
42142         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
42143         LDKNetworkGraph network_conv;
42144         network_conv.inner = (void*)(network & (~1));
42145         network_conv.is_owned = false;
42146         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
42147         LDKCVec_ChannelDetailsZ first_hops_constr;
42148         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
42149         if (first_hops != NULL) {
42150                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
42151                 if (first_hops_constr.datalen > 0)
42152                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
42153                 else
42154                         first_hops_constr.data = NULL;
42155                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
42156                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
42157                         int64_t first_hops_conv_16 = first_hops_vals[q];
42158                         LDKChannelDetails first_hops_conv_16_conv;
42159                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
42160                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
42161                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
42162                         first_hops_constr.data[q] = first_hops_conv_16_conv;
42163                 }
42164                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
42165                 first_hops_ptr = &first_hops_constr;
42166         }
42167         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42168         CHECK_ACCESS(logger_ptr);
42169         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42170         if (logger_conv.free == LDKLogger_JCalls_free) {
42171                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42172                 LDKLogger_JCalls_cloned(&logger_conv);
42173         }
42174         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
42175         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
42176         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
42177         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
42178         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
42179         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
42180         return (uintptr_t)ret_conv;
42181 }
42182
42183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42184         if ((this_ptr & 1) != 0) return;
42185         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42186         CHECK_ACCESS(this_ptr_ptr);
42187         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
42188         FREE((void*)this_ptr);
42189         Score_free(this_ptr_conv);
42190 }
42191
42192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42193         if ((this_ptr & 1) != 0) return;
42194         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42195         CHECK_ACCESS(this_ptr_ptr);
42196         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
42197         FREE((void*)this_ptr);
42198         LockableScore_free(this_ptr_conv);
42199 }
42200
42201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42202         LDKMultiThreadedLockableScore this_obj_conv;
42203         this_obj_conv.inner = (void*)(this_obj & (~1));
42204         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42206         MultiThreadedLockableScore_free(this_obj_conv);
42207 }
42208
42209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
42210         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
42211         CHECK_ACCESS(score_ptr);
42212         LDKScore score_conv = *(LDKScore*)(score_ptr);
42213         if (score_conv.free == LDKScore_JCalls_free) {
42214                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42215                 LDKScore_JCalls_cloned(&score_conv);
42216         }
42217         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
42218         uintptr_t ret_ref = 0;
42219         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42220         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42222         ret_ref = (uintptr_t)ret_var.inner;
42223         if (ret_var.is_owned) {
42224                 ret_ref |= 1;
42225         }
42226         return ret_ref;
42227 }
42228
42229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42230         LDKFixedPenaltyScorer this_obj_conv;
42231         this_obj_conv.inner = (void*)(this_obj & (~1));
42232         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42234         FixedPenaltyScorer_free(this_obj_conv);
42235 }
42236
42237 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
42238         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
42239 uintptr_t ret_ref = 0;
42240 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42241 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42242 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42243 ret_ref = (uintptr_t)ret_var.inner;
42244 if (ret_var.is_owned) {
42245         ret_ref |= 1;
42246 }
42247         return ret_ref;
42248 }
42249 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42250         LDKFixedPenaltyScorer arg_conv;
42251         arg_conv.inner = (void*)(arg & (~1));
42252         arg_conv.is_owned = false;
42253         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42254         intptr_t ret_val = FixedPenaltyScorer_clone_ptr(&arg_conv);
42255         return ret_val;
42256 }
42257
42258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42259         LDKFixedPenaltyScorer orig_conv;
42260         orig_conv.inner = (void*)(orig & (~1));
42261         orig_conv.is_owned = false;
42262         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42263         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
42264         uintptr_t ret_ref = 0;
42265         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42266         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42268         ret_ref = (uintptr_t)ret_var.inner;
42269         if (ret_var.is_owned) {
42270                 ret_ref |= 1;
42271         }
42272         return ret_ref;
42273 }
42274
42275 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
42276         LDKFixedPenaltyScorer obj_conv;
42277         obj_conv.inner = (void*)(obj & (~1));
42278         obj_conv.is_owned = false;
42279         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42280         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
42281         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42282         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42283         CVec_u8Z_free(ret_var);
42284         return ret_arr;
42285 }
42286
42287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42288         LDKu8slice ser_ref;
42289         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42290         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42291         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
42292         *ret_conv = FixedPenaltyScorer_read(ser_ref);
42293         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42294         return (uintptr_t)ret_conv;
42295 }
42296
42297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
42298         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
42299         uintptr_t ret_ref = 0;
42300         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42301         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42303         ret_ref = (uintptr_t)ret_var.inner;
42304         if (ret_var.is_owned) {
42305                 ret_ref |= 1;
42306         }
42307         return ret_ref;
42308 }
42309
42310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
42311         LDKFixedPenaltyScorer this_arg_conv;
42312         this_arg_conv.inner = (void*)(this_arg & (~1));
42313         this_arg_conv.is_owned = false;
42314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42315         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
42316         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
42317         return (uintptr_t)ret_ret;
42318 }
42319
42320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Scorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42321         LDKScorer this_obj_conv;
42322         this_obj_conv.inner = (void*)(this_obj & (~1));
42323         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42325         Scorer_free(this_obj_conv);
42326 }
42327
42328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42329         LDKScoringParameters this_obj_conv;
42330         this_obj_conv.inner = (void*)(this_obj & (~1));
42331         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42333         ScoringParameters_free(this_obj_conv);
42334 }
42335
42336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42337         LDKScoringParameters this_ptr_conv;
42338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42339         this_ptr_conv.is_owned = false;
42340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42341         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
42342         return ret_val;
42343 }
42344
42345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42346         LDKScoringParameters this_ptr_conv;
42347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42348         this_ptr_conv.is_owned = false;
42349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42350         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
42351 }
42352
42353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42354         LDKScoringParameters this_ptr_conv;
42355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42356         this_ptr_conv.is_owned = false;
42357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42358         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
42359         return ret_val;
42360 }
42361
42362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42363         LDKScoringParameters this_ptr_conv;
42364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42365         this_ptr_conv.is_owned = false;
42366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42367         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
42368 }
42369
42370 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1overuse_1penalty_1start_11024th(JNIEnv *env, jclass clz, int64_t this_ptr) {
42371         LDKScoringParameters this_ptr_conv;
42372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42373         this_ptr_conv.is_owned = false;
42374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42375         int16_t ret_val = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
42376         return ret_val;
42377 }
42378
42379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1overuse_1penalty_1start_11024th(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
42380         LDKScoringParameters this_ptr_conv;
42381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42382         this_ptr_conv.is_owned = false;
42383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42384         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
42385 }
42386
42387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1overuse_1penalty_1msat_1per_11024th(JNIEnv *env, jclass clz, int64_t this_ptr) {
42388         LDKScoringParameters this_ptr_conv;
42389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42390         this_ptr_conv.is_owned = false;
42391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42392         int64_t ret_val = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
42393         return ret_val;
42394 }
42395
42396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1overuse_1penalty_1msat_1per_11024th(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42397         LDKScoringParameters this_ptr_conv;
42398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42399         this_ptr_conv.is_owned = false;
42400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42401         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
42402 }
42403
42404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
42405         LDKScoringParameters this_ptr_conv;
42406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42407         this_ptr_conv.is_owned = false;
42408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42409         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
42410         return ret_val;
42411 }
42412
42413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42414         LDKScoringParameters this_ptr_conv;
42415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42416         this_ptr_conv.is_owned = false;
42417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42418         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
42419 }
42420
42421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1new(JNIEnv *env, jclass clz, int64_t base_penalty_msat_arg, int64_t failure_penalty_msat_arg, int16_t overuse_penalty_start_1024th_arg, int64_t overuse_penalty_msat_per_1024th_arg, int64_t failure_penalty_half_life_arg) {
42422         LDKScoringParameters ret_var = ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, overuse_penalty_start_1024th_arg, overuse_penalty_msat_per_1024th_arg, failure_penalty_half_life_arg);
42423         uintptr_t ret_ref = 0;
42424         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42425         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42427         ret_ref = (uintptr_t)ret_var.inner;
42428         if (ret_var.is_owned) {
42429                 ret_ref |= 1;
42430         }
42431         return ret_ref;
42432 }
42433
42434 static inline uintptr_t ScoringParameters_clone_ptr(LDKScoringParameters *NONNULL_PTR arg) {
42435         LDKScoringParameters ret_var = ScoringParameters_clone(arg);
42436 uintptr_t ret_ref = 0;
42437 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42438 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42439 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42440 ret_ref = (uintptr_t)ret_var.inner;
42441 if (ret_var.is_owned) {
42442         ret_ref |= 1;
42443 }
42444         return ret_ref;
42445 }
42446 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42447         LDKScoringParameters arg_conv;
42448         arg_conv.inner = (void*)(arg & (~1));
42449         arg_conv.is_owned = false;
42450         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42451         intptr_t ret_val = ScoringParameters_clone_ptr(&arg_conv);
42452         return ret_val;
42453 }
42454
42455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42456         LDKScoringParameters orig_conv;
42457         orig_conv.inner = (void*)(orig & (~1));
42458         orig_conv.is_owned = false;
42459         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42460         LDKScoringParameters ret_var = ScoringParameters_clone(&orig_conv);
42461         uintptr_t ret_ref = 0;
42462         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42463         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42465         ret_ref = (uintptr_t)ret_var.inner;
42466         if (ret_var.is_owned) {
42467                 ret_ref |= 1;
42468         }
42469         return ret_ref;
42470 }
42471
42472 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
42473         LDKScoringParameters obj_conv;
42474         obj_conv.inner = (void*)(obj & (~1));
42475         obj_conv.is_owned = false;
42476         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42477         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
42478         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42479         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42480         CVec_u8Z_free(ret_var);
42481         return ret_arr;
42482 }
42483
42484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42485         LDKu8slice ser_ref;
42486         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42487         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42488         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
42489         *ret_conv = ScoringParameters_read(ser_ref);
42490         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42491         return (uintptr_t)ret_conv;
42492 }
42493
42494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1new(JNIEnv *env, jclass clz, int64_t params) {
42495         LDKScoringParameters params_conv;
42496         params_conv.inner = (void*)(params & (~1));
42497         params_conv.is_owned = (params & 1) || (params == 0);
42498         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
42499         params_conv = ScoringParameters_clone(&params_conv);
42500         LDKScorer ret_var = Scorer_new(params_conv);
42501         uintptr_t ret_ref = 0;
42502         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42503         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42505         ret_ref = (uintptr_t)ret_var.inner;
42506         if (ret_var.is_owned) {
42507                 ret_ref |= 1;
42508         }
42509         return ret_ref;
42510 }
42511
42512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1default(JNIEnv *env, jclass clz) {
42513         LDKScorer ret_var = Scorer_default();
42514         uintptr_t ret_ref = 0;
42515         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42516         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42517         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42518         ret_ref = (uintptr_t)ret_var.inner;
42519         if (ret_var.is_owned) {
42520                 ret_ref |= 1;
42521         }
42522         return ret_ref;
42523 }
42524
42525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1default(JNIEnv *env, jclass clz) {
42526         LDKScoringParameters ret_var = ScoringParameters_default();
42527         uintptr_t ret_ref = 0;
42528         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42529         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42531         ret_ref = (uintptr_t)ret_var.inner;
42532         if (ret_var.is_owned) {
42533                 ret_ref |= 1;
42534         }
42535         return ret_ref;
42536 }
42537
42538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
42539         LDKScorer this_arg_conv;
42540         this_arg_conv.inner = (void*)(this_arg & (~1));
42541         this_arg_conv.is_owned = false;
42542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42543         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
42544         *ret_ret = Scorer_as_Score(&this_arg_conv);
42545         return (uintptr_t)ret_ret;
42546 }
42547
42548 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Scorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
42549         LDKScorer obj_conv;
42550         obj_conv.inner = (void*)(obj & (~1));
42551         obj_conv.is_owned = false;
42552         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42553         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
42554         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42555         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42556         CVec_u8Z_free(ret_var);
42557         return ret_arr;
42558 }
42559
42560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42561         LDKu8slice ser_ref;
42562         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42563         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42564         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
42565         *ret_conv = Scorer_read(ser_ref);
42566         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42567         return (uintptr_t)ret_conv;
42568 }
42569
42570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42571         LDKProbabilisticScoringParameters this_obj_conv;
42572         this_obj_conv.inner = (void*)(this_obj & (~1));
42573         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42575         ProbabilisticScoringParameters_free(this_obj_conv);
42576 }
42577
42578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42579         LDKProbabilisticScoringParameters this_ptr_conv;
42580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42581         this_ptr_conv.is_owned = false;
42582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42583         int64_t ret_val = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
42584         return ret_val;
42585 }
42586
42587 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) {
42588         LDKProbabilisticScoringParameters this_ptr_conv;
42589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42590         this_ptr_conv.is_owned = false;
42591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42592         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
42593 }
42594
42595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
42596         LDKProbabilisticScoringParameters this_ptr_conv;
42597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42598         this_ptr_conv.is_owned = false;
42599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42600         int64_t ret_val = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
42601         return ret_val;
42602 }
42603
42604 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) {
42605         LDKProbabilisticScoringParameters this_ptr_conv;
42606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42607         this_ptr_conv.is_owned = false;
42608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42609         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
42610 }
42611
42612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1new(JNIEnv *env, jclass clz, int64_t liquidity_penalty_multiplier_msat_arg, int64_t liquidity_offset_half_life_arg) {
42613         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_new(liquidity_penalty_multiplier_msat_arg, liquidity_offset_half_life_arg);
42614         uintptr_t ret_ref = 0;
42615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42618         ret_ref = (uintptr_t)ret_var.inner;
42619         if (ret_var.is_owned) {
42620                 ret_ref |= 1;
42621         }
42622         return ret_ref;
42623 }
42624
42625 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
42626         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
42627 uintptr_t ret_ref = 0;
42628 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42629 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42630 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42631 ret_ref = (uintptr_t)ret_var.inner;
42632 if (ret_var.is_owned) {
42633         ret_ref |= 1;
42634 }
42635         return ret_ref;
42636 }
42637 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42638         LDKProbabilisticScoringParameters arg_conv;
42639         arg_conv.inner = (void*)(arg & (~1));
42640         arg_conv.is_owned = false;
42641         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42642         intptr_t ret_val = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
42643         return ret_val;
42644 }
42645
42646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42647         LDKProbabilisticScoringParameters orig_conv;
42648         orig_conv.inner = (void*)(orig & (~1));
42649         orig_conv.is_owned = false;
42650         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42651         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
42652         uintptr_t ret_ref = 0;
42653         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42654         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42656         ret_ref = (uintptr_t)ret_var.inner;
42657         if (ret_var.is_owned) {
42658                 ret_ref |= 1;
42659         }
42660         return ret_ref;
42661 }
42662
42663 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
42664         LDKProbabilisticScoringParameters obj_conv;
42665         obj_conv.inner = (void*)(obj & (~1));
42666         obj_conv.is_owned = false;
42667         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42668         LDKCVec_u8Z ret_var = ProbabilisticScoringParameters_write(&obj_conv);
42669         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42670         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42671         CVec_u8Z_free(ret_var);
42672         return ret_arr;
42673 }
42674
42675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42676         LDKu8slice ser_ref;
42677         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42678         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42679         LDKCResult_ProbabilisticScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScoringParametersDecodeErrorZ), "LDKCResult_ProbabilisticScoringParametersDecodeErrorZ");
42680         *ret_conv = ProbabilisticScoringParameters_read(ser_ref);
42681         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42682         return (uintptr_t)ret_conv;
42683 }
42684
42685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
42686         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
42687         uintptr_t ret_ref = 0;
42688         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42689         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42691         ret_ref = (uintptr_t)ret_var.inner;
42692         if (ret_var.is_owned) {
42693                 ret_ref |= 1;
42694         }
42695         return ret_ref;
42696 }
42697
42698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42699         LDKFilesystemPersister this_obj_conv;
42700         this_obj_conv.inner = (void*)(this_obj & (~1));
42701         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42703         FilesystemPersister_free(this_obj_conv);
42704 }
42705
42706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
42707         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
42708         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
42709         uintptr_t ret_ref = 0;
42710         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42711         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42713         ret_ref = (uintptr_t)ret_var.inner;
42714         if (ret_var.is_owned) {
42715                 ret_ref |= 1;
42716         }
42717         return ret_ref;
42718 }
42719
42720 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
42721         LDKFilesystemPersister this_arg_conv;
42722         this_arg_conv.inner = (void*)(this_arg & (~1));
42723         this_arg_conv.is_owned = false;
42724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42725         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
42726         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
42727         Str_free(ret_str);
42728         return ret_conv;
42729 }
42730
42731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
42732         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
42733         LDKChannelManager manager_conv;
42734         manager_conv.inner = (void*)(manager & (~1));
42735         manager_conv.is_owned = false;
42736         CHECK_INNER_FIELD_ACCESS_OR_NULL(manager_conv);
42737         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
42738         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
42739         return (uintptr_t)ret_conv;
42740 }
42741
42742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
42743         LDKFilesystemPersister this_arg_conv;
42744         this_arg_conv.inner = (void*)(this_arg & (~1));
42745         this_arg_conv.is_owned = false;
42746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42747         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
42748         CHECK_ACCESS(keys_manager_ptr);
42749         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
42750         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
42751                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42752                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
42753         }
42754         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
42755         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
42756         return (uintptr_t)ret_conv;
42757 }
42758
42759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
42760         LDKFilesystemPersister this_arg_conv;
42761         this_arg_conv.inner = (void*)(this_arg & (~1));
42762         this_arg_conv.is_owned = false;
42763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42764         LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
42765         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
42766         return (uintptr_t)ret_ret;
42767 }
42768
42769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42770         LDKBackgroundProcessor this_obj_conv;
42771         this_obj_conv.inner = (void*)(this_obj & (~1));
42772         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42774         BackgroundProcessor_free(this_obj_conv);
42775 }
42776
42777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42778         if ((this_ptr & 1) != 0) return;
42779         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42780         CHECK_ACCESS(this_ptr_ptr);
42781         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(this_ptr_ptr);
42782         FREE((void*)this_ptr);
42783         ChannelManagerPersister_free(this_ptr_conv);
42784 }
42785
42786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(JNIEnv *env, jclass clz, int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t net_graph_msg_handler, int64_t peer_manager, int64_t logger) {
42787         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
42788         CHECK_ACCESS(persister_ptr);
42789         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(persister_ptr);
42790         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
42791                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42792                 LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
42793         }
42794         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
42795         CHECK_ACCESS(event_handler_ptr);
42796         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
42797         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
42798                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42799                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
42800         }
42801         LDKChainMonitor chain_monitor_conv;
42802         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
42803         chain_monitor_conv.is_owned = false;
42804         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
42805         LDKChannelManager channel_manager_conv;
42806         channel_manager_conv.inner = (void*)(channel_manager & (~1));
42807         channel_manager_conv.is_owned = false;
42808         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
42809         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
42810         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
42811         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
42812         CHECK_INNER_FIELD_ACCESS_OR_NULL(net_graph_msg_handler_conv);
42813         LDKPeerManager peer_manager_conv;
42814         peer_manager_conv.inner = (void*)(peer_manager & (~1));
42815         peer_manager_conv.is_owned = false;
42816         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
42817         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42818         CHECK_ACCESS(logger_ptr);
42819         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42820         if (logger_conv.free == LDKLogger_JCalls_free) {
42821                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42822                 LDKLogger_JCalls_cloned(&logger_conv);
42823         }
42824         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, net_graph_msg_handler_conv, &peer_manager_conv, logger_conv);
42825         uintptr_t ret_ref = 0;
42826         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42827         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42829         ret_ref = (uintptr_t)ret_var.inner;
42830         if (ret_var.is_owned) {
42831                 ret_ref |= 1;
42832         }
42833         return ret_ref;
42834 }
42835
42836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
42837         LDKBackgroundProcessor this_arg_conv;
42838         this_arg_conv.inner = (void*)(this_arg & (~1));
42839         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
42840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42841         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
42842         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
42843         *ret_conv = BackgroundProcessor_join(this_arg_conv);
42844         return (uintptr_t)ret_conv;
42845 }
42846
42847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
42848         LDKBackgroundProcessor this_arg_conv;
42849         this_arg_conv.inner = (void*)(this_arg & (~1));
42850         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
42851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42852         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
42853         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
42854         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
42855         return (uintptr_t)ret_conv;
42856 }
42857
42858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42859         LDKInvoice this_obj_conv;
42860         this_obj_conv.inner = (void*)(this_obj & (~1));
42861         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42863         Invoice_free(this_obj_conv);
42864 }
42865
42866 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42867         LDKInvoice a_conv;
42868         a_conv.inner = (void*)(a & (~1));
42869         a_conv.is_owned = false;
42870         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42871         LDKInvoice b_conv;
42872         b_conv.inner = (void*)(b & (~1));
42873         b_conv.is_owned = false;
42874         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42875         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
42876         return ret_val;
42877 }
42878
42879 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
42880         LDKInvoice ret_var = Invoice_clone(arg);
42881 uintptr_t ret_ref = 0;
42882 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42883 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42884 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42885 ret_ref = (uintptr_t)ret_var.inner;
42886 if (ret_var.is_owned) {
42887         ret_ref |= 1;
42888 }
42889         return ret_ref;
42890 }
42891 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42892         LDKInvoice arg_conv;
42893         arg_conv.inner = (void*)(arg & (~1));
42894         arg_conv.is_owned = false;
42895         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42896         intptr_t ret_val = Invoice_clone_ptr(&arg_conv);
42897         return ret_val;
42898 }
42899
42900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42901         LDKInvoice orig_conv;
42902         orig_conv.inner = (void*)(orig & (~1));
42903         orig_conv.is_owned = false;
42904         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42905         LDKInvoice ret_var = Invoice_clone(&orig_conv);
42906         uintptr_t ret_ref = 0;
42907         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42908         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42909         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42910         ret_ref = (uintptr_t)ret_var.inner;
42911         if (ret_var.is_owned) {
42912                 ret_ref |= 1;
42913         }
42914         return ret_ref;
42915 }
42916
42917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42918         LDKSignedRawInvoice this_obj_conv;
42919         this_obj_conv.inner = (void*)(this_obj & (~1));
42920         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42922         SignedRawInvoice_free(this_obj_conv);
42923 }
42924
42925 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42926         LDKSignedRawInvoice a_conv;
42927         a_conv.inner = (void*)(a & (~1));
42928         a_conv.is_owned = false;
42929         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42930         LDKSignedRawInvoice b_conv;
42931         b_conv.inner = (void*)(b & (~1));
42932         b_conv.is_owned = false;
42933         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42934         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
42935         return ret_val;
42936 }
42937
42938 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
42939         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
42940 uintptr_t ret_ref = 0;
42941 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42942 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42943 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42944 ret_ref = (uintptr_t)ret_var.inner;
42945 if (ret_var.is_owned) {
42946         ret_ref |= 1;
42947 }
42948         return ret_ref;
42949 }
42950 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42951         LDKSignedRawInvoice arg_conv;
42952         arg_conv.inner = (void*)(arg & (~1));
42953         arg_conv.is_owned = false;
42954         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42955         intptr_t ret_val = SignedRawInvoice_clone_ptr(&arg_conv);
42956         return ret_val;
42957 }
42958
42959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42960         LDKSignedRawInvoice orig_conv;
42961         orig_conv.inner = (void*)(orig & (~1));
42962         orig_conv.is_owned = false;
42963         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42964         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
42965         uintptr_t ret_ref = 0;
42966         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42967         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42969         ret_ref = (uintptr_t)ret_var.inner;
42970         if (ret_var.is_owned) {
42971                 ret_ref |= 1;
42972         }
42973         return ret_ref;
42974 }
42975
42976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42977         LDKRawInvoice this_obj_conv;
42978         this_obj_conv.inner = (void*)(this_obj & (~1));
42979         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42981         RawInvoice_free(this_obj_conv);
42982 }
42983
42984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
42985         LDKRawInvoice this_ptr_conv;
42986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42987         this_ptr_conv.is_owned = false;
42988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42989         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
42990         uintptr_t ret_ref = 0;
42991         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42992         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42994         ret_ref = (uintptr_t)ret_var.inner;
42995         if (ret_var.is_owned) {
42996                 ret_ref |= 1;
42997         }
42998         return ret_ref;
42999 }
43000
43001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43002         LDKRawInvoice this_ptr_conv;
43003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43004         this_ptr_conv.is_owned = false;
43005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43006         LDKRawDataPart val_conv;
43007         val_conv.inner = (void*)(val & (~1));
43008         val_conv.is_owned = (val & 1) || (val == 0);
43009         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43010         val_conv = RawDataPart_clone(&val_conv);
43011         RawInvoice_set_data(&this_ptr_conv, val_conv);
43012 }
43013
43014 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43015         LDKRawInvoice a_conv;
43016         a_conv.inner = (void*)(a & (~1));
43017         a_conv.is_owned = false;
43018         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43019         LDKRawInvoice b_conv;
43020         b_conv.inner = (void*)(b & (~1));
43021         b_conv.is_owned = false;
43022         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43023         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
43024         return ret_val;
43025 }
43026
43027 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
43028         LDKRawInvoice ret_var = RawInvoice_clone(arg);
43029 uintptr_t ret_ref = 0;
43030 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43031 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43032 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43033 ret_ref = (uintptr_t)ret_var.inner;
43034 if (ret_var.is_owned) {
43035         ret_ref |= 1;
43036 }
43037         return ret_ref;
43038 }
43039 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43040         LDKRawInvoice arg_conv;
43041         arg_conv.inner = (void*)(arg & (~1));
43042         arg_conv.is_owned = false;
43043         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43044         intptr_t ret_val = RawInvoice_clone_ptr(&arg_conv);
43045         return ret_val;
43046 }
43047
43048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43049         LDKRawInvoice orig_conv;
43050         orig_conv.inner = (void*)(orig & (~1));
43051         orig_conv.is_owned = false;
43052         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43053         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
43054         uintptr_t ret_ref = 0;
43055         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43056         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43058         ret_ref = (uintptr_t)ret_var.inner;
43059         if (ret_var.is_owned) {
43060                 ret_ref |= 1;
43061         }
43062         return ret_ref;
43063 }
43064
43065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43066         LDKRawDataPart this_obj_conv;
43067         this_obj_conv.inner = (void*)(this_obj & (~1));
43068         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43070         RawDataPart_free(this_obj_conv);
43071 }
43072
43073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
43074         LDKRawDataPart this_ptr_conv;
43075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43076         this_ptr_conv.is_owned = false;
43077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43078         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
43079         uintptr_t ret_ref = 0;
43080         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43081         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43083         ret_ref = (uintptr_t)ret_var.inner;
43084         if (ret_var.is_owned) {
43085                 ret_ref |= 1;
43086         }
43087         return ret_ref;
43088 }
43089
43090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43091         LDKRawDataPart this_ptr_conv;
43092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43093         this_ptr_conv.is_owned = false;
43094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43095         LDKPositiveTimestamp val_conv;
43096         val_conv.inner = (void*)(val & (~1));
43097         val_conv.is_owned = (val & 1) || (val == 0);
43098         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43099         val_conv = PositiveTimestamp_clone(&val_conv);
43100         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
43101 }
43102
43103 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43104         LDKRawDataPart a_conv;
43105         a_conv.inner = (void*)(a & (~1));
43106         a_conv.is_owned = false;
43107         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43108         LDKRawDataPart b_conv;
43109         b_conv.inner = (void*)(b & (~1));
43110         b_conv.is_owned = false;
43111         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43112         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
43113         return ret_val;
43114 }
43115
43116 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
43117         LDKRawDataPart ret_var = RawDataPart_clone(arg);
43118 uintptr_t ret_ref = 0;
43119 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43120 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43121 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43122 ret_ref = (uintptr_t)ret_var.inner;
43123 if (ret_var.is_owned) {
43124         ret_ref |= 1;
43125 }
43126         return ret_ref;
43127 }
43128 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43129         LDKRawDataPart arg_conv;
43130         arg_conv.inner = (void*)(arg & (~1));
43131         arg_conv.is_owned = false;
43132         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43133         intptr_t ret_val = RawDataPart_clone_ptr(&arg_conv);
43134         return ret_val;
43135 }
43136
43137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43138         LDKRawDataPart orig_conv;
43139         orig_conv.inner = (void*)(orig & (~1));
43140         orig_conv.is_owned = false;
43141         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43142         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
43143         uintptr_t ret_ref = 0;
43144         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43145         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43147         ret_ref = (uintptr_t)ret_var.inner;
43148         if (ret_var.is_owned) {
43149                 ret_ref |= 1;
43150         }
43151         return ret_ref;
43152 }
43153
43154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43155         LDKPositiveTimestamp this_obj_conv;
43156         this_obj_conv.inner = (void*)(this_obj & (~1));
43157         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43159         PositiveTimestamp_free(this_obj_conv);
43160 }
43161
43162 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43163         LDKPositiveTimestamp a_conv;
43164         a_conv.inner = (void*)(a & (~1));
43165         a_conv.is_owned = false;
43166         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43167         LDKPositiveTimestamp b_conv;
43168         b_conv.inner = (void*)(b & (~1));
43169         b_conv.is_owned = false;
43170         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43171         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
43172         return ret_val;
43173 }
43174
43175 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
43176         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
43177 uintptr_t ret_ref = 0;
43178 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43179 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43180 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43181 ret_ref = (uintptr_t)ret_var.inner;
43182 if (ret_var.is_owned) {
43183         ret_ref |= 1;
43184 }
43185         return ret_ref;
43186 }
43187 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43188         LDKPositiveTimestamp arg_conv;
43189         arg_conv.inner = (void*)(arg & (~1));
43190         arg_conv.is_owned = false;
43191         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43192         intptr_t ret_val = PositiveTimestamp_clone_ptr(&arg_conv);
43193         return ret_val;
43194 }
43195
43196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43197         LDKPositiveTimestamp orig_conv;
43198         orig_conv.inner = (void*)(orig & (~1));
43199         orig_conv.is_owned = false;
43200         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43201         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
43202         uintptr_t ret_ref = 0;
43203         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43204         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43206         ret_ref = (uintptr_t)ret_var.inner;
43207         if (ret_var.is_owned) {
43208                 ret_ref |= 1;
43209         }
43210         return ret_ref;
43211 }
43212
43213 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43214         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
43215         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
43216         return ret_conv;
43217 }
43218
43219 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
43220         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
43221         return ret_conv;
43222 }
43223
43224 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
43225         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
43226         return ret_conv;
43227 }
43228
43229 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
43230         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
43231         return ret_conv;
43232 }
43233
43234 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
43235         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
43236         return ret_conv;
43237 }
43238
43239 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43240         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
43241         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
43242         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
43243         return ret_val;
43244 }
43245
43246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
43247         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
43248         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
43249         return ret_val;
43250 }
43251
43252 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43253         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
43254         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
43255         return ret_conv;
43256 }
43257
43258 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
43259         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
43260         return ret_conv;
43261 }
43262
43263 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
43264         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
43265         return ret_conv;
43266 }
43267
43268 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
43269         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
43270         return ret_conv;
43271 }
43272
43273 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
43274         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
43275         return ret_conv;
43276 }
43277
43278 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
43279         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
43280         return ret_conv;
43281 }
43282
43283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
43284         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
43285         int64_t ret_val = Currency_hash(o_conv);
43286         return ret_val;
43287 }
43288
43289 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43290         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
43291         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
43292         jboolean ret_val = Currency_eq(a_conv, b_conv);
43293         return ret_val;
43294 }
43295
43296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43297         LDKSha256 this_obj_conv;
43298         this_obj_conv.inner = (void*)(this_obj & (~1));
43299         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43301         Sha256_free(this_obj_conv);
43302 }
43303
43304 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
43305         LDKSha256 ret_var = Sha256_clone(arg);
43306 uintptr_t ret_ref = 0;
43307 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43308 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43309 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43310 ret_ref = (uintptr_t)ret_var.inner;
43311 if (ret_var.is_owned) {
43312         ret_ref |= 1;
43313 }
43314         return ret_ref;
43315 }
43316 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43317         LDKSha256 arg_conv;
43318         arg_conv.inner = (void*)(arg & (~1));
43319         arg_conv.is_owned = false;
43320         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43321         intptr_t ret_val = Sha256_clone_ptr(&arg_conv);
43322         return ret_val;
43323 }
43324
43325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43326         LDKSha256 orig_conv;
43327         orig_conv.inner = (void*)(orig & (~1));
43328         orig_conv.is_owned = false;
43329         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43330         LDKSha256 ret_var = Sha256_clone(&orig_conv);
43331         uintptr_t ret_ref = 0;
43332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43335         ret_ref = (uintptr_t)ret_var.inner;
43336         if (ret_var.is_owned) {
43337                 ret_ref |= 1;
43338         }
43339         return ret_ref;
43340 }
43341
43342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
43343         LDKSha256 o_conv;
43344         o_conv.inner = (void*)(o & (~1));
43345         o_conv.is_owned = false;
43346         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43347         int64_t ret_val = Sha256_hash(&o_conv);
43348         return ret_val;
43349 }
43350
43351 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43352         LDKSha256 a_conv;
43353         a_conv.inner = (void*)(a & (~1));
43354         a_conv.is_owned = false;
43355         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43356         LDKSha256 b_conv;
43357         b_conv.inner = (void*)(b & (~1));
43358         b_conv.is_owned = false;
43359         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43360         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
43361         return ret_val;
43362 }
43363
43364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43365         LDKDescription this_obj_conv;
43366         this_obj_conv.inner = (void*)(this_obj & (~1));
43367         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43369         Description_free(this_obj_conv);
43370 }
43371
43372 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
43373         LDKDescription ret_var = Description_clone(arg);
43374 uintptr_t ret_ref = 0;
43375 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43376 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43377 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43378 ret_ref = (uintptr_t)ret_var.inner;
43379 if (ret_var.is_owned) {
43380         ret_ref |= 1;
43381 }
43382         return ret_ref;
43383 }
43384 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43385         LDKDescription arg_conv;
43386         arg_conv.inner = (void*)(arg & (~1));
43387         arg_conv.is_owned = false;
43388         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43389         intptr_t ret_val = Description_clone_ptr(&arg_conv);
43390         return ret_val;
43391 }
43392
43393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43394         LDKDescription orig_conv;
43395         orig_conv.inner = (void*)(orig & (~1));
43396         orig_conv.is_owned = false;
43397         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43398         LDKDescription ret_var = Description_clone(&orig_conv);
43399         uintptr_t ret_ref = 0;
43400         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43401         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43403         ret_ref = (uintptr_t)ret_var.inner;
43404         if (ret_var.is_owned) {
43405                 ret_ref |= 1;
43406         }
43407         return ret_ref;
43408 }
43409
43410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
43411         LDKDescription o_conv;
43412         o_conv.inner = (void*)(o & (~1));
43413         o_conv.is_owned = false;
43414         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43415         int64_t ret_val = Description_hash(&o_conv);
43416         return ret_val;
43417 }
43418
43419 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43420         LDKDescription a_conv;
43421         a_conv.inner = (void*)(a & (~1));
43422         a_conv.is_owned = false;
43423         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43424         LDKDescription b_conv;
43425         b_conv.inner = (void*)(b & (~1));
43426         b_conv.is_owned = false;
43427         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43428         jboolean ret_val = Description_eq(&a_conv, &b_conv);
43429         return ret_val;
43430 }
43431
43432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43433         LDKPayeePubKey this_obj_conv;
43434         this_obj_conv.inner = (void*)(this_obj & (~1));
43435         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43437         PayeePubKey_free(this_obj_conv);
43438 }
43439
43440 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
43441         LDKPayeePubKey this_ptr_conv;
43442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43443         this_ptr_conv.is_owned = false;
43444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43445         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
43446         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
43447         return ret_arr;
43448 }
43449
43450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43451         LDKPayeePubKey this_ptr_conv;
43452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43453         this_ptr_conv.is_owned = false;
43454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43455         LDKPublicKey val_ref;
43456         CHECK((*env)->GetArrayLength(env, val) == 33);
43457         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
43458         PayeePubKey_set_a(&this_ptr_conv, val_ref);
43459 }
43460
43461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
43462         LDKPublicKey a_arg_ref;
43463         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
43464         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
43465         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
43466         uintptr_t ret_ref = 0;
43467         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43468         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43470         ret_ref = (uintptr_t)ret_var.inner;
43471         if (ret_var.is_owned) {
43472                 ret_ref |= 1;
43473         }
43474         return ret_ref;
43475 }
43476
43477 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
43478         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
43479 uintptr_t ret_ref = 0;
43480 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43481 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43482 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43483 ret_ref = (uintptr_t)ret_var.inner;
43484 if (ret_var.is_owned) {
43485         ret_ref |= 1;
43486 }
43487         return ret_ref;
43488 }
43489 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43490         LDKPayeePubKey arg_conv;
43491         arg_conv.inner = (void*)(arg & (~1));
43492         arg_conv.is_owned = false;
43493         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43494         intptr_t ret_val = PayeePubKey_clone_ptr(&arg_conv);
43495         return ret_val;
43496 }
43497
43498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43499         LDKPayeePubKey orig_conv;
43500         orig_conv.inner = (void*)(orig & (~1));
43501         orig_conv.is_owned = false;
43502         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43503         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
43504         uintptr_t ret_ref = 0;
43505         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43506         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43508         ret_ref = (uintptr_t)ret_var.inner;
43509         if (ret_var.is_owned) {
43510                 ret_ref |= 1;
43511         }
43512         return ret_ref;
43513 }
43514
43515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
43516         LDKPayeePubKey o_conv;
43517         o_conv.inner = (void*)(o & (~1));
43518         o_conv.is_owned = false;
43519         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43520         int64_t ret_val = PayeePubKey_hash(&o_conv);
43521         return ret_val;
43522 }
43523
43524 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43525         LDKPayeePubKey a_conv;
43526         a_conv.inner = (void*)(a & (~1));
43527         a_conv.is_owned = false;
43528         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43529         LDKPayeePubKey b_conv;
43530         b_conv.inner = (void*)(b & (~1));
43531         b_conv.is_owned = false;
43532         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43533         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
43534         return ret_val;
43535 }
43536
43537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43538         LDKExpiryTime this_obj_conv;
43539         this_obj_conv.inner = (void*)(this_obj & (~1));
43540         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43542         ExpiryTime_free(this_obj_conv);
43543 }
43544
43545 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
43546         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
43547 uintptr_t ret_ref = 0;
43548 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43549 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43550 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43551 ret_ref = (uintptr_t)ret_var.inner;
43552 if (ret_var.is_owned) {
43553         ret_ref |= 1;
43554 }
43555         return ret_ref;
43556 }
43557 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43558         LDKExpiryTime arg_conv;
43559         arg_conv.inner = (void*)(arg & (~1));
43560         arg_conv.is_owned = false;
43561         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43562         intptr_t ret_val = ExpiryTime_clone_ptr(&arg_conv);
43563         return ret_val;
43564 }
43565
43566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43567         LDKExpiryTime orig_conv;
43568         orig_conv.inner = (void*)(orig & (~1));
43569         orig_conv.is_owned = false;
43570         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43571         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
43572         uintptr_t ret_ref = 0;
43573         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43574         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43576         ret_ref = (uintptr_t)ret_var.inner;
43577         if (ret_var.is_owned) {
43578                 ret_ref |= 1;
43579         }
43580         return ret_ref;
43581 }
43582
43583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
43584         LDKExpiryTime o_conv;
43585         o_conv.inner = (void*)(o & (~1));
43586         o_conv.is_owned = false;
43587         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43588         int64_t ret_val = ExpiryTime_hash(&o_conv);
43589         return ret_val;
43590 }
43591
43592 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43593         LDKExpiryTime a_conv;
43594         a_conv.inner = (void*)(a & (~1));
43595         a_conv.is_owned = false;
43596         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43597         LDKExpiryTime b_conv;
43598         b_conv.inner = (void*)(b & (~1));
43599         b_conv.is_owned = false;
43600         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43601         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
43602         return ret_val;
43603 }
43604
43605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43606         LDKMinFinalCltvExpiry this_obj_conv;
43607         this_obj_conv.inner = (void*)(this_obj & (~1));
43608         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43610         MinFinalCltvExpiry_free(this_obj_conv);
43611 }
43612
43613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
43614         LDKMinFinalCltvExpiry this_ptr_conv;
43615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43616         this_ptr_conv.is_owned = false;
43617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43618         int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
43619         return ret_val;
43620 }
43621
43622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43623         LDKMinFinalCltvExpiry this_ptr_conv;
43624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43625         this_ptr_conv.is_owned = false;
43626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43627         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
43628 }
43629
43630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
43631         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
43632         uintptr_t ret_ref = 0;
43633         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43634         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43636         ret_ref = (uintptr_t)ret_var.inner;
43637         if (ret_var.is_owned) {
43638                 ret_ref |= 1;
43639         }
43640         return ret_ref;
43641 }
43642
43643 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
43644         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
43645 uintptr_t ret_ref = 0;
43646 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43647 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43648 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43649 ret_ref = (uintptr_t)ret_var.inner;
43650 if (ret_var.is_owned) {
43651         ret_ref |= 1;
43652 }
43653         return ret_ref;
43654 }
43655 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43656         LDKMinFinalCltvExpiry arg_conv;
43657         arg_conv.inner = (void*)(arg & (~1));
43658         arg_conv.is_owned = false;
43659         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43660         intptr_t ret_val = MinFinalCltvExpiry_clone_ptr(&arg_conv);
43661         return ret_val;
43662 }
43663
43664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43665         LDKMinFinalCltvExpiry orig_conv;
43666         orig_conv.inner = (void*)(orig & (~1));
43667         orig_conv.is_owned = false;
43668         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43669         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
43670         uintptr_t ret_ref = 0;
43671         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43672         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43674         ret_ref = (uintptr_t)ret_var.inner;
43675         if (ret_var.is_owned) {
43676                 ret_ref |= 1;
43677         }
43678         return ret_ref;
43679 }
43680
43681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
43682         LDKMinFinalCltvExpiry o_conv;
43683         o_conv.inner = (void*)(o & (~1));
43684         o_conv.is_owned = false;
43685         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43686         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
43687         return ret_val;
43688 }
43689
43690 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43691         LDKMinFinalCltvExpiry a_conv;
43692         a_conv.inner = (void*)(a & (~1));
43693         a_conv.is_owned = false;
43694         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43695         LDKMinFinalCltvExpiry b_conv;
43696         b_conv.inner = (void*)(b & (~1));
43697         b_conv.is_owned = false;
43698         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43699         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
43700         return ret_val;
43701 }
43702
43703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43704         if ((this_ptr & 1) != 0) return;
43705         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43706         CHECK_ACCESS(this_ptr_ptr);
43707         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
43708         FREE((void*)this_ptr);
43709         Fallback_free(this_ptr_conv);
43710 }
43711
43712 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
43713         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43714         *ret_copy = Fallback_clone(arg);
43715 uintptr_t ret_ref = (uintptr_t)ret_copy;
43716         return ret_ref;
43717 }
43718 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43719         LDKFallback* arg_conv = (LDKFallback*)arg;
43720         intptr_t ret_val = Fallback_clone_ptr(arg_conv);
43721         return ret_val;
43722 }
43723
43724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43725         LDKFallback* orig_conv = (LDKFallback*)orig;
43726         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43727         *ret_copy = Fallback_clone(orig_conv);
43728         uintptr_t ret_ref = (uintptr_t)ret_copy;
43729         return ret_ref;
43730 }
43731
43732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
43733         
43734         LDKCVec_u8Z program_ref;
43735         program_ref.datalen = (*env)->GetArrayLength(env, program);
43736         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
43737         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
43738         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43739         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
43740         uintptr_t ret_ref = (uintptr_t)ret_copy;
43741         return ret_ref;
43742 }
43743
43744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
43745         LDKTwentyBytes a_ref;
43746         CHECK((*env)->GetArrayLength(env, a) == 20);
43747         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
43748         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43749         *ret_copy = Fallback_pub_key_hash(a_ref);
43750         uintptr_t ret_ref = (uintptr_t)ret_copy;
43751         return ret_ref;
43752 }
43753
43754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
43755         LDKTwentyBytes a_ref;
43756         CHECK((*env)->GetArrayLength(env, a) == 20);
43757         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
43758         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43759         *ret_copy = Fallback_script_hash(a_ref);
43760         uintptr_t ret_ref = (uintptr_t)ret_copy;
43761         return ret_ref;
43762 }
43763
43764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
43765         LDKFallback* o_conv = (LDKFallback*)o;
43766         int64_t ret_val = Fallback_hash(o_conv);
43767         return ret_val;
43768 }
43769
43770 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43771         LDKFallback* a_conv = (LDKFallback*)a;
43772         LDKFallback* b_conv = (LDKFallback*)b;
43773         jboolean ret_val = Fallback_eq(a_conv, b_conv);
43774         return ret_val;
43775 }
43776
43777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43778         LDKInvoiceSignature this_obj_conv;
43779         this_obj_conv.inner = (void*)(this_obj & (~1));
43780         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43782         InvoiceSignature_free(this_obj_conv);
43783 }
43784
43785 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
43786         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
43787 uintptr_t ret_ref = 0;
43788 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43789 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43790 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43791 ret_ref = (uintptr_t)ret_var.inner;
43792 if (ret_var.is_owned) {
43793         ret_ref |= 1;
43794 }
43795         return ret_ref;
43796 }
43797 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43798         LDKInvoiceSignature arg_conv;
43799         arg_conv.inner = (void*)(arg & (~1));
43800         arg_conv.is_owned = false;
43801         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43802         intptr_t ret_val = InvoiceSignature_clone_ptr(&arg_conv);
43803         return ret_val;
43804 }
43805
43806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43807         LDKInvoiceSignature orig_conv;
43808         orig_conv.inner = (void*)(orig & (~1));
43809         orig_conv.is_owned = false;
43810         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43811         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
43812         uintptr_t ret_ref = 0;
43813         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43814         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43815         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43816         ret_ref = (uintptr_t)ret_var.inner;
43817         if (ret_var.is_owned) {
43818                 ret_ref |= 1;
43819         }
43820         return ret_ref;
43821 }
43822
43823 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43824         LDKInvoiceSignature a_conv;
43825         a_conv.inner = (void*)(a & (~1));
43826         a_conv.is_owned = false;
43827         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43828         LDKInvoiceSignature b_conv;
43829         b_conv.inner = (void*)(b & (~1));
43830         b_conv.is_owned = false;
43831         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43832         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
43833         return ret_val;
43834 }
43835
43836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43837         LDKPrivateRoute this_obj_conv;
43838         this_obj_conv.inner = (void*)(this_obj & (~1));
43839         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43841         PrivateRoute_free(this_obj_conv);
43842 }
43843
43844 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
43845         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
43846 uintptr_t ret_ref = 0;
43847 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43848 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43849 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43850 ret_ref = (uintptr_t)ret_var.inner;
43851 if (ret_var.is_owned) {
43852         ret_ref |= 1;
43853 }
43854         return ret_ref;
43855 }
43856 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43857         LDKPrivateRoute arg_conv;
43858         arg_conv.inner = (void*)(arg & (~1));
43859         arg_conv.is_owned = false;
43860         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43861         intptr_t ret_val = PrivateRoute_clone_ptr(&arg_conv);
43862         return ret_val;
43863 }
43864
43865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43866         LDKPrivateRoute orig_conv;
43867         orig_conv.inner = (void*)(orig & (~1));
43868         orig_conv.is_owned = false;
43869         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43870         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
43871         uintptr_t ret_ref = 0;
43872         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43873         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43875         ret_ref = (uintptr_t)ret_var.inner;
43876         if (ret_var.is_owned) {
43877                 ret_ref |= 1;
43878         }
43879         return ret_ref;
43880 }
43881
43882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
43883         LDKPrivateRoute o_conv;
43884         o_conv.inner = (void*)(o & (~1));
43885         o_conv.is_owned = false;
43886         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43887         int64_t ret_val = PrivateRoute_hash(&o_conv);
43888         return ret_val;
43889 }
43890
43891 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43892         LDKPrivateRoute a_conv;
43893         a_conv.inner = (void*)(a & (~1));
43894         a_conv.is_owned = false;
43895         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43896         LDKPrivateRoute b_conv;
43897         b_conv.inner = (void*)(b & (~1));
43898         b_conv.is_owned = false;
43899         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43900         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
43901         return ret_val;
43902 }
43903
43904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
43905         LDKSignedRawInvoice this_arg_conv;
43906         this_arg_conv.inner = (void*)(this_arg & (~1));
43907         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
43908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43909         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
43910         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
43911         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
43912         return ((uintptr_t)ret_conv);
43913 }
43914
43915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
43916         LDKSignedRawInvoice this_arg_conv;
43917         this_arg_conv.inner = (void*)(this_arg & (~1));
43918         this_arg_conv.is_owned = false;
43919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43920         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
43921         uintptr_t ret_ref = 0;
43922         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43923         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43925         ret_ref = (uintptr_t)ret_var.inner;
43926         if (ret_var.is_owned) {
43927                 ret_ref |= 1;
43928         }
43929         return ret_ref;
43930 }
43931
43932 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
43933         LDKSignedRawInvoice this_arg_conv;
43934         this_arg_conv.inner = (void*)(this_arg & (~1));
43935         this_arg_conv.is_owned = false;
43936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43937         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43938         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
43939         return ret_arr;
43940 }
43941
43942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
43943         LDKSignedRawInvoice this_arg_conv;
43944         this_arg_conv.inner = (void*)(this_arg & (~1));
43945         this_arg_conv.is_owned = false;
43946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43947         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
43948         uintptr_t ret_ref = 0;
43949         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43950         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43952         ret_ref = (uintptr_t)ret_var.inner;
43953         if (ret_var.is_owned) {
43954                 ret_ref |= 1;
43955         }
43956         return ret_ref;
43957 }
43958
43959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
43960         LDKSignedRawInvoice this_arg_conv;
43961         this_arg_conv.inner = (void*)(this_arg & (~1));
43962         this_arg_conv.is_owned = false;
43963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43964         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
43965         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
43966         return (uintptr_t)ret_conv;
43967 }
43968
43969 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
43970         LDKSignedRawInvoice this_arg_conv;
43971         this_arg_conv.inner = (void*)(this_arg & (~1));
43972         this_arg_conv.is_owned = false;
43973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43974         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
43975         return ret_val;
43976 }
43977
43978 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
43979         LDKRawInvoice this_arg_conv;
43980         this_arg_conv.inner = (void*)(this_arg & (~1));
43981         this_arg_conv.is_owned = false;
43982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43983         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43984         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
43985         return ret_arr;
43986 }
43987
43988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
43989         LDKRawInvoice this_arg_conv;
43990         this_arg_conv.inner = (void*)(this_arg & (~1));
43991         this_arg_conv.is_owned = false;
43992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43993         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
43994         uintptr_t ret_ref = 0;
43995         if ((uintptr_t)ret_var.inner > 4096) {
43996                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43997                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43999                 ret_ref = (uintptr_t)ret_var.inner;
44000                 if (ret_var.is_owned) {
44001                         ret_ref |= 1;
44002                 }
44003         }
44004         return ret_ref;
44005 }
44006
44007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
44008         LDKRawInvoice this_arg_conv;
44009         this_arg_conv.inner = (void*)(this_arg & (~1));
44010         this_arg_conv.is_owned = false;
44011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44012         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
44013         uintptr_t ret_ref = 0;
44014         if ((uintptr_t)ret_var.inner > 4096) {
44015                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44016                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44018                 ret_ref = (uintptr_t)ret_var.inner;
44019                 if (ret_var.is_owned) {
44020                         ret_ref |= 1;
44021                 }
44022         }
44023         return ret_ref;
44024 }
44025
44026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44027         LDKRawInvoice this_arg_conv;
44028         this_arg_conv.inner = (void*)(this_arg & (~1));
44029         this_arg_conv.is_owned = false;
44030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44031         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
44032         uintptr_t ret_ref = 0;
44033         if ((uintptr_t)ret_var.inner > 4096) {
44034                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44035                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44037                 ret_ref = (uintptr_t)ret_var.inner;
44038                 if (ret_var.is_owned) {
44039                         ret_ref |= 1;
44040                 }
44041         }
44042         return ret_ref;
44043 }
44044
44045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
44046         LDKRawInvoice this_arg_conv;
44047         this_arg_conv.inner = (void*)(this_arg & (~1));
44048         this_arg_conv.is_owned = false;
44049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44050         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
44051         uintptr_t ret_ref = 0;
44052         if ((uintptr_t)ret_var.inner > 4096) {
44053                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44054                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44056                 ret_ref = (uintptr_t)ret_var.inner;
44057                 if (ret_var.is_owned) {
44058                         ret_ref |= 1;
44059                 }
44060         }
44061         return ret_ref;
44062 }
44063
44064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
44065         LDKRawInvoice this_arg_conv;
44066         this_arg_conv.inner = (void*)(this_arg & (~1));
44067         this_arg_conv.is_owned = false;
44068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44069         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
44070         uintptr_t ret_ref = 0;
44071         if ((uintptr_t)ret_var.inner > 4096) {
44072                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44073                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44075                 ret_ref = (uintptr_t)ret_var.inner;
44076                 if (ret_var.is_owned) {
44077                         ret_ref |= 1;
44078                 }
44079         }
44080         return ret_ref;
44081 }
44082
44083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
44084         LDKRawInvoice this_arg_conv;
44085         this_arg_conv.inner = (void*)(this_arg & (~1));
44086         this_arg_conv.is_owned = false;
44087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44088         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
44089         uintptr_t ret_ref = 0;
44090         if ((uintptr_t)ret_var.inner > 4096) {
44091                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44092                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44094                 ret_ref = (uintptr_t)ret_var.inner;
44095                 if (ret_var.is_owned) {
44096                         ret_ref |= 1;
44097                 }
44098         }
44099         return ret_ref;
44100 }
44101
44102 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
44103         LDKRawInvoice this_arg_conv;
44104         this_arg_conv.inner = (void*)(this_arg & (~1));
44105         this_arg_conv.is_owned = false;
44106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44107         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44108         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
44109         return ret_arr;
44110 }
44111
44112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
44113         LDKRawInvoice this_arg_conv;
44114         this_arg_conv.inner = (void*)(this_arg & (~1));
44115         this_arg_conv.is_owned = false;
44116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44117         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
44118         uintptr_t ret_ref = 0;
44119         if ((uintptr_t)ret_var.inner > 4096) {
44120                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44121                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44123                 ret_ref = (uintptr_t)ret_var.inner;
44124                 if (ret_var.is_owned) {
44125                         ret_ref |= 1;
44126                 }
44127         }
44128         return ret_ref;
44129 }
44130
44131 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
44132         LDKRawInvoice this_arg_conv;
44133         this_arg_conv.inner = (void*)(this_arg & (~1));
44134         this_arg_conv.is_owned = false;
44135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44136         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
44137         int64_tArray ret_arr = NULL;
44138         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44139         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44140         for (size_t o = 0; o < ret_var.datalen; o++) {
44141                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
44142                 uintptr_t ret_conv_14_ref = 0;
44143                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44144                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44145                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
44146                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
44147                 if (ret_conv_14_var.is_owned) {
44148                         ret_conv_14_ref |= 1;
44149                 }
44150                 ret_arr_ptr[o] = ret_conv_14_ref;
44151         }
44152         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44153         FREE(ret_var.data);
44154         return ret_arr;
44155 }
44156
44157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
44158         LDKRawInvoice this_arg_conv;
44159         this_arg_conv.inner = (void*)(this_arg & (~1));
44160         this_arg_conv.is_owned = false;
44161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44162         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
44163         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
44164         uintptr_t ret_ref = (uintptr_t)ret_copy;
44165         return ret_ref;
44166 }
44167
44168 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
44169         LDKRawInvoice this_arg_conv;
44170         this_arg_conv.inner = (void*)(this_arg & (~1));
44171         this_arg_conv.is_owned = false;
44172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44173         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
44174         return ret_conv;
44175 }
44176
44177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
44178         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
44179         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
44180         return (uintptr_t)ret_conv;
44181 }
44182
44183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
44184         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
44185         *ret_conv = PositiveTimestamp_from_system_time(time);
44186         return (uintptr_t)ret_conv;
44187 }
44188
44189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
44190         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
44191         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
44192         return (uintptr_t)ret_conv;
44193 }
44194
44195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
44196         LDKPositiveTimestamp this_arg_conv;
44197         this_arg_conv.inner = (void*)(this_arg & (~1));
44198         this_arg_conv.is_owned = false;
44199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44200         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
44201         return ret_val;
44202 }
44203
44204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
44205         LDKPositiveTimestamp this_arg_conv;
44206         this_arg_conv.inner = (void*)(this_arg & (~1));
44207         this_arg_conv.is_owned = false;
44208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44209         int64_t ret_val = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
44210         return ret_val;
44211 }
44212
44213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
44214         LDKPositiveTimestamp this_arg_conv;
44215         this_arg_conv.inner = (void*)(this_arg & (~1));
44216         this_arg_conv.is_owned = false;
44217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44218         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
44219         return ret_val;
44220 }
44221
44222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
44223         LDKInvoice this_arg_conv;
44224         this_arg_conv.inner = (void*)(this_arg & (~1));
44225         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44227         this_arg_conv = Invoice_clone(&this_arg_conv);
44228         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
44229         uintptr_t ret_ref = 0;
44230         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44231         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44233         ret_ref = (uintptr_t)ret_var.inner;
44234         if (ret_var.is_owned) {
44235                 ret_ref |= 1;
44236         }
44237         return ret_ref;
44238 }
44239
44240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
44241         LDKInvoice this_arg_conv;
44242         this_arg_conv.inner = (void*)(this_arg & (~1));
44243         this_arg_conv.is_owned = false;
44244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44245         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
44246         *ret_conv = Invoice_check_signature(&this_arg_conv);
44247         return (uintptr_t)ret_conv;
44248 }
44249
44250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
44251         LDKSignedRawInvoice signed_invoice_conv;
44252         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
44253         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
44254         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
44255         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
44256         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
44257         *ret_conv = Invoice_from_signed(signed_invoice_conv);
44258         return (uintptr_t)ret_conv;
44259 }
44260
44261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
44262         LDKInvoice this_arg_conv;
44263         this_arg_conv.inner = (void*)(this_arg & (~1));
44264         this_arg_conv.is_owned = false;
44265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44266         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
44267         return ret_val;
44268 }
44269
44270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
44271         LDKInvoice this_arg_conv;
44272         this_arg_conv.inner = (void*)(this_arg & (~1));
44273         this_arg_conv.is_owned = false;
44274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44275         int64_t ret_val = Invoice_duration_since_epoch(&this_arg_conv);
44276         return ret_val;
44277 }
44278
44279 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
44280         LDKInvoice this_arg_conv;
44281         this_arg_conv.inner = (void*)(this_arg & (~1));
44282         this_arg_conv.is_owned = false;
44283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44284         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44285         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
44286         return ret_arr;
44287 }
44288
44289 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44290         LDKInvoice this_arg_conv;
44291         this_arg_conv.inner = (void*)(this_arg & (~1));
44292         this_arg_conv.is_owned = false;
44293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44294         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44295         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
44296         return ret_arr;
44297 }
44298
44299 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
44300         LDKInvoice this_arg_conv;
44301         this_arg_conv.inner = (void*)(this_arg & (~1));
44302         this_arg_conv.is_owned = false;
44303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44304         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44305         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
44306         return ret_arr;
44307 }
44308
44309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
44310         LDKInvoice this_arg_conv;
44311         this_arg_conv.inner = (void*)(this_arg & (~1));
44312         this_arg_conv.is_owned = false;
44313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44314         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
44315         uintptr_t ret_ref = 0;
44316         if ((uintptr_t)ret_var.inner > 4096) {
44317                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44318                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44320                 ret_ref = (uintptr_t)ret_var.inner;
44321                 if (ret_var.is_owned) {
44322                         ret_ref |= 1;
44323                 }
44324         }
44325         return ret_ref;
44326 }
44327
44328 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44329         LDKInvoice this_arg_conv;
44330         this_arg_conv.inner = (void*)(this_arg & (~1));
44331         this_arg_conv.is_owned = false;
44332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44333         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44334         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
44335         return ret_arr;
44336 }
44337
44338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
44339         LDKInvoice this_arg_conv;
44340         this_arg_conv.inner = (void*)(this_arg & (~1));
44341         this_arg_conv.is_owned = false;
44342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44343         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
44344         return ret_val;
44345 }
44346
44347 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
44348         LDKInvoice this_arg_conv;
44349         this_arg_conv.inner = (void*)(this_arg & (~1));
44350         this_arg_conv.is_owned = false;
44351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44352         jboolean ret_val = Invoice_is_expired(&this_arg_conv);
44353         return ret_val;
44354 }
44355
44356 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
44357         LDKInvoice this_arg_conv;
44358         this_arg_conv.inner = (void*)(this_arg & (~1));
44359         this_arg_conv.is_owned = false;
44360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44361         jboolean ret_val = Invoice_would_expire(&this_arg_conv, at_time);
44362         return ret_val;
44363 }
44364
44365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
44366         LDKInvoice this_arg_conv;
44367         this_arg_conv.inner = (void*)(this_arg & (~1));
44368         this_arg_conv.is_owned = false;
44369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44370         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
44371         return ret_val;
44372 }
44373
44374 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
44375         LDKInvoice this_arg_conv;
44376         this_arg_conv.inner = (void*)(this_arg & (~1));
44377         this_arg_conv.is_owned = false;
44378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44379         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
44380         int64_tArray ret_arr = NULL;
44381         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44382         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44383         for (size_t o = 0; o < ret_var.datalen; o++) {
44384                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
44385                 uintptr_t ret_conv_14_ref = 0;
44386                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44387                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44388                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
44389                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
44390                 if (ret_conv_14_var.is_owned) {
44391                         ret_conv_14_ref |= 1;
44392                 }
44393                 ret_arr_ptr[o] = ret_conv_14_ref;
44394         }
44395         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44396         FREE(ret_var.data);
44397         return ret_arr;
44398 }
44399
44400 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
44401         LDKInvoice this_arg_conv;
44402         this_arg_conv.inner = (void*)(this_arg & (~1));
44403         this_arg_conv.is_owned = false;
44404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44405         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
44406         int64_tArray ret_arr = NULL;
44407         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44408         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44409         for (size_t l = 0; l < ret_var.datalen; l++) {
44410                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
44411                 uintptr_t ret_conv_11_ref = 0;
44412                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44413                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44414                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
44415                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
44416                 if (ret_conv_11_var.is_owned) {
44417                         ret_conv_11_ref |= 1;
44418                 }
44419                 ret_arr_ptr[l] = ret_conv_11_ref;
44420         }
44421         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44422         FREE(ret_var.data);
44423         return ret_arr;
44424 }
44425
44426 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
44427         LDKInvoice this_arg_conv;
44428         this_arg_conv.inner = (void*)(this_arg & (~1));
44429         this_arg_conv.is_owned = false;
44430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44431         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
44432         return ret_conv;
44433 }
44434
44435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
44436         LDKInvoice this_arg_conv;
44437         this_arg_conv.inner = (void*)(this_arg & (~1));
44438         this_arg_conv.is_owned = false;
44439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44440         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
44441         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
44442         uintptr_t ret_ref = (uintptr_t)ret_copy;
44443         return ret_ref;
44444 }
44445
44446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
44447         LDKStr description_conv = java_to_owned_str(env, description);
44448         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
44449         *ret_conv = Description_new(description_conv);
44450         return (uintptr_t)ret_conv;
44451 }
44452
44453 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
44454         LDKDescription this_arg_conv;
44455         this_arg_conv.inner = (void*)(this_arg & (~1));
44456         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44458         this_arg_conv = Description_clone(&this_arg_conv);
44459         LDKStr ret_str = Description_into_inner(this_arg_conv);
44460         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
44461         Str_free(ret_str);
44462         return ret_conv;
44463 }
44464
44465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
44466         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
44467         uintptr_t ret_ref = 0;
44468         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44469         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44471         ret_ref = (uintptr_t)ret_var.inner;
44472         if (ret_var.is_owned) {
44473                 ret_ref |= 1;
44474         }
44475         return ret_ref;
44476 }
44477
44478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
44479         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
44480         uintptr_t ret_ref = 0;
44481         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44482         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44484         ret_ref = (uintptr_t)ret_var.inner;
44485         if (ret_var.is_owned) {
44486                 ret_ref |= 1;
44487         }
44488         return ret_ref;
44489 }
44490
44491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
44492         LDKExpiryTime this_arg_conv;
44493         this_arg_conv.inner = (void*)(this_arg & (~1));
44494         this_arg_conv.is_owned = false;
44495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44496         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
44497         return ret_val;
44498 }
44499
44500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
44501         LDKExpiryTime this_arg_conv;
44502         this_arg_conv.inner = (void*)(this_arg & (~1));
44503         this_arg_conv.is_owned = false;
44504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44505         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
44506         return ret_val;
44507 }
44508
44509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
44510         LDKRouteHint hops_conv;
44511         hops_conv.inner = (void*)(hops & (~1));
44512         hops_conv.is_owned = (hops & 1) || (hops == 0);
44513         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
44514         hops_conv = RouteHint_clone(&hops_conv);
44515         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
44516         *ret_conv = PrivateRoute_new(hops_conv);
44517         return (uintptr_t)ret_conv;
44518 }
44519
44520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
44521         LDKPrivateRoute this_arg_conv;
44522         this_arg_conv.inner = (void*)(this_arg & (~1));
44523         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44525         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
44526         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
44527         uintptr_t ret_ref = 0;
44528         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44529         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44531         ret_ref = (uintptr_t)ret_var.inner;
44532         if (ret_var.is_owned) {
44533                 ret_ref |= 1;
44534         }
44535         return ret_ref;
44536 }
44537
44538 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44539         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
44540         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
44541         return ret_conv;
44542 }
44543
44544 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
44545         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
44546         return ret_conv;
44547 }
44548
44549 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
44550         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
44551         return ret_conv;
44552 }
44553
44554 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
44555         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
44556         return ret_conv;
44557 }
44558
44559 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
44560         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
44561         return ret_conv;
44562 }
44563
44564 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
44565         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
44566         return ret_conv;
44567 }
44568
44569 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44570         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
44571         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
44572         jboolean ret_val = CreationError_eq(a_conv, b_conv);
44573         return ret_val;
44574 }
44575
44576 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
44577         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
44578         LDKStr ret_str = CreationError_to_str(o_conv);
44579         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
44580         Str_free(ret_str);
44581         return ret_conv;
44582 }
44583
44584 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44585         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
44586         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
44587         return ret_conv;
44588 }
44589
44590 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
44591         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
44592         return ret_conv;
44593 }
44594
44595 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
44596         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
44597         return ret_conv;
44598 }
44599
44600 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
44601         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
44602         return ret_conv;
44603 }
44604
44605 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
44606         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
44607         return ret_conv;
44608 }
44609
44610 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
44611         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
44612         return ret_conv;
44613 }
44614
44615 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
44616         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
44617         return ret_conv;
44618 }
44619
44620 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
44621         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
44622         return ret_conv;
44623 }
44624
44625 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
44626         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
44627         return ret_conv;
44628 }
44629
44630 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
44631         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
44632         return ret_conv;
44633 }
44634
44635 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
44636         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
44637         return ret_conv;
44638 }
44639
44640 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44641         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
44642         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
44643         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
44644         return ret_val;
44645 }
44646
44647 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
44648         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
44649         LDKStr ret_str = SemanticError_to_str(o_conv);
44650         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
44651         Str_free(ret_str);
44652         return ret_conv;
44653 }
44654
44655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44656         if ((this_ptr & 1) != 0) return;
44657         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44658         CHECK_ACCESS(this_ptr_ptr);
44659         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
44660         FREE((void*)this_ptr);
44661         SignOrCreationError_free(this_ptr_conv);
44662 }
44663
44664 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
44665         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
44666         *ret_copy = SignOrCreationError_clone(arg);
44667 uintptr_t ret_ref = (uintptr_t)ret_copy;
44668         return ret_ref;
44669 }
44670 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44671         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
44672         intptr_t ret_val = SignOrCreationError_clone_ptr(arg_conv);
44673         return ret_val;
44674 }
44675
44676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44677         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
44678         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
44679         *ret_copy = SignOrCreationError_clone(orig_conv);
44680         uintptr_t ret_ref = (uintptr_t)ret_copy;
44681         return ret_ref;
44682 }
44683
44684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
44685         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
44686         *ret_copy = SignOrCreationError_sign_error();
44687         uintptr_t ret_ref = (uintptr_t)ret_copy;
44688         return ret_ref;
44689 }
44690
44691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
44692         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
44693         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
44694         *ret_copy = SignOrCreationError_creation_error(a_conv);
44695         uintptr_t ret_ref = (uintptr_t)ret_copy;
44696         return ret_ref;
44697 }
44698
44699 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44700         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
44701         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
44702         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
44703         return ret_val;
44704 }
44705
44706 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
44707         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
44708         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
44709         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
44710         Str_free(ret_str);
44711         return ret_conv;
44712 }
44713
44714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44715         LDKInvoicePayer this_obj_conv;
44716         this_obj_conv.inner = (void*)(this_obj & (~1));
44717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44719         InvoicePayer_free(this_obj_conv);
44720 }
44721
44722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44723         if ((this_ptr & 1) != 0) return;
44724         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44725         CHECK_ACCESS(this_ptr_ptr);
44726         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
44727         FREE((void*)this_ptr);
44728         Payer_free(this_ptr_conv);
44729 }
44730
44731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44732         if ((this_ptr & 1) != 0) return;
44733         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44734         CHECK_ACCESS(this_ptr_ptr);
44735         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
44736         FREE((void*)this_ptr);
44737         Router_free(this_ptr_conv);
44738 }
44739
44740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44741         LDKRetryAttempts this_obj_conv;
44742         this_obj_conv.inner = (void*)(this_obj & (~1));
44743         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44745         RetryAttempts_free(this_obj_conv);
44746 }
44747
44748 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
44749         LDKRetryAttempts this_ptr_conv;
44750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44751         this_ptr_conv.is_owned = false;
44752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44753         intptr_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
44754         return ret_val;
44755 }
44756
44757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, intptr_t val) {
44758         LDKRetryAttempts this_ptr_conv;
44759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44760         this_ptr_conv.is_owned = false;
44761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44762         RetryAttempts_set_a(&this_ptr_conv, val);
44763 }
44764
44765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1new(JNIEnv *env, jclass clz, intptr_t a_arg) {
44766         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
44767         uintptr_t ret_ref = 0;
44768         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44769         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44771         ret_ref = (uintptr_t)ret_var.inner;
44772         if (ret_var.is_owned) {
44773                 ret_ref |= 1;
44774         }
44775         return ret_ref;
44776 }
44777
44778 static inline uintptr_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
44779         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
44780 uintptr_t ret_ref = 0;
44781 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44782 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44783 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44784 ret_ref = (uintptr_t)ret_var.inner;
44785 if (ret_var.is_owned) {
44786         ret_ref |= 1;
44787 }
44788         return ret_ref;
44789 }
44790 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44791         LDKRetryAttempts arg_conv;
44792         arg_conv.inner = (void*)(arg & (~1));
44793         arg_conv.is_owned = false;
44794         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44795         intptr_t ret_val = RetryAttempts_clone_ptr(&arg_conv);
44796         return ret_val;
44797 }
44798
44799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44800         LDKRetryAttempts orig_conv;
44801         orig_conv.inner = (void*)(orig & (~1));
44802         orig_conv.is_owned = false;
44803         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44804         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
44805         uintptr_t ret_ref = 0;
44806         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44807         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44809         ret_ref = (uintptr_t)ret_var.inner;
44810         if (ret_var.is_owned) {
44811                 ret_ref |= 1;
44812         }
44813         return ret_ref;
44814 }
44815
44816 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44817         LDKRetryAttempts a_conv;
44818         a_conv.inner = (void*)(a & (~1));
44819         a_conv.is_owned = false;
44820         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44821         LDKRetryAttempts b_conv;
44822         b_conv.inner = (void*)(b & (~1));
44823         b_conv.is_owned = false;
44824         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44825         jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
44826         return ret_val;
44827 }
44828
44829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1hash(JNIEnv *env, jclass clz, int64_t o) {
44830         LDKRetryAttempts o_conv;
44831         o_conv.inner = (void*)(o & (~1));
44832         o_conv.is_owned = false;
44833         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44834         int64_t ret_val = RetryAttempts_hash(&o_conv);
44835         return ret_val;
44836 }
44837
44838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44839         if ((this_ptr & 1) != 0) return;
44840         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44841         CHECK_ACCESS(this_ptr_ptr);
44842         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
44843         FREE((void*)this_ptr);
44844         PaymentError_free(this_ptr_conv);
44845 }
44846
44847 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
44848         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
44849         *ret_copy = PaymentError_clone(arg);
44850 uintptr_t ret_ref = (uintptr_t)ret_copy;
44851         return ret_ref;
44852 }
44853 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44854         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
44855         intptr_t ret_val = PaymentError_clone_ptr(arg_conv);
44856         return ret_val;
44857 }
44858
44859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44860         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
44861         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
44862         *ret_copy = PaymentError_clone(orig_conv);
44863         uintptr_t ret_ref = (uintptr_t)ret_copy;
44864         return ret_ref;
44865 }
44866
44867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
44868         LDKStr a_conv = java_to_owned_str(env, a);
44869         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
44870         *ret_copy = PaymentError_invoice(a_conv);
44871         uintptr_t ret_ref = (uintptr_t)ret_copy;
44872         return ret_ref;
44873 }
44874
44875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
44876         LDKLightningError a_conv;
44877         a_conv.inner = (void*)(a & (~1));
44878         a_conv.is_owned = (a & 1) || (a == 0);
44879         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44880         a_conv = LightningError_clone(&a_conv);
44881         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
44882         *ret_copy = PaymentError_routing(a_conv);
44883         uintptr_t ret_ref = (uintptr_t)ret_copy;
44884         return ret_ref;
44885 }
44886
44887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
44888         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
44889         CHECK_ACCESS(a_ptr);
44890         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
44891         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
44892         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
44893         *ret_copy = PaymentError_sending(a_conv);
44894         uintptr_t ret_ref = (uintptr_t)ret_copy;
44895         return ret_ref;
44896 }
44897
44898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1new(JNIEnv *env, jclass clz, int64_t payer, int64_t router, int64_t scorer, int64_t logger, int64_t event_handler, int64_t retry_attempts) {
44899         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
44900         CHECK_ACCESS(payer_ptr);
44901         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
44902         if (payer_conv.free == LDKPayer_JCalls_free) {
44903                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44904                 LDKPayer_JCalls_cloned(&payer_conv);
44905         }
44906         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
44907         CHECK_ACCESS(router_ptr);
44908         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
44909         if (router_conv.free == LDKRouter_JCalls_free) {
44910                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44911                 LDKRouter_JCalls_cloned(&router_conv);
44912         }
44913         LDKMultiThreadedLockableScore scorer_conv;
44914         scorer_conv.inner = (void*)(scorer & (~1));
44915         scorer_conv.is_owned = false;
44916         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
44917         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
44918         CHECK_ACCESS(logger_ptr);
44919         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
44920         if (logger_conv.free == LDKLogger_JCalls_free) {
44921                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44922                 LDKLogger_JCalls_cloned(&logger_conv);
44923         }
44924         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
44925         CHECK_ACCESS(event_handler_ptr);
44926         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
44927         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
44928                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44929                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
44930         }
44931         LDKRetryAttempts retry_attempts_conv;
44932         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
44933         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
44934         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
44935         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
44936         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
44937         uintptr_t ret_ref = 0;
44938         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44939         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44941         ret_ref = (uintptr_t)ret_var.inner;
44942         if (ret_var.is_owned) {
44943                 ret_ref |= 1;
44944         }
44945         return ret_ref;
44946 }
44947
44948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
44949         LDKInvoicePayer this_arg_conv;
44950         this_arg_conv.inner = (void*)(this_arg & (~1));
44951         this_arg_conv.is_owned = false;
44952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44953         LDKInvoice invoice_conv;
44954         invoice_conv.inner = (void*)(invoice & (~1));
44955         invoice_conv.is_owned = false;
44956         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
44957         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
44958         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
44959         return (uintptr_t)ret_conv;
44960 }
44961
44962 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) {
44963         LDKInvoicePayer this_arg_conv;
44964         this_arg_conv.inner = (void*)(this_arg & (~1));
44965         this_arg_conv.is_owned = false;
44966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44967         LDKInvoice invoice_conv;
44968         invoice_conv.inner = (void*)(invoice & (~1));
44969         invoice_conv.is_owned = false;
44970         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
44971         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
44972         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
44973         return (uintptr_t)ret_conv;
44974 }
44975
44976 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) {
44977         LDKInvoicePayer this_arg_conv;
44978         this_arg_conv.inner = (void*)(this_arg & (~1));
44979         this_arg_conv.is_owned = false;
44980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44981         LDKPublicKey pubkey_ref;
44982         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
44983         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
44984         LDKThirtyTwoBytes payment_preimage_ref;
44985         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
44986         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
44987         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
44988         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
44989         return (uintptr_t)ret_conv;
44990 }
44991
44992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
44993         LDKInvoicePayer this_arg_conv;
44994         this_arg_conv.inner = (void*)(this_arg & (~1));
44995         this_arg_conv.is_owned = false;
44996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44997         unsigned char payment_hash_arr[32];
44998         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
44999         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
45000         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
45001         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
45002 }
45003
45004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
45005         LDKInvoicePayer this_arg_conv;
45006         this_arg_conv.inner = (void*)(this_arg & (~1));
45007         this_arg_conv.is_owned = false;
45008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45009         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
45010         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
45011         return (uintptr_t)ret_ret;
45012 }
45013
45014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice(JNIEnv *env, jclass clz, int64_t amt_msat, jstring description, int8_tArray payment_hash, int8_tArray payment_secret, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
45015         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
45016         CHECK_ACCESS(amt_msat_ptr);
45017         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
45018         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
45019         LDKStr description_conv = java_to_owned_str(env, description);
45020         LDKThirtyTwoBytes payment_hash_ref;
45021         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
45022         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
45023         LDKThirtyTwoBytes payment_secret_ref;
45024         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
45025         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
45026         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
45027         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
45028         if (phantom_route_hints_constr.datalen > 0)
45029                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
45030         else
45031                 phantom_route_hints_constr.data = NULL;
45032         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
45033         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
45034                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
45035                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
45036                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
45037                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
45038                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
45039                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
45040                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
45041         }
45042         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
45043         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
45044         CHECK_ACCESS(keys_manager_ptr);
45045         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
45046         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
45047                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45048                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
45049         }
45050         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
45051         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
45052         *ret_conv = create_phantom_invoice(amt_msat_conv, description_conv, payment_hash_ref, payment_secret_ref, phantom_route_hints_constr, keys_manager_conv, network_conv);
45053         return (uintptr_t)ret_conv;
45054 }
45055
45056 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) {
45057         LDKChannelManager channelmanager_conv;
45058         channelmanager_conv.inner = (void*)(channelmanager & (~1));
45059         channelmanager_conv.is_owned = false;
45060         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
45061         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
45062         CHECK_ACCESS(keys_manager_ptr);
45063         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
45064         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
45065                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45066                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
45067         }
45068         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
45069         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
45070         CHECK_ACCESS(amt_msat_ptr);
45071         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
45072         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
45073         LDKStr description_conv = java_to_owned_str(env, description);
45074         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
45075         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
45076         return (uintptr_t)ret_conv;
45077 }
45078
45079 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) {
45080         LDKChannelManager channelmanager_conv;
45081         channelmanager_conv.inner = (void*)(channelmanager & (~1));
45082         channelmanager_conv.is_owned = false;
45083         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
45084         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
45085         CHECK_ACCESS(keys_manager_ptr);
45086         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
45087         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
45088                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45089                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
45090         }
45091         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
45092         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
45093         CHECK_ACCESS(amt_msat_ptr);
45094         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
45095         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
45096         LDKStr description_conv = java_to_owned_str(env, description);
45097         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
45098         *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);
45099         return (uintptr_t)ret_conv;
45100 }
45101
45102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45103         LDKDefaultRouter this_obj_conv;
45104         this_obj_conv.inner = (void*)(this_obj & (~1));
45105         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45107         DefaultRouter_free(this_obj_conv);
45108 }
45109
45110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger) {
45111         LDKNetworkGraph network_graph_conv;
45112         network_graph_conv.inner = (void*)(network_graph & (~1));
45113         network_graph_conv.is_owned = false;
45114         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
45115         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45116         CHECK_ACCESS(logger_ptr);
45117         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45118         if (logger_conv.free == LDKLogger_JCalls_free) {
45119                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45120                 LDKLogger_JCalls_cloned(&logger_conv);
45121         }
45122         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv);
45123         uintptr_t ret_ref = 0;
45124         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45125         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45127         ret_ref = (uintptr_t)ret_var.inner;
45128         if (ret_var.is_owned) {
45129                 ret_ref |= 1;
45130         }
45131         return ret_ref;
45132 }
45133
45134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
45135         LDKDefaultRouter this_arg_conv;
45136         this_arg_conv.inner = (void*)(this_arg & (~1));
45137         this_arg_conv.is_owned = false;
45138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45139         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
45140         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
45141         return (uintptr_t)ret_ret;
45142 }
45143
45144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
45145         LDKChannelManager this_arg_conv;
45146         this_arg_conv.inner = (void*)(this_arg & (~1));
45147         this_arg_conv.is_owned = false;
45148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45149         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
45150         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
45151         return (uintptr_t)ret_ret;
45152 }
45153
45154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
45155         LDKStr s_conv = java_to_owned_str(env, s);
45156         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
45157         *ret_conv = SiPrefix_from_str(s_conv);
45158         return (uintptr_t)ret_conv;
45159 }
45160
45161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
45162         LDKStr s_conv = java_to_owned_str(env, s);
45163         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
45164         *ret_conv = Invoice_from_str(s_conv);
45165         return (uintptr_t)ret_conv;
45166 }
45167
45168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
45169         LDKStr s_conv = java_to_owned_str(env, s);
45170         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
45171         *ret_conv = SignedRawInvoice_from_str(s_conv);
45172         return (uintptr_t)ret_conv;
45173 }
45174
45175 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
45176         LDKInvoice o_conv;
45177         o_conv.inner = (void*)(o & (~1));
45178         o_conv.is_owned = false;
45179         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45180         LDKStr ret_str = Invoice_to_str(&o_conv);
45181         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45182         Str_free(ret_str);
45183         return ret_conv;
45184 }
45185
45186 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
45187         LDKSignedRawInvoice o_conv;
45188         o_conv.inner = (void*)(o & (~1));
45189         o_conv.is_owned = false;
45190         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45191         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
45192         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45193         Str_free(ret_str);
45194         return ret_conv;
45195 }
45196
45197 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
45198         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
45199         LDKStr ret_str = Currency_to_str(o_conv);
45200         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45201         Str_free(ret_str);
45202         return ret_conv;
45203 }
45204
45205 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
45206         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
45207         LDKStr ret_str = SiPrefix_to_str(o_conv);
45208         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45209         Str_free(ret_str);
45210         return ret_conv;
45211 }
45212